You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2025/04/28 09:05:00 UTC

[jira] [Resolved] (CAMEL-22020) platform-http - Error in clientRequestValidation consumes & produces when plus sign in content-type

     [ https://issues.apache.org/jira/browse/CAMEL-22020?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-22020.
---------------------------------
    Resolution: Fixed

> platform-http - Error in clientRequestValidation consumes & produces when plus sign in content-type
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-22020
>                 URL: https://issues.apache.org/jira/browse/CAMEL-22020
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-platform-http, rest
>    Affects Versions: 4.8.6, 4.11.0
>         Environment: I've tested in 3.8.x and current 3.21.x quarkus version.
>            Reporter: Oscar Gomez
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.8.7, 4.10.5, 4.12.0
>
>
> Base on topic [#camel-quarkus > platform-http error validating consumes & produces @ 💬|https://camel.zulipchat.com/#narrow/channel/257302-camel-quarkus/topic/platform-http.20error.20validating.20consumes.20.26.20produces/near/514302427]
>  Hi!
> I've tested in 3.8.x and current 3.21.x quarkus version.
> In both cases whenever you define and endpoint where you want to validate consumes or produces mime-types the validation fails if the mime-type you want to validate contains plus '+' symbol, for example 'application/fhir+json'. Retrieving a response of 406 or 415 if you add the proper one in 'Accept' and 'Content-Type' header.
> For example try to use these routes:
> {code:java}
>     @Override
>     public void configure() throws Exception {
>         restConfiguration().component("platform-http")
>             .host("localhost")
>             .port(8080)
>         ;
> 		// Using rest consumer
>         rest("/test/rest")
>             .post()
>             .routeId("Main-Route")
>             .description("Create a FHIR resource")
>             .clientRequestValidation(true)
>             .consumes("application/fhir+json") 
>             .to("direct:createResource")
>         ;
>         from("direct:createResource")
>             .routeId("Create Resource FHIR")
>             .log("Received FHIR: ${body}")
>             .setBody(simple("{'response': 'Bundle FHIR processed successfully'}"))
>             .log("Response: ${body}")
>         ;
>         // Using platform-http consumer
>         from("platform-http:/test/platform?produces=application/fhir+json&httpMethodRestrict=GET")
>             .routeId("Test Platform")
>             .log("Received FHIR JSON: ${body}")
>             .setBody(simple("{'response': 'Bundle FHIR JSON processed successfully'}"))
>             .log("Response: ${body}")
>         ;
>     }
> {code}
> Then if you try to call them, for example with 'curl' as follows:
> {code:bash}
> curl -H 'Accept: application/fhir+json' http://localhost:8080/test/platform -v
> {code}
> You will get a 406 response.
> And for POST, using 'curl':
> {code:bash}
> curl -H 'Content-Type: application/fhir+json' -X POST -d '{"resource": "Patient", ...}' http://localhost:8080/test/rest -v
> {code}
> You'll get 415 response.
> The validation works well if there is no '+' symbol in the mime-type, however I didn't make tests with other kind of symbols.
> I've also tested the behavior of Quarkus resteasy component using annotations @Consumes and @Produces for the methods dispatching requests and the behavior is correct, that's why I'm thinking the problem is in the camel implementation itself.
> There is also a workaround by surrounding the mime-types with RAW(...) function, not only in platform-http, but also in Rest DSL, as follows:
> {code:java}
> from("platform-http:/foo?consumes=RAW(application/fhir+json)")
> ...
> rest("/test")
>    .post()
>    .clientRequestValidation(true)
>    .consumes("RAW(application/fhir+json)")
> ...
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)