I can read full response body (big JSON data, more than 400,000 chars) few times, but after 5-6 times my response is not full.
Here's my code of getting response:
URL address = new URL("https://myurl.com/");
HttpURLConnection Connection = (HttpURLConnection)address.openConnection();
Connection.setRequestMethod("GET");
Connection.setRequestProperty("accept-language", "en-US");
Connection.setRequestProperty("user-agent", UserAgent);
Connection.setRequestProperty("cookie", cookies);
Connection.setUseCaches(false);
Connection.setDoInput(true);
Connection.setDoOutput(true);
if (Connection.getResponseCode() == HttpsURLConnection.HTTP_OK)
{
String Response = new String();
InputStream is = Connection.getInputStream();
int ch;
StringBuffer sb = new StringBuffer();
while (( ch = is.read()) != -1) {
sb.append((char) ch);
}
Response = sb.toString();
is.close();
}
In my original code after is.close()
, it is just lot of JSON parsing from Response string