You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/04/14 16:04:02 UTC

[GitHub] [hbase] ndimiduk commented on a change in pull request #3159: HBASE-25770 Http InfoServers should honor gzip encoding when requested

ndimiduk commented on a change in pull request #3159:
URL: https://github.com/apache/hbase/pull/3159#discussion_r613380494



##########
File path: hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpServer.java
##########
@@ -269,6 +277,35 @@ public void testContentTypes() throws Exception {
     // assertEquals("text/html; charset=utf-8", conn.getContentType());
   }
 
+  @Test
+  public void testNegotiatesEncodingGzip() throws IOException {
+    try (final CloseableHttpClient client = HttpClients.createMinimal()) {
+      final HttpGet request = new HttpGet(new URL(baseUrl, "/static/test.css").toString());
+
+      request.setHeader(HttpHeaders.ACCEPT_ENCODING, null);
+      final long unencodedContentLength;
+      try (final CloseableHttpResponse response = client.execute(request)) {
+        final HttpEntity entity = response.getEntity();
+        assertNotNull(entity);
+        assertNull(entity.getContentEncoding());
+        unencodedContentLength = entity.getContentLength();
+        MatcherAssert.assertThat(unencodedContentLength, greaterThan(0L));
+      }
+
+      request.setHeader(HttpHeaders.ACCEPT_ENCODING, "gzip");
+      final long encodedContentLength;
+      try (final CloseableHttpResponse response = client.execute(request)) {
+        final HttpEntity entity = response.getEntity();
+        assertNotNull(entity);
+        assertNotNull(entity.getContentEncoding());
+        assertEquals("gzip", entity.getContentEncoding().getValue());
+        encodedContentLength = entity.getContentLength();
+        MatcherAssert.assertThat(encodedContentLength, greaterThan(0L));
+      }
+      MatcherAssert.assertThat(unencodedContentLength, greaterThanOrEqualTo(encodedContentLength));

Review comment:
       I could do, sure. The goal is to test that the server honors the encoding request, not the efficiency of gzip for this specific content.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org