To disable HTTP connection persistency I would like to enforce HTTP protocol 1.0 on one of my Apache Camel routes using the http component.
Following Camel's http component documentation I tried to use the following URI:
http://localhost:8888/foo?httpClient.protocolVersion=HTTP/1.0
However, the camel context initialization fails with a ResolveEndpointFailedException with message:
Unknown parameters=[{protocolVersion=HTTP/1.0}]
I assumed that the protocol version parameter is available due to the HttpClientParam documentation. Interestingly, the soTimeout example from the Apache Camel documentation works fine.
I tried both the http and http4 components. I use Apache Camel 2.10.4. The http component has the user agent Jakarta Commons-HttpClient/3.1.
I know that I could also try to use the httpClientConfigurer and/or clientConnectionManager parameters of the http components, but would rather use a solution that does not require custom code.
Thanks in advance for any help!
I came up with the following solution.
On the http-component URL I set a custom httpClientConfigurer
:
http://localhost:8080/foo?httpClientConfigurer=myHttpClientConfigurer
where myHttpClientConfigurer
is a bean with an implementation similar to this:
public class Http10ClientConfigurer implements HttpClientConfigurer {
@Override
public void configureHttpClient(HttpClient httpClient) {
if (httpClient.getParams() != null) {
httpClient.getParams().setVersion(new HttpVersion(1, 0));
} else {
// Could not set HTTP 1.0 version on httpClient
}
}
}