4

How do you set the protocol version on a CloseableHttpClient object or HttpPost object with http client 4.3 now that setParams and getParams are deprecated?

2 Answers 2

10
HttpPost post = new HttpPost("/");
post.setProtocolVersion(HttpVersion.HTTP_1_1);
Sign up to request clarification or add additional context in comments.

1 Comment

httpClient version 5 has setVersion function
4

or use that builder pattern they are so fond of these days:

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()

1 Comment

Odd thing to be snide about

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.