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



##########
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 think we'd better use greaterThan here? If we do not enable gzip, the 
content length will be the same, so the the asserttion here just does nothing...




-- 
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:
[email protected]


Reply via email to