I kept the original answer for completeness, but I just looked at the HTTP RFC (2616) section 4.3:
Content-Length Transfer-Encoding . , ( 5.1.1) . ; -, .
, , Transfer-Encoding ( , 400 , 411 ( " " )), , Transfer-Encoding:)
, API ( HTTP API), - , , API (.. ).
, .
, , ( ).
(, ByteArrayOutputStream , , ), InputStream.read
-1. :
byte[] buffer = new byte[8192];
ByteArrayOutputStream output = new ByteArrayOutputStream();
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1)
{
output.write(buffer, 0, bytesRead);
}
EDIT: , . API HTTP , , .
, (, , , ) - , , , TCP . - , .
" ", ...