• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTPURLConnection Redirect  RSS feed

 
Ajay Thacker
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am tryting to download a document using HTTPURLConnection. The problem is I dont have direct link to the document. The link I have is authenticating me using IP Address and then redirecting me to the actual page. I dont know the actual link at the beginning. I need to get new location of URL to donwload it. I dont know HOW??

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a request is redirected, there's a particular status code, and a redirect URL which I believe is in a special header. The HttpURLConnection class has a getResponseCode() method, and a getHeaderFields() method for gettting a Map of all the headers. If you call setInstanceFollowRedirects(false), then this info will be available to you and you can then grab the file you actually want.

I've never done this, of course. Just guessing.

I'm moving this to the Sockets and Internet Protocols forum for followup.
 
Ajay Thacker
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
I tried it. I am not able to get it. The URL I know is using IP authentication so it is taking time to redirect. Is it possible to track url to get to the final url?

Thanks
AT
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!