From a87b569d0140e77650e95c47a3a9dd5e091deaf0 Mon Sep 17 00:00:00 2001 From: Kristopher Wuollett Date: Fri, 12 Jul 2013 00:06:21 -0700 Subject: [PATCH] Added check for length < 0 for transparent gzip response. The documentation for org.apache.http.HttpEntity::getContentLength() states that a negative number will be returned when the length of the content is not known. --- .../java/com/squareup/okhttp/apache/OkApacheClientTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java b/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java index 22543c34f..d156fcbec 100644 --- a/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java +++ b/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java @@ -236,8 +236,7 @@ public class OkApacheClientTest { // content length should also be absent Header[] headers1b = response1.getHeaders("Content-Length"); assertEquals(0, headers1b.length); - // The following currently fails because ContentLength(-1) is returned from the entity - // assertNull(response1.getEntity().getContentLength()); + assertTrue(response1.getEntity().getContentLength() < 0); Header[] headers1c = response1.getHeaders("Content-Type"); assertEquals(1, headers1c.length); assertEquals("application/json", headers1c[0].getValue());