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 Roland Weber <RO...@de.ibm.com> on 2006/09/07 08:35:45 UTC

Re: Equivalent of setFollowRedirects(false) for HttpConnection

Hello Jeff,

> I'm writing an application that downloads files, and I need to disable 
the
> automatic following of HTTP redirects.
> Does that mean that, to download my files, I have to use GetMethod 
instead
> of HttpConnection.getResponseInputStream() ?
> 
> More specifically:
> 
> Class HttpMethodBase has a method named setFollowRedirects(boolean), 
which
> can be used to "turn off" the automatic following of HTTP redirects.
> 
> However, if I use HttpConnection.getResponseInputStream(), there doesn't
> appear to be a corresponding way to turn off automatic HTTP redirection.
> 
> Or am I missing something?

You are. If you want to read RFC 2616 and implement all the logic 
yourself,
then you can use the HttpConnection directly. Don't worry about redirects,
you'll have to implement them yourself. Like everything else, for example
setting a host header or not, depending on the protocol version you use.
Or authentication. Or cookie/session management. Or connection management.

If you prefer to profit from the years of experience and development that
have gone into HttpClient, you will use GetMethod and pass it for 
execution
to an instance of HttpClient. There's a tutorial showing how to use
HttpClient correctly:
http://jakarta.apache.org/commons/httpclient/tutorial.html

cheers,
  Roland


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