RFR: 8347167: Implementation in com.sun.net.httpserver.Headers.normalize() can be improved [v2]

Michael McMahon michaelm at openjdk.org
Tue Nov 18 14:46:39 UTC 2025


On Mon, 17 Nov 2025 16:06:55 GMT, Josiah Noel <duke at openjdk.org> wrote:

>> Following the direction outlined in the net-dev discussion, I've updated the `com.sun.net.httpserver.Headers.normalize()` method to no longer allocate a superfluous char array when the header is already normalized.
>
> Josiah Noel has updated the pull request incrementally with one additional commit since the last revision:
> 
>   patch

src/jdk.httpserver/share/classes/com/sun/net/httpserver/Headers.java line 157:

> 155:                 throw new IllegalArgumentException("illegal character in key at index " + i);
> 156:             }
> 157:             cs[0] = (char) (c - o);

There's an assumption here that because of the test at line 135 then `c` must be a lower case letter. But, it could in principle be any `tchar` (token character) which includes digits and vchars other than lower case letters. We should check `if (c >= 'a' && c <= 'z')`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27276#discussion_r2538466371


More information about the net-dev mailing list