You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Jon Brisbin <jo...@jbrisbin.com> on 2011/08/03 17:16:54 UTC

HttpAsyncPut constructor issue

I'm building a proof of concept application that uses the async HTTP client and I've hit a snag w.r.t. the API. I'm streaming content using PUT and I don't have any content to pass to the constructor. Is it safe to pass null here? I need to send content in chunks because it's impossible to do it by loading the (possibly huge) files into a byte[] in memory. 

How do I do streaming with a PUT using the async HTTP client? 


Thanks! 

Jon Brisbin 
http//jbrisbin.com 



Re: HttpAsyncPut constructor issue

Posted by Jon Brisbin <jo...@jbrisbin.com>.
----- Original Message -----

> From: "Oleg Kalnichevski" <ol...@apache.org>
> To: "HttpComponents Project" <de...@hc.apache.org>
> Sent: Wednesday, August 3, 2011 10:40:54 AM
> Subject: Re: HttpAsyncPut constructor issue

> On Wed, 2011-08-03 at 10:16 -0500, Jon Brisbin wrote:
> > I'm building a proof of concept application that uses the async
> > HTTP client and I've hit a snag w.r.t. the API. I'm streaming
> > content using PUT and I don't have any content to pass to the
> > constructor. Is it safe to pass null here?

> No, it is not. Why would you want to issue a PUT request without any
> content in the first place?

Because I'm writing a non-blocking application that uses a PUT REST API call. I start a PUT request when I have the first bit of data I need then I send the rest of the content as I get it. 

> > I need to send content in chunks because it's impossible to do it
> > by loading the (possibly huge) files into a byte[] in memory.
> >
> > How do I do streaming with a PUT using the async HTTP client?
> >

> You can either use the ZeroCopyPut request producer if the request
> content is stored in a file or builds a custom implementation of
> HttpAsyncRequestProducer that generates bits of content dynamically
> and
> writes them out using the #produceContent method.
Looks like I'll need to create a custom ZeroCopyPut that doesn't use a File. 

Thanks for the help. 

jb 

> Hope this helps

> Oleg

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

Re: HttpAsyncPut constructor issue

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2011-08-03 at 10:16 -0500, Jon Brisbin wrote:
> I'm building a proof of concept application that uses the async HTTP client and I've hit a snag w.r.t. the API. I'm streaming content using PUT and I don't have any content to pass to the constructor. Is it safe to pass null here?

No, it is not. Why would you want to issue a PUT request without any
content in the first place?

>  I need to send content in chunks because it's impossible to do it by loading the (possibly huge) files into a byte[] in memory. 
> 
> How do I do streaming with a PUT using the async HTTP client? 
> 

You can either use the ZeroCopyPut request producer if the request
content is stored in a file or builds a custom implementation of
HttpAsyncRequestProducer that generates bits of content dynamically and
writes them out using the #produceContent method.

Hope this helps

Oleg



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