You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by COURTAULT Francois <fr...@thalesgroup.com.INVALID> on 2023/03/17 10:46:48 UTC

Method annotated with @GET questions

Hello everyone,

Is it relevant to annotate a @GET method with @Consumes knowing that it's not advised to have a payload for HTTP GET request even if it is not forbidden by the specification if I have well understood  ?

I ask this question because I have performed some tests with TomEE 8.0.14 and I am a little bit surprised.
Indeed I have annotated an @GET method with @Consumes ( { MediaType.TEXT_PLAIN}).
Then I sent a GET request using curl with a Content-Type set to application/json.
I was expecting  to get a 415 but in fact everything worked fine.

Does it means that there is no check  between the Content-Type value and the @Consumes media types for HTTP GET methods ?
meaning that @Consumes for HTTP GET methods is useless ?

Best Regards.




Re: Method annotated with @GET questions

Posted by Jean-Louis Monteiro <jl...@tomitribe.com>.
First your understanding is aligned with mine. Sending payloads with the
GET method is discouraged but not forbidden. I have seen some cases in my
career.

Now concretely with TomEE, I'd need to double check CXF resolution. This
piece of code is a bit complex, but I would not be surprised if it would
ignore the content-type as it's not expecting any content.

--
Jean-Louis Monteiro
http://twitter.com/jlouismonteiro
http://www.tomitribe.com


On Fri, Mar 17, 2023 at 11:47 AM COURTAULT Francois
<fr...@thalesgroup.com.invalid> wrote:

> Hello everyone,
>
> Is it relevant to annotate a @GET method with @Consumes knowing that it's
> not advised to have a payload for HTTP GET request even if it is not
> forbidden by the specification if I have well understood  ?
>
> I ask this question because I have performed some tests with TomEE 8.0.14
> and I am a little bit surprised.
> Indeed I have annotated an @GET method with @Consumes ( {
> MediaType.TEXT_PLAIN}).
> Then I sent a GET request using curl with a Content-Type set to
> application/json.
> I was expecting  to get a 415 but in fact everything worked fine.
>
> Does it means that there is no check  between the Content-Type value and
> the @Consumes media types for HTTP GET methods ?
> meaning that @Consumes for HTTP GET methods is useless ?
>
> Best Regards.
>
>
>
>