RFR: 8355572: Support HTTP Range requests in Simple Web Server [v6]
Peyang
duke at openjdk.org
Fri Oct 31 15:17:53 UTC 2025
On Fri, 31 Oct 2025 15:08:50 GMT, Michael McMahon <michaelm at openjdk.org> wrote:
>> Good point. But we have already sent the status code. I guess we should throw IOException in this case, so that the ServerImpl closes the connection, ensuring that the client notices that the response was not entirely fulfilled?
>
> I'll have to check the RFC but it might be allowable to return a shorter range than was requested, but the actual range to be returned would have to have been specified in the `Content-Range` header. You would have to check the length of the file first. So, EOF wouldn't occur except in very unusual circumstances. Otherwise, yes throwing IOE would close the connection signaling the error.
The `ranges` list in the arguments is constructed so that each range's end option does not exceed the file size: if a requested range goes beyond the file lengh, it is clamped accordingly.
There fore, I don't thiunk any foundamental change is needed here.
We could add an `assert` (and a comment) to make this assumption explict, or possibly throw an IOE in case the file was truncated or modified during editing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28021#discussion_r2481765572
More information about the net-dev
mailing list