spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.5k stars 3.31k forks source link

[Gateway MVC] ERR_HTTP2_PROTOCOL_ERROR if HTTP/2 enabled #3326

Open benba opened 5 months ago

benba commented 5 months ago

if server.http2.enabled is set to true, using JDK HttpClient, and if the downstream server also exchange in HTTP/2, a HTTP/2 protocol error will be raised (ERR_HTTP2_PROTOCOL_ERROR in Chrome for example).

curl gives more details about the issue: PROTOCOL_ERROR Invalid HTTP header filed was received: frame type: 1, stream: 1, name: [:status], value: [200]

An easy workardound is to add a HttpHeadersFilter.ResponseHttpHeadersFilter that removes the :status pseudo-header.

I can submit a PR if you feel that it's an appropriate fix

spencergibb commented 5 months ago

PRs welcome

ebarliba commented 4 months ago

For anyone stumbling upon this and looking for a workaround, I replaced the JDK HttpClient by adding Apache httpclient (org.apache.httpcomponents.client5:httpclient5) dependency and adding spring.cloud.gateway.mvc.http-client.type: autodetect.