hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim <jimi...@gmail.com>
Subject Re: Why doesn't httpclient follow redirects on this URL?
Date Wed, 08 Sep 2010 19:26:09 GMT
Stephen, thank you ... you're correct now that I manually do a HEAD request.
I switched to HttpGet and that correctly follows the 302




On Wed, Sep 8, 2010 at 12:18 PM, Stephen J. Butler <stephen.butler@gmail.com
> wrote:

> On Wed, Sep 8, 2010 at 1:42 PM, Jim <jiminoc@gmail.com> wrote:
> > HttpHead httpget = null;
> > HttpHost target = null;
> > HttpUriRequest req = null;
> >
> > String startURL = "
> >
> http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGrJk-F7Dmshmtze2yhifxRsv8sRg&url=http://www.mtv.com/news/articles/1647243/20100907/story.jhtml
> > ";
> > HttpContext localContext = new BasicHttpContext();
> >
> localContext.setAttribute(ClientContext.COOKIE_STORE,HttpClientFetcher.emptyCookieStore);
> > httpget = new HttpHead(startURL);
>
> There's your problem. Google doesn't respond to HEAD the same way as GET:
>
> $ nc news.google.com 80
> HEAD /news/url?sa=t&fd=R&usg=AFQjCNGrJk-F7Dmshmtze2yhifxRsv8sRg&url=
> http://www.mtv.com/news/articles/1647243/20100907/story.jhtml
> HTTP/1.1
> Host: news.google.com
>
> HTTP/1.1 200 OK
> Content-Type: text/html; charset=ISO-8859-1
> Set-Cookie:
> PREF=ID=c0dc77b54e3366b4:TM=1283973424:LM=1283973424:S=5gVyGhbFXF9WJ_WY;
> expires=Fri, 07-Sep-2012 19:17:04 GMT; path=/; domain=.google.com
> X-Content-Type-Options: nosniff
> Date: Wed, 08 Sep 2010 19:17:04 GMT
> Server: NFE/1.0
> Content-Length: 0
> X-XSS-Protection: 1; mode=block
> Expires: Wed, 08 Sep 2010 19:17:04 GMT
> Cache-Control: private
>
> ---------------------------------------------------------------------
> 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