<div dir="ltr"><div>Hi,</div><div>I have an issue using http client communicating with servers that most probably are on GCP (I see header: "via: 1.1 google").</div><div><br></div><div>I get "java.io.IOException: Received RST_STREAM: Protocol error".</div><div>I quick search revealed that there were two bugs reported in JDK for that, with the most recent (<a href="https://bugs.openjdk.java.net/browse/JDK-8218546">https://bugs.openjdk.java.net/browse/JDK-8218546</a>) should have fixed the issue in JDK 12.</div><div><br></div><div>But I'm on JDK 16 (build 16+35-2229) and I get this error when connecting to a website when I use the header "TE: Trailers"  (needs first letter capitalized).</div><div><br></div><div>When I remove this header everything works, if I switch to HTTP 1.1 (with that header) it also works.<br></div><div><br></div><div>Here is a minimal reproducible example:</div><div><br></div><div>HttpClient.newBuilder()</div><div>  .build()</div><div>  .send(</div><div>    HttpRequest.newBuilder()</div><div>    .header("TE", "Trailers")</div><div>    .uri(URI.create("<a href="https://pacjent.erejestracja.ezdrowie.gov.pl">https://pacjent.erejestracja.ezdrowie.gov.pl</a>"))</div><div>    .GET()</div><div>    .build(),</div><div>    HttpResponse.BodyHandlers.ofString()</div><div>  );</div><div><br></div><div>I got that header from the browser (I tried to use the same request in Java as Firefox does) and was surprised that it works in browser (Firefox 90) as well as in curl (7.74.0) but fails in Java.</div><div><br></div><div>Not sure if that is a quirk of Google servers or java bug, so I'm reporting here.<br></div><div><br></div><div><br></div><div>Below is full stacktrace:</div><div><br></div><div> java.io.IOException: Received RST_STREAM: Protocol error<br>      at jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:568) ~[java.net.http:?]<br>      at jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119) ~[java.net.http:?]<br>  at com.kirela.szczepimy.Main.webSearch(Main.java:525) ~[classes/:?]<br>   at com.kirela.szczepimy.Main.main(Main.java:423) [classes/:?]<br>Caused by: java.io.IOException: Received RST_STREAM: Protocol error<br>    at jdk.internal.net.http.Stream.handleReset(Stream.java:537) ~[java.net.http:?]<br>       at jdk.internal.net.http.Stream.schedule(Stream.java:184) ~[java.net.http:?]<br>  at jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175) ~[java.net.http:?]<br>  at jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271) ~[java.net.http:?]<br>    at jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224) ~[java.net.http:?]<br>    at jdk.internal.net.http.Stream.receiveResetFrame(Stream.java:345) ~[java.net.http:?]<br> at jdk.internal.net.http.Stream.incoming_reset(Stream.java:515) ~[java.net.http:?]<br>    at jdk.internal.net.http.Stream.otherFrame(Stream.java:455) ~[java.net.http:?]<br>        at jdk.internal.net.http.Stream.incoming(Stream.java:448) ~[java.net.http:?]<br>  at jdk.internal.net.http.Http2Connection.processFrame(Http2Connection.java:810) ~[java.net.http:?]<br>    at jdk.internal.net.http.frame.FramesDecoder.decode(FramesDecoder.java:155) ~[java.net.http:?]<br>        at jdk.internal.net.http.Http2Connection$FramesController.processReceivedData(Http2Connection.java:232) ~[java.net.http:?]<br>    at jdk.internal.net.http.Http2Connection.asyncReceive(Http2Connection.java:672) ~[java.net.http:?]<br>    at jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.processQueue(Http2Connection.java:1305) ~[java.net.http:?]<br>       at jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175) ~[java.net.http:?]<br>  at jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271) ~[java.net.http:?]<br>    at jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224) ~[java.net.http:?]<br>    at jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.runOrSchedule(Http2Connection.java:1323) ~[java.net.http:?]<br>      at jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.onNext(Http2Connection.java:1349) ~[java.net.http:?]<br>     at jdk.internal.net.http.Http2Connection$Http2TubeSubscriber.onNext(Http2Connection.java:1283) ~[java.net.http:?]<br>     at jdk.internal.net.http.common.SSLTube$DelegateWrapper.onNext(SSLTube.java:210) ~[java.net.http:?]<br>   at jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:492) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onNext(SSLTube.java:295) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:316) ~[java.net.http:?]<br>        at jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:259) ~[java.net.http:?]<br> at jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175) ~[java.net.http:?]<br>  at jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271) ~[java.net.http:?]<br>    at jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224) ~[java.net.http:?]<br>    at jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:232) ~[java.net.http:?]<br>     at jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:198) ~[java.net.http:?]<br>     at jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:444) ~[java.net.http:?]<br>       at jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:268) ~[java.net.http:?]<br>        at jdk.internal.net.http.common.SequentialScheduler$SynchronizedRestartableTask.run(SequentialScheduler.java:175) ~[java.net.http:?]<br>  at jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147) ~[java.net.http:?]<br>      at jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198) ~[java.net.http:?]<br>      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]<br>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]<br>     at java.lang.Thread.run(Thread.java:831) ~[?:?]</div><div><br></div><div><br></div><div>Regards,<br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Krzysztof Krason</div></div></div>