You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2007/06/11 10:25:37 UTC

Re: Is httpclient able to notice me whether the fetching process has been finished?

On Mon, 2007-06-11 at 15:06 +0800, Feng Jiang wrote:
> Hi all,
> 
> I need httpclient to fetching some large files, such as images, videos. In
> some cases, the server will close the connection before the fetching process
> is done, so that I have only fetched a part of the whole file. In this case,
> I hope httpclient be able to tell me whether it fetched the whole file, or
> interrupted during the fetching process.
> 
> Can httpclient do it?
> 
> Thanks alot,
> 
> Feng

Hi Feng

HttpClient will throw an IOException (most likely 'Connection reset by
peer' or some such) if the target server shuts down the connection
prematurely.

Hope this helps

Oleg


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


Re: Is httpclient able to notice me whether the fetching process has been finished?

Posted by Feng Jiang <fe...@gmail.com>.
Ok, thanks.

Feng

On 6/11/07, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> On Mon, 2007-06-11 at 16:46 +0800, Feng Jiang wrote:
> > Hi Oleg,
> >
> > thanks alot. but which method does you mean? I read stream in this way:
> > InputStream is = method.getResponseBodyAsStream();
> > is.read(...)
> >
> > Do you mean that I just only need to handle the IOException thrown by
> the
> > InputStream.read() method?
>
> Yes, I do.
>
> > Isn't there any other possibility that httpclient
> > throws IOException not because the conneciton is closed?
> >
>
> There can be other causes for an IOException to be thrown while fetching
> the response body such as malformed chunk encoding but the premature
> termination of the connection by the peer or a connectivity problem are
> the most likely ones.
>
> Oleg
>
>
> > Any way, Thanks a lot.
> >
> > Feng
> >
> > On 6/11/07, Oleg Kalnichevski <ol...@apache.org> wrote:
> > >
> > > On Mon, 2007-06-11 at 15:06 +0800, Feng Jiang wrote:
> > > > Hi all,
> > > >
> > > > I need httpclient to fetching some large files, such as images,
> videos.
> > > In
> > > > some cases, the server will close the connection before the fetching
> > > process
> > > > is done, so that I have only fetched a part of the whole file. In
> this
> > > case,
> > > > I hope httpclient be able to tell me whether it fetched the whole
> file,
> > > or
> > > > interrupted during the fetching process.
> > > >
> > > > Can httpclient do it?
> > > >
> > > > Thanks alot,
> > > >
> > > > Feng
> > >
> > > Hi Feng
> > >
> > > HttpClient will throw an IOException (most likely 'Connection reset by
> > > peer' or some such) if the target server shuts down the connection
> > > prematurely.
> > >
> > > Hope this helps
> > >
> > > Oleg
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> httpclient-user-help@jakarta.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>

Re: Is httpclient able to notice me whether the fetching process has been finished?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2007-06-11 at 16:46 +0800, Feng Jiang wrote:
> Hi Oleg,
> 
> thanks alot. but which method does you mean? I read stream in this way:
> InputStream is = method.getResponseBodyAsStream();
> is.read(...)
> 
> Do you mean that I just only need to handle the IOException thrown by the
> InputStream.read() method? 

Yes, I do.

> Isn't there any other possibility that httpclient
> throws IOException not because the conneciton is closed?
> 

There can be other causes for an IOException to be thrown while fetching
the response body such as malformed chunk encoding but the premature
termination of the connection by the peer or a connectivity problem are
the most likely ones.

Oleg


> Any way, Thanks a lot.
> 
> Feng
> 
> On 6/11/07, Oleg Kalnichevski <ol...@apache.org> wrote:
> >
> > On Mon, 2007-06-11 at 15:06 +0800, Feng Jiang wrote:
> > > Hi all,
> > >
> > > I need httpclient to fetching some large files, such as images, videos.
> > In
> > > some cases, the server will close the connection before the fetching
> > process
> > > is done, so that I have only fetched a part of the whole file. In this
> > case,
> > > I hope httpclient be able to tell me whether it fetched the whole file,
> > or
> > > interrupted during the fetching process.
> > >
> > > Can httpclient do it?
> > >
> > > Thanks alot,
> > >
> > > Feng
> >
> > Hi Feng
> >
> > HttpClient will throw an IOException (most likely 'Connection reset by
> > peer' or some such) if the target server shuts down the connection
> > prematurely.
> >
> > Hope this helps
> >
> > Oleg
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >


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


Re: Is httpclient able to notice me whether the fetching process has been finished?

Posted by Feng Jiang <fe...@gmail.com>.
Hi Oleg,

thanks alot. but which method does you mean? I read stream in this way:
InputStream is = method.getResponseBodyAsStream();
is.read(...)

Do you mean that I just only need to handle the IOException thrown by the
InputStream.read() method? Isn't there any other possibility that httpclient
throws IOException not because the conneciton is closed?

Any way, Thanks a lot.

Feng

On 6/11/07, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> On Mon, 2007-06-11 at 15:06 +0800, Feng Jiang wrote:
> > Hi all,
> >
> > I need httpclient to fetching some large files, such as images, videos.
> In
> > some cases, the server will close the connection before the fetching
> process
> > is done, so that I have only fetched a part of the whole file. In this
> case,
> > I hope httpclient be able to tell me whether it fetched the whole file,
> or
> > interrupted during the fetching process.
> >
> > Can httpclient do it?
> >
> > Thanks alot,
> >
> > Feng
>
> Hi Feng
>
> HttpClient will throw an IOException (most likely 'Connection reset by
> peer' or some such) if the target server shuts down the connection
> prematurely.
>
> Hope this helps
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>