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

Jaikiran Pai jpai at openjdk.org
Tue Jun 17 13:53:15 UTC 2025


On Tue, 17 Jun 2025 13:28:07 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
>
> src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java line 624:
> 
>> 622:                 host += ":" + String.valueOf(port);
>> 623:             }
>> 624:             if (requests.findValue("Host") == null) {
> 
> Should we use `setIfNotSet` here like for "Accept" below?

That seems reasonable. I had a look at the implementation in `setIfNotSet()` and it matches this current semantic. So I've updated the PR to use `setIfNotSet()`.

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

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


More information about the net-dev mailing list