Hello,
I have an HTTP Request Dispatcher class that works most of the time, but I had noticed that it "stalls" when receiving larger requests. After looking into the problem, I thought that perhaps I wasn't allocating enough bytes to the buffer. Before, I was doing:
byte[] buffer = new byte[10000];
After changing it to 20000, it seems to have stopped stalling:
String contentType = connection.getHeaderField("Content-type");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream responseData = connection.openInputStream();
byte[] buffer = new byte[20000];
int bytesRead = responseData.read(buffer);
while (bytesRead > 0) {
baos.write(buffer, 0, bytesRead);
bytesRead = responseData.read(buffer);
}
baos.close();
connection.close();
Am I doing this right? Is there anyway that I can dynamically set the number of bytes for the buffer based on the size of the request?
Thanks...