hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Campbell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-1009) http client cache: SizeLimitedResponseReader is not setting content type for InputStreamEntity in constructResponse()
Date Sat, 09 Oct 2010 16:07:31 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12919505#action_12919505
] 

Joe Campbell commented on HTTPCLIENT-1009:
------------------------------------------

The following test that I am adding to TestSizeLimitedResponseReader confirms that if the
header is on the original response from the server it is moved onto the response:

    @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());
    }

If the response does not contain the headers for Content-Encoding and Content-Type in the
first place - it really should not be the responsibility of the client side cache to add them
or attempt to determine what they should be and place them onto the response.  I don't believe
that this is an issue of the cache.

> http client cache: SizeLimitedResponseReader is not setting content type for InputStreamEntity
in constructResponse()
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1009
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1009
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Cache
>    Affects Versions: 4.1 Alpha2
>            Reporter: Felix Berger
>
> the newly created InputStreamEntity should be populated with content-encoding and content-type.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message