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

   ## Summary
   
   _Claude Code on behalf of davsclaus_
   
   Fixes two bugs in `RestBindingAdvice.marshal()` related to Content-Type 
handling:
   
   **Bug 1 - Content-Type set on body-less responses:** 
`ensureHeaderContentType()` was called before the null-body check, so responses 
with no body (e.g. 204 No Content) got a spurious Content-Type header. Moved 
the null-body check to before the `ensureHeaderContentType()` call.
   
   **Bug 2 - Multi-value `produces` used as Content-Type:** 
`ensureHeaderContentType()` set the raw comma-separated `produces` string (e.g. 
`application/json,text/plain`) as Content-Type before the `isJson`/`isXml` 
fallback branches had a chance to set a proper single media type. Reordered the 
priority so `isJson`/`isXml` are checked first (setting `application/json` or 
`application/xml`), with the raw `produces` string only used as a last resort.
   
   ## Test plan
   
   - [x] New test `FromRestGetContentTypeEmptyBodyTest` with 3 test cases:
     - `testNoContentTypeOnEmptyBody` - verifies no Content-Type on null-body 
response
     - `testContentTypeSetOnNonEmptyBody` - verifies `application/json` set on 
response with body
     - `testContentTypeJsonWhenMultiValueProduces` - verifies 
`application/json` (not multi-value) when `produces` contains multiple media 
types
   - [x] All existing `FromRest*` tests pass (35 tests, 0 failures)
   - [x] Full `camel-core` test suite passes (7264 tests, 0 failures)
   - [x] Full reactor build succeeds
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   Co-Authored-By: Claude Opus 4.6 <[email protected]>


-- 
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