Hi Erich,

I assume you mixed client/server behaviour.

The client fetchtes the data from server. Normally it uses the Accept Header to 
tell the client which data format will be accepted.
The server sends the data with the content-type header.

For example: When the client ask for data with:
Accept: application/json application/text

The server answers with
Content-Type: application/json

In this case the client knows that the data are json encoded and not xml.

When you using a POST request the client sends data. In this case the 
content-tpye header must be set otherwise the server does not know about the 
data format and need a method which handles the request.

Cheers,
Markus

> Gesendet: Dienstag, 10. Januar 2023 um 19:36 Uhr
> Von: "Erich Mauerböck" <[email protected]>
> An: [email protected]
> Betreff: Injected null Content-Type header?
>
> Hi,
> 
> I am using CXF 3.5.5 as JAXRS implementation. Today I got a null 
> Content-Type header injected via the following code:
> 
> @GET
> public void someMethod(@Context HttpHeaders headers) {
>    ...
> }
> 
> Calling this method without a Content-Type header (which makes no sense 
> with a GET request) did the following:
> While headers.getMediaType() returned null as expected, I was also 
> expecting headers.getRequestHeaders().get("Content-Type") to return 
> null, but actually I got a List with one String element being null. May 
> this be a bug?
> 
> BR
> Erich.
>

Reply via email to