Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection question  RSS feed

 
Bill Gunn
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I setFollowRedirects to true, will it just return a 200 status code for the new url after being redirected? Is there any way to get the new url that it is redirecting to?
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bill Gunn:
If I setFollowRedirects to true, will it just return a 200 status code for the new url after being redirected?
That's what I would expect. I don't see what else it could do.
Is there any way to get the new url that it is redirecting to?
I wouldn't expect so. Perhaps the getURL() method would return the last URL connected to, but I wouldn't expect that. However I'm sure a quick test would answer that.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you played with setting followRedirects to false? I think you can get the next URL and then fetch it. More work, but it gets the info you wanted.
 
Bill Gunn
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, I've been kind of playing with it in my app. As far as I can tell, it doesn't redirect at all. I may be doing something wrong though, since I don't really understand connecting, then setting the redirect to true, but that's the only format I've found that will compile.



After I check for a 302 or 301 response code, I print out the url using con.getURL(). I still get the old url.

[ August 16, 2006: Message edited by: Bill Gunn ]
[ August 16, 2006: Message edited by: Bill Gunn ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This really belongs in our Sockets and Internet Protocols forum, so I will move it there.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!