RFR: 8252304: Seed an HttpRequest.Builder from an existing HttpRequest [v8]

Daniel Fuchs dfuchs at openjdk.java.net
Tue Nov 17 18:32:05 UTC 2020


On Tue, 17 Nov 2020 17:28:45 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> src/java.net.http/share/classes/java/net/http/HttpRequest.java line 335:
>> 
>>> 333:      *  <li> Remove a particular header (e.g. Foo-Bar):
>>> 334:      *  <pre>{@code HttpRequest.newBuilder(request, (name, value) -> name.equalsIgnoreCase("Foo-Bar"))}</pre>
>>> 335:      * </ul>
>> 
>> Does the example above not result in "Foo-Bar" being the only header being copied across? So, maybe it should say "Retain a particular header"
>
> Ah! Good catch - I believe the code is buggy. It should have been `!name.equalsIgnoreCase(...)`.

Patrick - can you add a test case with exactly **that** use case? I know you have similar tests which remove `"testName1"`, but it would be good to have a test that verifies that **the exact code** shown in the `@apiNote` works as expected. Your tests should have caught that mistake.

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

PR: https://git.openjdk.java.net/jdk/pull/1059


More information about the net-dev mailing list