日期:2014-05-19  浏览次数:20747 次

HttpClient模拟登陆下载一个文件时 中间有个302跳转报错
1.首先是登陆 成功!(https://itunesconnect.apple.com/)
2.然后跳转到一个页 成功!(https://itunesconnect.apple.com/)
3.然后一个A标签 A标签的地址域名与上两个的域名不一样 失败!(https://reportingitc.apple.com)
4.搜索数据 失败!(https://reportingitc.apple.com)
5.下载数据 失败!(https://reportingitc.apple.com)


现在卡到第三步 第三步不解决下面两个解决不了

报错如下:
Java code

org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:909)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
    at com.httpTest.Test.main(Test.java:148)
Caused by: org.apache.http.HttpException: Unable to establish route: planned = {s}->https://reportingitc.apple.com; current = {s}->https://itunesconnect.apple.com
    at org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:842)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)



------解决方案--------------------
302并不是错误,只是页面重定向而已。

从HTTPHEAD中取出重定向的目标页,然后重新发起请求即可。