hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen J. Butler" <stephen.but...@gmail.com>
Subject Re: why are so different the response headers as reported by wget and httpclient?
Date Tue, 07 May 2013 22:45:15 GMT
On Tue, May 7, 2013 at 4:15 PM, Albretch Mueller <lbrtchx@gmail.com> wrote:

>  1) even if, since all I need are the headers, for which I "only" need to
> go:
>   Header[] RspnsHdrs = httpResponse.getAllHeaders();
> // __ closing underlying stream (just getting all HTTP headers for
> this URL's connection)
>  InputStream IS = httpEnt.getContent();
>  IS.close();
>  the InputStream is taking like a minute to actually close. Why is
> that happening?
>  It seems once you go "GET ..." the server does as you tell it and
> sends the data anyway, which seems to be patiently swallowed by HC,
> even if the data is not saved to local storage
>  Is there a way to just get the headers and the negotiation without
> the actual payload? (like the spider option of wget)

A HEAD request, instead of GET, should return just the headers. Although
I'm not a 100% sure about that... the server might still be allowed to
respond with a body for a HEAD request.

Either way, use EntityUtils.consumeQuietly(ent) is the best way to handle
unwanted entity content. Just closing the input stream is a little rude.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message