hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Forcing a chunk boundary
Date Wed, 02 Feb 2011 17:40:14 GMT
On Wed, 2011-02-02 at 12:16 -0500, John Kiffmeyer wrote:
> Hi all,
> I'm working with an application that requires requests to be chunked a 
> certain way.  More or less, the body contains an application request and 
> some data associated with it.  If chunked normally, the first chunk 
> contains the application request and the beginning of the data.  If the 
> first chunk is this large, however, the server refuses to parse the 
> application request.  I want to force a chunk boundary at the end of the 
> application request/beginning of the data.
> I (understandably) don't see a way to do this in the api.  Is it feasible 
> to accomplish this by subclassing some stuff?  I've traced through 
> httpclient and httpcore code but it's not obvious to me yet what I need to 
> extend/override (EntitySerializer looks promising, but I'm not clear on 
> where I need to shoehorn a subclass of that into the path after 
> HttpClient.execute()).  So, I'm looking for some wisdom.
> Thanks!
> jk


While it is not going to be pretty it is certainly doable.  

Assuming you intend to use blocking I/O model

(1) Create a custom version of the ChunkedOutputStream. Most likely will
need to copy the entire class and tweak it quite a bit to make it work
the way you want

(2) Subclass EntitySerializer and make it use your custom
ChunkedOutputStream when serializing chunked entities or a specific type
of entities.

(2) If you intend to use HttpCore only, subclass
DefaultHttpClientConnection and make it use your custom
EntitySerializer. If you would like to use HttpClient with all bells and
whistles, follow these instructions of the HttpClient tutorial:


Hope this helps


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

View raw message