[
https://issues.apache.org/jira/browse/CAMEL-27902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27902:
--------------------------------
Description:
Found while improving the option descriptions of camel-http for CAMEL-23832
(commit
https://github.com/apache/camel/commit/d09f8bc52aa903fb5780759bccdea7387e6fb3a9,
pull request https://github.com/apache/camel/pull/31165).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. The component cookieStore is never used
{{HttpEndpoint}} initializes cookieStore with a new BasicCookieStore, so the
check {{if (endpoint.getCookieStore() == null)}} in
{{HttpComponent.createEndpoint}} is never true and the cookieStore of the
component is ignored.
Proposed change: let the endpoint field start as null and fall back to a new
BasicCookieStore in createHttpClient.
h4. 2. httpConfiguration: only the authentication values are used
>From the component httpConfiguration, only the authentication fields reach the
>HTTP client (the configureBasicAuthentication fallback, and only when
>authMethod is set). Its proxy* and oauth2* values are copied onto the endpoint
>by setProperties after the HttpClientConfigurer was built from the URI
>parameters, so they have no effect.
Proposed change: use the httpConfiguration values as defaults in
configureHttpProxy and configureOAuth2Authentication.
h4. 3. proxyAuthMethod is never read
The endpoint and component option proxyAuthMethod is not used:
ProxyHttpClientConfigurer uses NTCredentials when proxyAuthDomain is set and
UsernamePasswordCredentials otherwise, and HttpClient picks the scheme from the
407 challenge.
Proposed change: use the option, or deprecate it.
h4. 4. The OAuth2 token request is not URL-encoded
{{OAuth2ClientConfigurer.getAccessTokenResponse}} puts scope, client_id,
client_secret and resource into the form body without URL-encoding, so a scope
list with spaces, or a secret with &, + or =, gives a broken token request.
Proposed change: build the body with URLEncoder or UrlEncodedFormEntity.
h4. 5. Connections with a user token are not reused
Each message runs in a new HttpCoreContext, so the user token is null when a
connection is leased, and StrictConnPool.getFree(null) only returns connections
without state. A connection that carries a principal (TLS client certificate,
NTLM) is never reused and every message opens a new connection.
connectionStateDisabled=true works around it.
Proposed change: set NoopUserTokenHandler by default, or keep the user token
per endpoint.
h4. 6. LoggingHttpActivityListener: sourceLocationLoggerName and showRouteGroup
{{HttpEndpoint.createHttpClient}} passes the anonymous interceptor ({{this}})
as source to the activity listener, which is not LineNumberAware, so
sourceLocationLoggerName never takes effect; and
{{LoggingHttpActivityListener.onActivity}} tests {{showRouteGroup &&
showRouteId}}, so showRouteGroup=false also hides the route ID.
Proposed change: pass HttpEndpoint.this, and test the two flags separately.
h4. 7. Smaller issues
The timeouts connectTimeout, soTimeout, responseTimeout and
connectionRequestTimeout are accepted on the endpoint URI but are @Metadata
(not @UriParam) on HttpEndpoint, so they are missing from the endpoint options
in the catalog and the docs. A clientConnectionManager on the endpoint drops
the pool the component already built for it without closing it, and the
endpoint closes a custom clientConnectionManager or httpClient on stop even
when it is shared. The component connectionTimeToLive has no defaultValue in
the metadata (effective -1). The header CamelHttpCharacterEncoding is not used
by the producer.
_Claude Code on behalf of davsclaus_
was:
Found while improving the option descriptions of camel-http for CAMEL-23832
(pull request https://github.com/apache/camel/pull/31165).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. The component cookieStore is never used
{{HttpEndpoint}} initializes cookieStore with a new BasicCookieStore, so the
check {{if (endpoint.getCookieStore() == null)}} in
{{HttpComponent.createEndpoint}} is never true and the cookieStore of the
component is ignored.
Proposed change: let the endpoint field start as null and fall back to a new
BasicCookieStore in createHttpClient.
h4. 2. httpConfiguration: only the authentication values are used
>From the component httpConfiguration, only the authentication fields reach the
>HTTP client (the configureBasicAuthentication fallback, and only when
>authMethod is set). Its proxy* and oauth2* values are copied onto the endpoint
>by setProperties after the HttpClientConfigurer was built from the URI
>parameters, so they have no effect.
Proposed change: use the httpConfiguration values as defaults in
configureHttpProxy and configureOAuth2Authentication.
h4. 3. proxyAuthMethod is never read
The endpoint and component option proxyAuthMethod is not used:
ProxyHttpClientConfigurer uses NTCredentials when proxyAuthDomain is set and
UsernamePasswordCredentials otherwise, and HttpClient picks the scheme from the
407 challenge.
Proposed change: use the option, or deprecate it.
h4. 4. The OAuth2 token request is not URL-encoded
{{OAuth2ClientConfigurer.getAccessTokenResponse}} puts scope, client_id,
client_secret and resource into the form body without URL-encoding, so a scope
list with spaces, or a secret with &, + or =, gives a broken token request.
Proposed change: build the body with URLEncoder or UrlEncodedFormEntity.
h4. 5. Connections with a user token are not reused
Each message runs in a new HttpCoreContext, so the user token is null when a
connection is leased, and StrictConnPool.getFree(null) only returns connections
without state. A connection that carries a principal (TLS client certificate,
NTLM) is never reused and every message opens a new connection.
connectionStateDisabled=true works around it.
Proposed change: set NoopUserTokenHandler by default, or keep the user token
per endpoint.
h4. 6. LoggingHttpActivityListener: sourceLocationLoggerName and showRouteGroup
{{HttpEndpoint.createHttpClient}} passes the anonymous interceptor ({{this}})
as source to the activity listener, which is not LineNumberAware, so
sourceLocationLoggerName never takes effect; and
{{LoggingHttpActivityListener.onActivity}} tests {{showRouteGroup &&
showRouteId}}, so showRouteGroup=false also hides the route ID.
Proposed change: pass HttpEndpoint.this, and test the two flags separately.
h4. 7. Smaller issues
The timeouts connectTimeout, soTimeout, responseTimeout and
connectionRequestTimeout are accepted on the endpoint URI but are @Metadata
(not @UriParam) on HttpEndpoint, so they are missing from the endpoint options
in the catalog and the docs. A clientConnectionManager on the endpoint drops
the pool the component already built for it without closing it, and the
endpoint closes a custom clientConnectionManager or httpClient on stop even
when it is shared. The component connectionTimeToLive has no defaultValue in
the metadata (effective -1). The header CamelHttpCharacterEncoding is not used
by the producer.
_Claude Code on behalf of davsclaus_
> camel-http: the component cookieStore is never used, httpConfiguration proxy
> and OAuth2 values have no effect, the OAuth2 token request is not URL-encoded
> ----------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27902
> URL: https://issues.apache.org/jira/browse/CAMEL-27902
> Project: Camel
> Issue Type: Bug
> Components: camel-http
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-http for CAMEL-23832
> (commit
> https://github.com/apache/camel/commit/d09f8bc52aa903fb5780759bccdea7387e6fb3a9,
> pull request https://github.com/apache/camel/pull/31165).
> These are separate problems of the component; the descriptions change only
> documents the current behavior.
> h4. 1. The component cookieStore is never used
> {{HttpEndpoint}} initializes cookieStore with a new BasicCookieStore, so the
> check {{if (endpoint.getCookieStore() == null)}} in
> {{HttpComponent.createEndpoint}} is never true and the cookieStore of the
> component is ignored.
> Proposed change: let the endpoint field start as null and fall back to a new
> BasicCookieStore in createHttpClient.
> h4. 2. httpConfiguration: only the authentication values are used
> From the component httpConfiguration, only the authentication fields reach
> the HTTP client (the configureBasicAuthentication fallback, and only when
> authMethod is set). Its proxy* and oauth2* values are copied onto the
> endpoint by setProperties after the HttpClientConfigurer was built from the
> URI parameters, so they have no effect.
> Proposed change: use the httpConfiguration values as defaults in
> configureHttpProxy and configureOAuth2Authentication.
> h4. 3. proxyAuthMethod is never read
> The endpoint and component option proxyAuthMethod is not used:
> ProxyHttpClientConfigurer uses NTCredentials when proxyAuthDomain is set and
> UsernamePasswordCredentials otherwise, and HttpClient picks the scheme from
> the 407 challenge.
> Proposed change: use the option, or deprecate it.
> h4. 4. The OAuth2 token request is not URL-encoded
> {{OAuth2ClientConfigurer.getAccessTokenResponse}} puts scope, client_id,
> client_secret and resource into the form body without URL-encoding, so a
> scope list with spaces, or a secret with &, + or =, gives a broken token
> request.
> Proposed change: build the body with URLEncoder or UrlEncodedFormEntity.
> h4. 5. Connections with a user token are not reused
> Each message runs in a new HttpCoreContext, so the user token is null when a
> connection is leased, and StrictConnPool.getFree(null) only returns
> connections without state. A connection that carries a principal (TLS client
> certificate, NTLM) is never reused and every message opens a new connection.
> connectionStateDisabled=true works around it.
> Proposed change: set NoopUserTokenHandler by default, or keep the user token
> per endpoint.
> h4. 6. LoggingHttpActivityListener: sourceLocationLoggerName and
> showRouteGroup
> {{HttpEndpoint.createHttpClient}} passes the anonymous interceptor ({{this}})
> as source to the activity listener, which is not LineNumberAware, so
> sourceLocationLoggerName never takes effect; and
> {{LoggingHttpActivityListener.onActivity}} tests {{showRouteGroup &&
> showRouteId}}, so showRouteGroup=false also hides the route ID.
> Proposed change: pass HttpEndpoint.this, and test the two flags separately.
> h4. 7. Smaller issues
> The timeouts connectTimeout, soTimeout, responseTimeout and
> connectionRequestTimeout are accepted on the endpoint URI but are @Metadata
> (not @UriParam) on HttpEndpoint, so they are missing from the endpoint
> options in the catalog and the docs. A clientConnectionManager on the
> endpoint drops the pool the component already built for it without closing
> it, and the endpoint closes a custom clientConnectionManager or httpClient on
> stop even when it is shared. The component connectionTimeToLive has no
> defaultValue in the metadata (effective -1). The header
> CamelHttpCharacterEncoding is not used by the producer.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)