Hi,

no, I didn't. I was referring to the request only. Forget about the response by now. By setting the content-type header in a request, the client tells the server what type of data it wants to send in the body. As I am using a GET request, no such header needs to be present, so I omit it. However my mentioned server side code actually gives me such a header via injected HttpHeaders object, but it has a null value.

Cheers,
Erich.

Am 2023-01-11 15:17, schrieb [email protected]:
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