You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Otavio Rodolfo Piske (Jira)" <ji...@apache.org> on 2023/06/27 15:58:00 UTC
[jira] [Updated] (CAMEL-19500) HttpMessage#getBody(Map.class) doesn't parse the regular web form POST
[ https://issues.apache.org/jira/browse/CAMEL-19500?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Otavio Rodolfo Piske updated CAMEL-19500:
-----------------------------------------
Estimated Complexity: Moderate (was: Unknown)
> HttpMessage#getBody(Map.class) doesn't parse the regular web form POST
> ----------------------------------------------------------------------
>
> Key: CAMEL-19500
> URL: https://issues.apache.org/jira/browse/CAMEL-19500
> Project: Camel
> Issue Type: Bug
> Components: camel-jetty, core
> Affects Versions: 3.20.4
> Environment: $ lsb_release -d
> Description: Ubuntu 22.04.2 LTS
> $ java --version
> openjdk 19.0.1 2022-10-18
> OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 19.0.1+10-jvmci-22.3-b08)
> OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 19.0.1+10-jvmci-22.3-b08, mixed mode, sharing)
> Reporter: Fyodor Kravchenko
> Priority: Minor
> Fix For: 3.x
>
>
> In Camel 2, when the form was submitted, the payload was able to be presented as a {{java.util.Map}} like this:
>
> {code:java}
> Map map = httpMessage.getBody(Map.class);{code}
> In Camel 3.20.4 this doesn't work.
>
> I've created a [little github project|https://github.com/fedd/cameljettyformmap/tree/main/cameljettyformmap] to demonstrate and reproduce the error. In the project's [{{pom.xml}}|https://github.com/fedd/cameljettyformmap/blob/main/cameljettyformmap/pom.xml] file you can easily switch the Camel versions to see how version 2.24.0 behaves as expected in a true Camel manner, and 3.20.4 does not.
> In essence, the code to check the behavior is like below. {{form.html}} is a simplest POST web form.
> {code:java}
> HttpMessage http = exchange.getIn(HttpMessage.class);
> HttpServletRequest request = http.getRequest();
> String method = request.getMethod();
> if ("POST".equals(method) || "PUT".equals(method)) {
> Map map = http.getBody(Map.class);
> String string = http.getBody(String.class);
> http.setHeader(Exchange.CONTENT_TYPE, "text/plain");
> http.setBody("json: " + mapper.writeValueAsString(map) + ", and string:" + string);
> } else {
> http.setHeader(Exchange.CONTENT_TYPE, "text/html");
> http.setBody(this.getClass().getResourceAsStream("form.html"));
> }
> {code}
> It should print the jsonified form POST payload, but doesn't for the Camel 3.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)