We are experiencing incorrect behavior from HttpURLConnection when requesting byte ranges of a document.
The Java client requests documents from the HTTP server via a HttpURLConnection object. The client sends a GET method request message, requesting a specific byte range of the document -- not the entire document. Although the response message contains a correct Content-Length header field, the entire document is present on the stream, not just the requested byte range.
- Sent to server via GET method
- Uses URLConnection.setRequestProperty(String key, String value) to set byte range.
- Sets URLConnection.setUseCaches(false);
- The response code is 206, correctly indicating "Partial Content". Correct.
- The "Content-Length" header field value is correct. Correct.
- The connection output stream contains the entire document (not just the byte range requested). INCORRECT.
The behavior described therein is closest to what we're experiencing, but still different. The difference is that we always get a document back from the server, and the document headers are correct. But the stream contains the entire document instead of just the bytes representing the requested byte range.
I don't believe our HTTP server is the problem. If I open a telnet connection and manually construct the HTTP request, then the returned document is correct, containing only the requested byte range.
We're running JDK 1.6 on both client and server.