Hamado Dene
05/30/2023, 8:13 PMHttpClient client =
HttpClient.create()
.protocol(HTTP1.1, H2C, H2 );
We are having several problems in our tests when configuring the HTTP1.1 protocol together with another HTTP2 protocol.
Basically when HTTP1.1 is configured together with H2C or H2, reactor netty at the first request sends a request of type Connection: upgrade to understand what type of protocol the server supports in order to use the right protocol for the request.
However, we noticed that wiremock does not handle Connection: Upgrade requests.
wireMockRule.stubFor(
post(urlEqualTo("/index.html")).
withRequestBody(equalTo("Wikipedia in\r\n"
+ "\r\n"
+ "chunks."))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/html")
.withBody("it <b>works</b> !!"))
);
By placing a subFor of this type, we see that when the Connection: upgrade request arrives, it sees that the body is empty, so it breaks and closes the connection without actually managing the connection upgrade.
We tried to introduce a subFor that manages the case in which a connection: upgrade arrives but the problem is that after having managed, wiremock closes the connection and therefore reactor netty is unable to continue the request.
In particular we did something like:
wireMockRule.stubFor(
post(urlEqualTo("/index.html"))
.withHeader(String.valueOf(HttpHeaderNames.CONNECTION), containing("upgrade") )
.willReturn(aResponse()
.withStatus(200)
.withHeader(String.valueOf(HttpHeaderNames.CONNECTION), "upgrade")
.withHeader(String.valueOf(HttpHeaderNames.UPGRADE), "HTTP/2.0")
));
wireMockRule.stubFor(
post(urlEqualTo("/index.html")).
withRequestBody(equalTo("Wikipedia in\r\n"
+ "\r\n"
+ "chunks."))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "text/html")
.withBody("it <b>works</b> !!"))
);
The problem, however, is that by matching the first subFor, it still immediately closes the connection. So reactor netty is not able to go and send data.
If configured together H2C and H2 the problem does not arise as Connection:upgrade over http2 is not supported.
If configured HTTP1.1 alone the problem does not arise.
Do you have a solution to handle this issue?Tom
05/31/2023, 8:48 AM