Claus Ibsen created CAMEL-26138:
-----------------------------------

             Summary: camel-http-common - with chunked=true a Map, List, POJO 
or number reply is a 200 with an empty body, and mapHttpMessageBody=false still 
maps the body (jetty, servlet)
                 Key: CAMEL-26138
                 URL: https://issues.apache.org/jira/browse/CAMEL-26138
             Project: Camel
          Issue Type: Bug
          Components: camel-http-common
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of jetty and servlet, which share 
{{DefaultHttpBinding}} and {{HttpMessage}} of camel-http-common (CAMEL-24961, 
PR #28395).

h4. 1. With chunked=true (the default) a Map, List, POJO or number reply is a 
200 with an empty body

{{DefaultHttpBinding.doWriteDirectResponse}} (main 2a465aa4814c, line 539) 
takes {{message.getBody(InputStream.class)}} when the response is chunked. For 
a Map, List, POJO or number this gives no data (the request stream, already 
read), so the response is a 200 with an empty body and no error. With 
{{chunked=false}} the same bodies are written as their String form (line 593). 
Checked on 4.24.0-SNAPSHOT with a java.net.http client against jetty and 
servlet consumers (servlet in the Undertow servlet container).

Proposed: when the body is not a stream or bytes, use the same String fallback 
as the non-chunked path.

h4. 2. mapHttpMessageBody=false still maps the request body

{{DefaultHttpBinding.readRequest}} (line 125) skips {{readBody}} when 
{{mapHttpMessageBody=false}}, but {{HttpMessage.createBody}} (line 98) reads 
the body lazily with {{parseBody}} whenever the route asks for it, so the 
option has no effect on the body the route sees. Checked on 4.24.0-SNAPSHOT 
with jetty and servlet consumers.

Proposed: return null from {{HttpMessage.createBody}} when the binding has 
{{mapHttpMessageBody=false}}.

h4. 3. With disableStreamCache=true a form POST loses its body

{{DefaultHttpBinding.readFormUrlEncodedBody}} (line 294) reads the body as a 
String to map the form fields to headers. With {{disableStreamCache=true}} the 
body is the raw request stream, so it is consumed: servlet then fails with 500 
"UT010029: Stream is closed" and jetty gives the route an empty body. Checked 
on 4.24.0-SNAPSHOT with jetty and servlet consumers.

Proposed: with {{disableStreamCache=true}}, keep the read text as the body (or 
take the form fields from {{request.getParameterMap()}}).

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to