阿帕奇的HttpClient:重定向的网址位置 [英] Apache HttpClient: Location of redirected URLs

查看:493
本文介绍了阿帕奇的HttpClient:重定向的网址位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache的HttpClient的(用于Java)加载,这是获得一个HTTP 301重定向响应的URL。好消息,HttpClient的自动遵循此重定向,并且我不需要手动通过重定向循环。

I'm using Apache's HttpClient (for Java) load a Url that is getting redirected by a HTTP 301 response. The good news, HttpClient follows this redirect automatically, and I don't need to manually loop through the redirects.

我还没有想出的部分是我的最终目的地。因为我得到最后的成功(HTTP 200)查询头,没有Location头。由于重定向发生HttpClient.execute(..)的幕后,我的code不知道是否有一个重定向,并在它重定向到。

The part I haven't figured out is my final destination. Because I'm getting the headers of the final successful (HTTP 200) query, there is no Location header. Since the redirect occurs behind the scenes of the HttpClient.execute(..), my code doesn't know whether there has been a redirect, and where it has redirected to.

我如何获得这一重要的资料片?我真的需要重新code此java.net中的类来得到这个信息?

How do I get this vital piece of information? Do I really need to recode this in java.net classes to get this info?

有关记录,我在Android上使用Apache的HttpClient和需要向后兼容性回到了Android 1.6。

For the record, I'm using the Apache HttpClient on Android, and need backward compatibility back to Android 1.6.

推荐答案

所有冰雹的 RedirectHandler (帮助阅读的文档)

All hail the RedirectHandler (helps to read the docs)

这篇关于阿帕奇的HttpClient:重定向的网址位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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