开发者

HttpClient throws 403

trying to access http://forum.worldoftanks.eu/index.php?ap开发者_Python百科p=members using apache HttpClient but keep getting 403. Can anyone help out? Been fiddling with this piece as a starting point:

DefaultHttpClient httpClient = new DefaultHttpClient();
HttpRequestBase method = new HttpGet(theUrl);
String s = httpClient.execute(method, new BasicResponseHandler());    
System.out.println(s);
httpClient.getConnectionManager().shutdown();


I don't think this is related to HttpClient. I tried this

$ wget http://forum.worldoftanks.eu/index.php?app=members
--2011-08-08 23:17:52--  http://forum.worldoftanks.eu/index.php?app=members
Resolving forum.worldoftanks.eu (forum.worldoftanks.eu)... 213.252.177.21, 213.2
52.177.20
Connecting to forum.worldoftanks.eu (forum.worldoftanks.eu)|213.252.177.21|:80..
. connected.
HTTP request sent, awaiting response... 403 Forbidden
2011-08-08 23:17:56 ERROR 403: Forbidden.

with no luck.

Yet I can hit it in the browser. It might be that there is some server logic returning 403s when an appropriate browser headers aren't sent. My next step would be to use FireBug and try to replicate the request as your browser makes it.

Also, try catching the exceptino

  } catch (HttpResponseException e) {
    System.err.println(e.response.parseAsString());
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜