hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yan aka. Yansheng" <yansheng....@gmail.com>
Subject Re: how to use PostMethod to stream request?
Date Tue, 23 Sep 2008 18:40:25 GMT
Hi Oleg,

See attached message for my use case.  Sorry if I misunderstood OP's use
case.  But the answer I got from you is that HTTPClient 3.x API was not
meant to be used that way...

As always, appreciate your help!



On Fri, 2008-06-27 at 10:43 -0700, Yan aka. Yansheng wrote:
> Hi There,
>
> This is my first post here so I hope this is the right audience.
>
> My story: I want to replace a chunk of my code for doing I/O streaming to
a
> webservice.  I use java.net.HttpURLConnection to get the InputStream and
> OutputStream, it works fine most of the time but it can get a bit flaky
and
> I had to write my own retry logic.  So I decided to switch to
> jakartacommons-httpclient to see if things get better.  The problem is I
> don't seem to be able to come up with a good replacement from the
httpclient
> package.
>
> Here is the method for obtaining a HttpConnection I wrote, the problem is
> the HostConfiguration returned is not populated.
>

´╗┐Yansheng

HttpClient 3.x API was never meant to be used this way. You should
either let HttpClient manage connections, or use connection management
components from HttpClient 4.0

Hope this helps

Oleg



On Thu, Sep 18, 2008 at 10:56 AM, Oleg Kalnichevski <olegk@apache.org>wrote:

> On Thu, 2008-09-18 at 08:16 -0700, Yan aka. Yansheng wrote:
> > The example you provided use the File as the buffer and then send as it
> over
> > the network a RequestEntity.  There is not direct IO writes to an http
> > connection in HttpClient.
>
> What you are saying is plain WRONG. RequestEntity#writeRequest() method
> gives you a direct access to the output stream of the underlying
> connection, which can be used to stream out any arbitrary content. The
> entity implementation given as an example does not use a file as a
> buffer. It streams out content of a file by reading from the file input
> stream and writing directly to the output stream of the HTTP
> connection.
>
> Please do not make statements about things you are not sure about.
>
> Oleg
>
>
> > On Wed, Sep 17, 2008 at 10:52 AM, Oleg Kalnichevski <olegk@apache.org
> >wrote:
> >
> > > On Wed, 2008-09-17 at 08:27 -0700, Yan aka. Yansheng wrote:
> > > > I had a similar problem.  From what I gathered, HttpClient does not
> > > support
> > > > stream IO directly.  It's not meant for streaming IO.
> > >
> > > This is most certainly is _NOT_ the case. HttpClient is fully capable
> of
> > > streaming data in and out since version 2.0.
> > >
> > > Oleg
> > >
> > > >   So one solution is to
> > > > buffer your output locally and send in batch at the end.
> > > >
> > > > Hope this helps.
> > > >
> > > > Yansheng Lin
> > > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message