Proposal: 8355572: Implement Range header support for jwebserver
Daniel Fuchs
daniel.fuchs at oracle.com
Thu Oct 23 15:11:58 UTC 2025
Hi,
I would support investigating adding support for Range header in
the FileServerHandler.
In the HttpClient, we have recently added a new
BodyPublishers.ofFileChannel() request publisher as a
potential building block to ease implementation of
partial/resumable file uploads in applications.
We have nothing out of the box for resumable file downloads
in the HttpClient API though.
It would be good if you could use the HttpClient API
in the unit tests you will develop. Maybe we could use
that as an opportunity to learn whether some more building
blocks of general utility could be added on the client
side (in the future) to ease the implementation of applications
that would have a need for Range headers, such as to implement
a download manager for instance.
best regards,
-- daniel
On 23/10/2025 15:49, Daisuke Yamazaki wrote:
> Thank you for the clarification and context.
>
> I understand that there is a legitimate need for Range header support.
> However, whether such a feature is necessary for the simple jwebserver is
> still open for discussion.
>
> Nevertheless, while the benefits are clear, I do not see any significant
> drawbacks apart from potential maintainability or slight code growth.
> I personally think it would be reasonable to implement this feature.
>
> I plan to wait for a bit to allow further discussion, and if no objections
> arise, I intend to proceed with the implementation.
>
> ---- On Thu, 23 Oct 2025 02:56:29 +0900 Ethan McCue <ethan at mccue.dev> wrote ---
>
> > Adding for context that there are legitimate usages for this that are within the jdk httpserver's remit of jwebserver and educational purposes. Cheerpj would let a student run their java code in a browser and requires range headers support.
> >
> > On Wed, Oct 22, 2025, 7:23 AM Daisuke Yamazaki <d.yamazaki at peya.tokyo> wrote:
> >
> > Hello all,
> >
> > I would like to work on implementing Range header support for jwebserver,
> > related to JDK-8355572.
> > Before I start working on it, i'd like to confirm whether it's okay for me to
> > take this issue.
> >
> > Here's my current design idea:
> >
> > 1. Introduce a RangeEntry record inside FileServerHandler to represent
> > each requested range
> > 2. In FileServerHandler.serveFile(), detect the Range header and parse it into
> > a list of RangeEntry objects.
> > If parsing fails or the range is invalid, return 416 Range Not Satisfiable.
> > 3. If multiple ranges are specified, generate a random boundary
> > string and return a multipart/byteranges response.
> >
> > Please let me know if it’s okay for me to proceed with this implementation,
> > or if there are any design points I should consider before starting.
> >
> > Thanks,
> > D. Yamazak
> >
>
More information about the net-dev
mailing list