HTTPCLIENT-1009: content-type / content-encoding headers on cache response entities (test case)
Contributed by Joe Campbell <joseph.r.campbell at gmail.com> git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1006346 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
804359f1ab
commit
c1f9d2b336
|
@ -113,4 +113,23 @@ public class TestSizeLimitedResponseReader {
|
||||||
Assert.assertFalse(tooLarge);
|
Assert.assertFalse(tooLarge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testResponseCopiesAllOriginalHeaders() throws Exception {
|
||||||
|
byte[] buf = new byte[] { 1, 2, 3 };
|
||||||
|
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
|
||||||
|
response.setEntity(new ByteArrayEntity(buf));
|
||||||
|
response.setHeader("Content-Encoding", "gzip");
|
||||||
|
|
||||||
|
impl = new SizeLimitedResponseReader(new HeapResourceFactory(), MAX_SIZE, request, response);
|
||||||
|
|
||||||
|
impl.readResponse();
|
||||||
|
boolean tooLarge = impl.isLimitReached();
|
||||||
|
HttpResponse reconstructed = impl.getReconstructedResponse();
|
||||||
|
byte[] result = EntityUtils.toByteArray(reconstructed.getEntity());
|
||||||
|
|
||||||
|
Assert.assertFalse(tooLarge);
|
||||||
|
Assert.assertArrayEquals(buf, result);
|
||||||
|
Assert.assertEquals("gzip", reconstructed.getFirstHeader("Content-Encoding").getValue());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue