Payara
Payara copied to clipboard
Bug Report: HTTP2 must be switched on to use GZIP compression
Description
When GZIP compression is enabled, HTTP2 must be enabled, too, if TLS is disabled. Otherwise some clients, including the Java SE 11 HTTP Client, will fail to parse the response as these clients explicitly request HTTP2. The same works if TLS is enabled.
Expected Outcome
Whether or not TLS is enabled, and whether or not a client explicitly requests HTTP2, the response should be correctly parsable.
Current Outcome
TLS enabled: Response is correctly gzipped, clients can correctly parse the response.
TLS disabled: Response is incorrectly gzipped, clients fail either parsing the headers or parsing the entity.
Steps to reproduce
Disable TLS and HTTP2 in Payara. Enable Compression in Payara. Execute HTTP GET request using Java SE 11 HttpClient with header "Accept-Encoding: gzip" (the HttpClient always requests HTTP2) Try to unzip the result (will throw exception that this is not a GZIP stream).
Environment
- Distribution: Server Full Profile 5.2022.1
- JDK Version: 11 - Azul
- Operating System: Windows
Hi @mkarg,
I am unable to verify it. Would you be able to share the reproducer? With both TLS and HTTP2 in Payara disabled and compression enabled. I tried testing it with a simple JAX-RS Get endpoint and below Code.
public static void httpGetRequest() throws URISyntaxException, IOException, InterruptedException {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.version(HttpClient.Version.HTTP_2)
.uri(URI.create("http://localhost:8080/hello/helloworld"))
.headers("Accept-Enconding", "gzip, deflate")
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
String responseBody = response.body();
int responseStatusCode = response.statusCode();
System.out.println("httpGetRequest: " + responseBody);
System.out.println("httpGetRequest status code: " + responseStatusCode);
}
I will try to strip down our application as far as possible, but it will need a while. Stay tuned.
Closing due to inactivity.