[
https://issues.apache.org/jira/browse/CAMEL-25563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127073#comment-18127073
]
Claus Ibsen commented on CAMEL-25563:
-------------------------------------
Merged to main in https://github.com/apache/camel/pull/27787
_Claude Code on behalf of
> camel-http - send each value of a multi-value header as its own HTTP header
> line
> --------------------------------------------------------------------------------
>
> Key: CAMEL-25563
> URL: https://issues.apache.org/jira/browse/CAMEL-25563
> Project: Camel
> Issue Type: Improvement
> Components: camel-http
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.24.0
>
>
> h3. Problem
> When a message header has two or more values (a {{List}}, a collection or an
> array), the camel-http producer sends them as a single header line with the
> {{toString()}} of the list, brackets included:
> {code}
> Accept: [text/plain, application/json]
> {code}
> See {{HttpProducer.applyHeader}} ({{multiValues.size() > 1 ?
> multiValues.toString() : multiValues.get(0)}}).
> This is not valid HTTP. A receiver that reads it as a list (RFC 9110 section
> 5.3) sees the values {{[text/plain}} and {{application/json]}}. It does not
> round-trip in Camel either: a Camel HTTP consumer turns repeated header lines
> into a {{List}}, but this arrives as the plain string {{"[text/plain,
> application/json]"}}. For {{Set-Cookie}}, folding values into one line is
> never valid.
> h3. Expected
> Send one header line per value, like every mainstream HTTP client (JDK
> {{HttpClient}}, Apache HttpClient {{addHeader}}, OkHttp, Netty, Vert.x,
> Spring {{HttpHeaders}}, curl with {{-H}} twice) and like the other Camel HTTP
> components already do: camel-http-common (servlet/jetty), camel-netty-http,
> camel-undertow and camel-platform-http-vertx.
> {code}
> Accept: text/plain
> Accept: application/json
> {code}
> RFC 9110 section 5.3 makes this equivalent to {{Accept: text/plain,
> application/json}} for list-based headers, and it is the only form that is
> also correct for {{Set-Cookie}}.
> h3. Notes
> * The same convention is being applied to camel-vertx-http (CAMEL-25526, PR
> #27689) and camel-knative-http (CAMEL-25547, PR #27690). Ideally all three
> share one helper in camel-support {{HttpUtil}}.
> * Only collections and object arrays should be split, not every {{Iterable}}
> (for example a Vert.x {{JsonObject}} is an {{Iterable}} of its entries).
> * {{Cookie}} from the cookie handler stays one line joined with {{;}}, as
> today.
> * This changes what is sent for multi-value headers, so it needs an entry in
> the 4.24 upgrade guide.
> _Created by Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)