RFR: 8272758: Improve HttpServer to avoid partial file name matches while mapping request path to context path [v2]
Volkan Yazici
vyazici at openjdk.org
Mon Feb 2 20:21:42 UTC 2026
On Thu, 29 Jan 2026 15:17:49 GMT, Michael McMahon <michaelm at openjdk.org> wrote:
>> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add property to switch between prefix matching schemes
>
> src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpServer.java line 287:
>
>> 285: * this context path matches request paths {@code /foo},
>> 286: * {@code /foo/bar}, or {@code /foobar}. Others may use <em>path prefix
>> 287: * matching</em> where {@code /foo} matches only request paths
>
> Suggestion:
>
> * matching</em> where {@code /foo} matches request paths
Fixed in e55e6050466.
> src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java line 201:
>
>> 199: }
>> 200:
>> 201: // Is it a path-prefix match?
>
> Suggestion:
>
> // Is it a path-prefix match? Either the context ends with '/'
> // or the request contains a '/' implying that it does
>
> or words to the same effect. The behavior is quite subtle.
This is indeed far from being _obvious_. I've documented both cases extensively in e55e6050466.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29264#discussion_r2756003419
PR Review Comment: https://git.openjdk.org/jdk/pull/29264#discussion_r2756005907
More information about the net-dev
mailing list