davsclaus opened a new pull request, #28041:
URL: https://github.com/apache/camel/pull/28041
CAMEL-25745: without the `httpMethod` option or the `CamelHttpMethod`
header, the http producer picks the method from the message body: a message
with a body is sent as a POST, a message without one as a GET. After
`unmarshal`, `split` or `setBody` the message has a body, so a call meant as a
GET is sent as a POST. This trips many users, and AI models too: in the
overnight benchmark of Oct 17-18, a step that calls a stock service for each
line of a split order failed 6 of 10 times on it. The behaviour cannot change
without breaking existing applications, so this PR makes the rule stand out.
## What
- **The http page opens its Usage section with "Which HTTP method will be
used"** (moved up from the middle of the page, with the same heading, so links
to it keep working):
- The rule as an IMPORTANT note, plus `getWithBody`.
- The order in which the method is chosen.
- Two examples in Java, XML and YAML: a GET for each line of a split order
with `httpMethod=GET`, and a POST of JSON with `httpMethod=POST`.
- `camel_catalog_doc` returns the start of a component's page, so the rule
is now in every answer about http.
- **"How to set the http method"** names the `httpMethod` option first, then
the header. Its YAML example is canonical now (`constant: POST` was the compact
form).
- **The error for a Map or List body (CAMEL-25309):** when neither the
option nor the header set the method, it now says "The call is a POST because
the message has a body and neither the httpMethod option nor the
CamelHttpMethod header sets the method: for a GET, set httpMethod GET on the
endpoint (a GET sends no body); for a POST, marshal it to JSON first". With an
explicit method the message stays as before.
The catalog copy of the page is updated.
## Checks
- The examples were run with `camel run` in all three DSLs, against a small
stub: the stock lookup arrives as a GET with a Map body in the message, and the
order arrives as a POST with JSON. The same split route without `httpMethod`
fails with the Map body error, as in the benchmark.
- `HttpProducerMapBodyTest`: the new test, and the explicit-POST test checks
that the GET advice is left out. `HttpMethodsTest` passes.
- All camel-http tests pass (297, 9 skipped, and 9 more).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
--
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]