From 2451e5dec74b9b49f9e5ffc8da049b2dd46c6d02 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Date: Fri, 1 Jun 2012 14:53:17 +0000 Subject: [PATCH] HTTPCLIENT-1199: Added unit test to verify Oleg's recent fix. We still do not properly handle the redirect case, however. git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1345217 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/impl/client/TestDecompressingHttpClient.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java index 490b7da87..efb83348a 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java @@ -36,6 +36,7 @@ import java.util.zip.GZIPOutputStream; import org.apache.http.Header; import org.apache.http.HeaderElement; import org.apache.http.HttpEntity; +import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; @@ -44,6 +45,7 @@ import org.apache.http.HttpVersion; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.entity.ByteArrayEntity; @@ -334,6 +336,15 @@ public class TestDecompressingHttpClient { assertNotNull(result.getFirstHeader("Content-MD5")); } + @Test + public void passesThroughTheBodyOfAPOST() throws Exception { + when(mockHandler.handleResponse(isA(HttpResponse.class))).thenReturn(new Object()); + HttpPost post = new HttpPost("http://localhost:8080/"); + post.setEntity(new ByteArrayEntity("hello".getBytes())); + impl.execute(host, post, mockHandler, ctx); + assertNotNull(((HttpEntityEnclosingRequest)backend.getCapturedRequest()).getEntity()); + } + private HttpResponse getGzippedResponse(final String plainText) throws IOException { HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");