如果现在不推荐使用setParams和getParams,如何使用http client 4.3在CloseableHttpClient对象或HttpPost对象上设置协议版本?
答案 0 :(得分:8)
HttpPost post = new HttpPost("/");
post.setProtocolVersion(HttpVersion.HTTP_1_1);
答案 1 :(得分:1)
或使用他们如今喜欢的那种建筑师模式:
final HttpUriRequest request = RequestBuilder.post()
.setVersion(HttpVersion.HTTP_1_1)
.setUri(requestURI)
.addHeader(key, value)
.... <whaterver more you want to add to the request>
.build()