RFR: 8359709: java.net.HttpURLConnection sends unexpected "Host" request header in some cases after JDK-8344190 [v2]

Jaikiran Pai jpai at openjdk.org
Wed Jun 18 01:51:37 UTC 2025


On Tue, 17 Jun 2025 14:13:36 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Volkan's suggestion - use test specific context root for the handler
>>  - Daniel's suggestion - use setIfNotSet
>
> test/jdk/java/net/HttpURLConnection/HostHeaderTest.java line 60:
> 
>> 58: class HostHeaderTest {
>> 59: 
>> 60:     private static final String SERVER_CTX_ROOT = "/8359709";
> 
> Suggestion:
> 
>     private static final String SERVER_CTX_ROOT = "/8359709/";
> 
> 
> Preferably always terminate context roots with /
> 
> https://docs.oracle.com/en/java/javase/24/docs/api/jdk.httpserver/com/sun/net/httpserver/HttpServer.html#createContext(java.lang.String,com.sun.net.httpserver.HttpHandler)
>> API Note:
>>     The path should generally, but is not required to, end with '/'. If the path does not end with '/', eg such as with "/foo" then this would match requests with a path of "/foobar" or "/foo/bar".

Good point. I've now updated the PR with this change. Test continues to pass.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25844#discussion_r2153460024


More information about the net-dev mailing list