HttpURLConnection getInputStream() returns empty for specific device

580 views Asked by At

Im experiencing a strange behaviour when using HttpURLConnection getInputStream() on a different devices. On all devices except "Alcatel" im getting a valid input stream only for Alcatel devices im getting a different(empty) kind of input stream:

All devices except alcatel enter image description here

Alcatel devices enter image description here

Im making the exact same call and getting 200 for all the devices.

The code is pretty straightforward:

urlObj = new URL(url);
urlConnection = (HttpURLConnection)urlObj.openConnection();
urlConnection.setRequestMethod(method);
urlConnection.setDoInput(true);
urlConnection.setConnectTimeout(timeout);
urlConnection.setReadTimeout(timeout);
urlConnection.setDoOutput(true);
urlConnection.setFixedLengthStreamingMode(body.length);
urlConnection.setRequestProperty(HEADER_KEY_CONTENT_LENGTH, String.valueOf(body.length));
urlConnection.getOutputStream().write(body);

int responseCode = urlConnection.getResponseCode();
InputStream in = urlConnection.getInputStream();

Any suggestions?

1

There are 1 answers

0
andromania On

Please check if you need to have proxy setting for alcatel. httpurlconnection may fail without proper proxy gateway.