如何找到HttpURLConnection尝试将我重定向到的位置? [英] How do I find where an HttpURLConnection is trying to redirect me to?

查看:503
本文介绍了如何找到HttpURLConnection尝试将我重定向到的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HttpURLConnection我不遵循重定向,但是如果出现重定向我想知道我将被重定向到哪里。似乎没有一个HttpURLConnection的方法会告诉我,有什么办法可以获得这些信息吗?

I have an HttpURLConnection that I do not what to follow redirects, however if a redirect appears I want to know where I would get redirected to. There doesn't seem to be a method of HttpURLConnection that will show me that, is there any way I can get that information?

推荐答案

获取标题位置,它包含重定向的URL。查看所有细节的HTTP规范

Get the Header "Location", it contains the URL where you are redirected. Look at the HTTP spec for all the details

这篇关于如何找到HttpURLConnection尝试将我重定向到的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆