[ 
https://issues.apache.org/jira/browse/CAMEL-26138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136762#comment-18136762
 ] 

Claus Ibsen commented on CAMEL-26138:
-------------------------------------

The open question on mapHttpMessageBody=false is decided: it is fixed as 
proposed in the issue. With mapHttpMessageBody=false the request body is not 
read and the message body is null, also when the route accesses it 
(HttpMessage.createBody returns null). The option description is updated, and 
the 4.24 upgrade guide has an entry (camel-jetty, camel-servlet).

A related bug in the same class is fixed in the same PR: 
DefaultHttpBinding.doWriteGZIPResponse failed with a 500 for a Map, List, POJO 
or number reply with Content-Encoding gzip, encoded a String body in the 
exchange charset instead of the content type charset, and checked the IN 
message body for a stream instead of the reply message body. It now writes the 
reply body like the direct reply does.

PR: https://github.com/apache/camel/pull/28911

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> 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
>            Assignee: Claus Ibsen
>            Priority: Major
>             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