使用 HttpClient 访问带双斜杠的 URL

Bar*_*lom 5 java url httpclient

我在另一台服务器上做一个这样的请求:

HttpGet req = new HttpGet("http://example.com//foo");
new DefaultHttpClient().execute(req);
Run Code Online (Sandbox Code Playgroud)

但是, HttpClient 更改example.com//fooexample.com/foo,因此其他服务器(不是我的)无法理解该请求。

我怎样才能解决这个问题?

小智 2

事实上这是一个非法的URL。

您是否尝试传递 URI 而不是字符串?你试过了吗 / \ \ / ?或者 URL 可能相当于 /default.asp/、/index.html/、/./、/?/、example.com/foo/ 等。

否则你将需要破解源。