davsclaus opened a new pull request, #28912:
URL: https://github.com/apache/camel/pull/28912

   Fixes [CAMEL-26139](https://issues.apache.org/jira/browse/CAMEL-26139).
   
   ### What was wrong
   
   With `attachmentMultipartBinding=true`, 
`AttachmentHttpBinding.populateAttachments` called `request.getParts()` for 
every request. The servlet container throws from `getParts()` when the request 
is not `multipart/form-data`. The exception was wrapped as `Cannot populate 
attachments` and the client got a 500. So such an endpoint could not serve a 
GET or a plain POST (text, JSON, ...).
   
   ### What changed
   
   `AttachmentHttpBinding` (camel-servlet) now reads the parts only when the 
request `Content-Type` starts with `multipart/form-data` (case-insensitive). 
Other requests skip attachment handling, and the body is read as usual.
   
   The issue proposed `multipart/*`. I used `multipart/form-data` because that 
is the only type `getParts()` supports per the Servlet spec. Undertow and 
Tomcat throw for `multipart/mixed` as well, so checking `multipart/*` would 
keep the 500 for those requests.
   
   The fix is only in camel-servlet. camel-http-common is not touched, so this 
does not overlap with #28911. camel-jetty already guards this with its 
`MultiPartFilter.MULTIPART` request attribute.
   
   ### Tests
   
   `MultipartUploadTest` has two new tests against a route with 
`attachmentMultipartBinding=true`: a `text/plain` POST and a GET. Both expect 
200 and the echoed body. Both failed with 500 before the fix. The existing 
multipart upload and whitelist tests still pass. Full camel-servlet suite: 114 
tests, 0 failures (2 skipped, as on main).
   
   ### Docs
   
   No doc, option or generated-file changes. No upgrade-guide entry: these 
requests used to fail with a 500, so no user relies on the old behaviour.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to