line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.8k stars 912 forks source link

Always use HTTP/2 preface for H2C #5706

Closed ikhoon closed 4 months ago

ikhoon commented 4 months ago

Motivation:

There are two modes to negotiate cleartext HTTP/2 connections. They are HTTP/2 connection preface and HTTP/1 upgrade requests. The default behavior is determined by ClientFactoryOptions.useHttp2Preface(). This option affects' http' and h2c, so even if a user uses h2c with prior knowledge, an upgrade request will be sent if useHttp2Preface() == false.

With prior knowledge, it is an unwanted behavior for useHttp2Preface() option to affect h2c scheme. h2c is an explicit scheme whose negotiation should be fixed to the HTTP/2 connection preface. Its endpoint may not understand the HTTP/1 upgrade.

So it would make more sense to apply to useHttp2Preface() option to adjust the default behavior of http. If both http and h2c follow useHttp2Preface(), there is no difference in behavior between them.

Modifications:

Result:

Armeria client always uses HTTP/2 connection preface for h2c, regardless of the value of useHttp2Preface().

github-actions[bot] commented 4 months ago

🔍 Build Scan® (commit: 5b58ffc9801ef126ed8443efc459630b6a1cc9e8)

Job name Status Build Scan®
build-windows-latest-jdk-21 https://ge.armeria.dev/s/j3gikcrioleju
build-self-hosted-unsafe-jdk-8 https://ge.armeria.dev/s/usav7bpli365k
build-self-hosted-unsafe-jdk-21-snapshot-blockhound https://ge.armeria.dev/s/se6bkbt67sz5k
build-self-hosted-unsafe-jdk-17-min-java-17-coverage https://ge.armeria.dev/s/ejljkwjlqh5rq
build-self-hosted-unsafe-jdk-17-min-java-11 https://ge.armeria.dev/s/utsg2vd5agfxo
build-self-hosted-unsafe-jdk-17-leak https://ge.armeria.dev/s/uo7pojfp446je
build-self-hosted-unsafe-jdk-11 https://ge.armeria.dev/s/4ey3cyvciubhm
build-macos-12-jdk-21 https://ge.armeria.dev/s/vrxwblc4tghkc
minwoox commented 4 months ago

@ikhoon 👍 👍 👍