RFR: 8272758: Improve HttpServer to avoid partial file name matches while mapping request path to context path [v2]
Volkan Yazici
vyazici at openjdk.org
Wed Jan 21 12:47:40 UTC 2026
On Wed, 21 Jan 2026 12:21:42 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:
>> Currently `HttpServer` allows matching a request path `/foobar` to context path `/foo`. Replace this surprising behaviour with a safer approach by requiring exact *path prefix matches*.
>>
>>
>> | Request path
>> Context +------+-------+----------+---------
>> path | /foo | /foo/ | /foo/bar | /foobar
>> ---------+------+-------+----------+---------
>> / | Y | Y | Y | Y
>> /foo/ | N | Y | Y | N
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>
> Add property to switch between prefix matching schemes
@Michael-Mc-Mahon, @dfuch, in e80aabcb7ab, I've added the `sun.net.httpserver.pathMatcher` property to switch between path-prefix and string-prefix matching schemes. See the following screenshots showcasing relevant parts:
### Module Summary page
<img width="1121" height="384" alt="Module Summary page" src="https://github.com/user-attachments/assets/c81944e6-64e7-411b-8f1b-385872fb844d" />
### `HttpServer` page
<img width="1116" height="722" alt="HttpServer page" src="https://github.com/user-attachments/assets/14abc3a6-9fe4-43b8-9973-b9e47e7dcdfd" />
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29264#issuecomment-3777942776
More information about the net-dev
mailing list