You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2018/01/11 13:18:16 UTC

httpcomponents-client git commit: HTTPCLIENT-1895: added test case for multi-member GZIP content streams (per RFC 1952)

Repository: httpcomponents-client
Updated Branches:
  refs/heads/4.5.x 1780ab2bf -> e7825a6f1


HTTPCLIENT-1895: added test case for multi-member GZIP content streams (per RFC 1952)


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/e7825a6f
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/e7825a6f
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/e7825a6f

Branch: refs/heads/4.5.x
Commit: e7825a6f13bfcc08fecf353a028173853d0e58f2
Parents: 1780ab2
Author: Sudheera Palihakkara <ca...@gmail.com>
Authored: Thu Jan 11 14:13:05 2018 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Thu Jan 11 14:14:48 2018 +0100

----------------------------------------------------------------------
 .../org/apache/http/client/entity/TestGZip.java | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e7825a6f/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
index f7008b8..2f9ba9a 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
@@ -27,6 +27,7 @@
 
 package org.apache.http.client.entity;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -35,6 +36,7 @@ import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.entity.ByteArrayEntity;
 import org.apache.http.entity.ContentType;
+import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
@@ -79,4 +81,23 @@ public class TestGZip {
         }
     }
 
+    @Test
+    public void testDecompressionWithMultipleGZipStream() throws IOException {
+        final int[] data = new int[] {
+                0x1f, 0x8b, 0x08, 0x08, 0x03, 0xf1, 0x55, 0x5a, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x31, 0x00,
+                0x2b, 0x2e, 0x29, 0x4a, 0x4d, 0xcc, 0xd5, 0x35, 0xe4, 0x02, 0x00, 0x03, 0x61, 0xf0, 0x5f, 0x09,
+                0x00, 0x00, 0x00, 0x1f, 0x8b, 0x08, 0x08, 0x08, 0xf1, 0x55, 0x5a, 0x00, 0x03, 0x74, 0x65, 0x73,
+                0x74, 0x32, 0x00, 0x2b, 0x2e, 0x29, 0x4a, 0x4d, 0xcc, 0xd5, 0x35, 0xe2, 0x02, 0x00, 0xc0, 0x32,
+                0xdd, 0x74, 0x09, 0x00, 0x00, 0x00
+        };
+        final byte[] bytes = new byte[data.length];
+        for (int i = 0; i < data.length; i++) {
+            bytes[i] = (byte) (data[i] & 0xff);
+        }
+
+        final InputStreamEntity out = new InputStreamEntity(new ByteArrayInputStream(bytes));
+        final GzipDecompressingEntity gunZipEntity = new GzipDecompressingEntity(out);
+        Assert.assertEquals("stream-1\nstream-2\n", EntityUtils.toString(gunZipEntity, Consts.ASCII));
+    }
+
 }