Does anyone have context on jdk.httpserver?

Alan Bateman Alan.Bateman at oracle.com
Mon Jan 22 07:18:24 UTC 2024


On 21/01/2024 20:18, Ethan McCue wrote:
> Hi all,
>
> Elliot[1] and I have been digging into the HTTP(S) server 
> implementation provided by the jdk.httpserver module.
>
> It hasn't taken long to notice that the provided implementation 
> is...lacking. Both in performance, as it places extremely low and 
> errors out on benchmarks [2][3], and in polish, as doing relatively 
> simple tasks like printing out the result of 
> HttpExchange#getRequestHeaders() does not actually include the headers 
> in the output.
>
> But, the actual API isn't wretched. The overall design (with a Filter 
> chain and a mutable "out" object for responses) is reminiscent of 
> Servlets and there is an SPI hook to provide custom server 
> implementations. And unlike the jwebserver tool, which is built on 
> this, there isn't a "for education purposes only" sign anywhere and it 
> is part of an exported and supposedly supported module.
>
> All that is to ask - does anyone on this mailing list have any 
> historical context on this? Why was it added to the JDK, what were the 
> goals of its implementation, are there any records of the decision 
> process behind its design?
>
> Separately is there any appetite for improving the performance of the 
> built-in server implementation?

The history on this is the web services client (meaning JAX-WS), added 
in Java 6. A HTTP server was required to support web services "callbacks".

As it turned out, having a basic HTTP server in the JDK is very useful 
for writing tests and very useful at reducing the "getting startup" 
effort to serve up a web page. The HTTP server was never meant to be 
feature rich with performance on par with other HTTP servers. However, 
it does have a service provider interface (SPI) so alternative 
implementations can be used (there are at least 3 full featured HTTP 
servers that implement the SPI).

More recently, JEP 408 [1] added a command line interface to make it 
easy to get started. It also added to the API to make it easy to create 
and customize. You've found that so you have some context on what the 
HTTP server is intended for now.

The net-dev mailing list is the mailing list to use.

-Alan

[1] https://openjdk.org/jeps/408




More information about the core-libs-dev mailing list