使用以下代码时:
URIBuilder uriBuilder = new URIBuilder(url);
HttpPost httpRequest= new HttpPost(uriBuilder.build());
HttpHost httpHost= new HttpHost(uriBuilder.getHost(), uriBuilder.getPort(), uriBuilder.getScheme());
什么时候使用是个好习惯
httpClient.execute(httpHost, httpRequest);
因为 httpHost 的主机可以通过包含 URL 的 HttpRequest 来确定
/**
* Executes HTTP request using the default context.
*
* @param target the target host for the request.
* Implementations may accept {@code null}
* if they can still determine a route, for example
* to a default target or by inspecting the request.
* @param request the request to execute
*
* @return the response to the request. This is always a final response,
* never an intermediate response with an 1xx status code.
* Whether redirects or authentication challenges will be returned
* or handled automatically depends on the implementation and
* configuration of this client.
* @throws IOException in case of a problem or the connection was aborted
* @throws ClientProtocolException in case of an http protocol error
*/
HttpResponse execute(HttpHost target, HttpRequest request)
打电话有什么好处吗
httpClient.execute(httpRequest);
它是代理/防火墙/平衡器相关的解决方案吗?主机何时与 URL 的主机不同?