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

Jonathan Moore commented on HTTPCLIENT-427:
-------------------------------------------

@Sam:

The byte[] is indeed the cached response body, and I would agree with Seb that 
as-is, it's not threadsafe because someone can muck with the bytearray. I think 
clone() on the byte array solves this, but at the expense of extra copies of 
the data. The Right Way is probably going down the road that Oleg suggests, 
which is to use something like HttpEntity instead which can be treated as 
immutable.

With regard to the potential size of the response, the CachingHttpClient lets 
you specify a max object size (with a heuristic default behavior that I'd have 
to recheck in the code); if the CachingHttpClient encounters a response that 
exceeds this, it won't try to cache it and will just stream the result through 
(it will optimistically consume some of the input stream, in case there is a 
chunked-encoding response that will fit, but if this process exceeds the max 
length then it will return a response with a "composite" input stream that 
returns the byte array read so far, then "appends" the rest of the unconsumed 
origin response stream.


> Implement a cache to perform real request only when needed
> ----------------------------------------------------------
>
>                 Key: HTTPCLIENT-427
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-427
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpClient
>         Environment: Operating System: Linux
> Platform: PC
>            Reporter: Marc Guillemot
>             Fix For: 4.1 Alpha2
>
>         Attachments: caching_client.zip, 
> HTTPCLIENT-427-Immutable-CacheEntry2.patch, 
> HTTPCLIENT-427-immutable-cachenentry.patch, httpclient-cache.zip
>
>
> Browsers may cache received content according to the values of different
> response headers. It would be great if HttpClient could do the same.

-- 
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to