我使用“prepareHttpPost”方法在JAVA中使用parallelClient将数据发布到URL集。默认情况下,它会在每个URL的末尾添加端口号:80。因此,我从每个URL中找不到404页面。我需要删除URL末尾的端口号。
以下是我要验证的代码。
private List<String> postHostsList = Arrays.asList("HOST1/test.php",
"HOST2/testing.php");
parallelClient = new ParallelClient();
String requestBody = "<JSON DATA>";
parallelClient.prepareHttpPost("").setConcurrency(20).setTargetHostsFromList(postHostsList)
.setHttpHeaders(new ParallecHeader().addPair("Content-Type", "application/json"))
.setHttpEntityBody(requestBody).execute(new ParallecResponseHandler() {
public void onCompleted(ResponseOnSingleTask responseOnSingleTask, Map<String, Object> map) {
responseOnSingleTask.getStatusCode().replaceAll("", "_");
System.out.println("Status Code =>" + responseOnSingleTask.getStatusCode());
System.out.println("Response =>" + responseOnSingleTask.getResponseContent());
}
});
parallelClient.releaseExternalResources();