Bug #25
HTTPRequest does not stream
| Status: | Assigned | Start date: | 03/27/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | Richard Körber | % Done: | 0% |
|
| Category: | net | |||
| Target version: | R18 |
Description
Even though the API is designed to stream a file content, HTTPRequest actually does not stream but buffers the entire file contents.
History
Updated by Richard Körber almost 3 years ago
- Status changed from New to Assigned
- Target version set to R16
HttpURLConnection.setFixedLengthStreamingMode() should be used to switch to streaming mode. The difficult part is that the total file size must be known and evaluated while the header is generated. This requires a change in the DataProvider interface.
If the total file size cannot be evaluated, HttpURLConnection.setChunkedStreamingMode() should be used instead. Chunked streaming is not supported by all servers, though, so there should also be a method to turn off streaming entirely.
The methods expect an int for the size, so there should be a proper range checking before the total size long is casted to an int. If the range is exceeded, an exception should be thrown, since it makes no sense to buffer a content stream in heap that is larger than 2GB. Starting from JDK7, there will also be a method that accepts long (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6755625), so this method should be used instead if available.
Updated by Richard Körber almost 2 years ago
- Target version changed from R16 to R18