我有以下代码:
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpEntity resEntity = null;
String endpointUrl = "https://test_demodata.domain.com/test_demodata/upload";
try {
HttpClientContext context = HttpClientContext.create();
HttpGet httpGet = new HttpGet(endpointUrl);
HttpResponse response = httpClient.execute(httpGet);
resEntity = response.getEntity();
System.out.println(response.getStatusLine());
System.out.println(EntityUtils.toString(resEntity));
} catch (ClientProtocolException e) {
throw new DocumentUploadException("Can't create temp file", e);
} catch (IOException e) {
throw new DocumentUploadException("Can't create temp file", e);
} finally {
if (resEntity != null) {
try {
EntityUtils.consume(resEntity);
} catch (IOException e) {
throw new DocumentUploadException(
"Can't close file upload connection", e);
}
}
if (httpClient != null) {
try {
httpClient.close();
} catch (IOException e) {
throw new DocumentUploadException(
"Can't close file upload connection", e);
}
}
}
我收到 404 not found ,并显示以下消息:
在此服务器上找不到请求的网址/ test_demodata:443 /
因此HttpClient正在尝试将端口号添加到文件夹中。
我尝试添加SSL支持,但是对于大量的折旧代码感到不知所措,并且无法找到新版本的工作解决方案。
如何让HttpClient处理https URL?
编辑:当我将endpointUrl
更改为不存在的那个时,错误消息就不同了:
在此服务器上找不到 / test_demodata / upload1
因此,出于某种原因,有问题的服务器了解所请求的文件夹是否存在,但如果重定向到 / test_demodata:443 / 会产生此错误,则会添加一些类型。
此URL在IE,FF和&铬。