Open mroloux opened 6 years ago
I tested that setting response.type("")
successfully removes the header in Spark versions 2.6.0 and 2.7.0 and 2.7.1. In only stopped working in version 2.7.2.
So as a workaround I reverted to version 2.7.1 for now.
Thanks for the suggestion. I remained on 2.5.5 for now, but I hope a future Spark version will allow sending responses without a content type again.
Any news on this? Can't upgrade to the new and shiny 2.8.0 because of this 😞
Same problem here. It would be great to have a fix for this.
After upgrading from Spark 2.5.5 to 2.7.2, I'm not able to send a 204 response without a content-type header anymore. This worked fine in 2.5.5
The controller code looks like this:
response.status(204);
response.type("");
return "";
The cause seems to be the following:
Spark 2.5.5 came with Jetty 9.3. In that Jetty version, headers that are empty strings or null are omitted from the response. That has changed with Jetty 9.4 (which is included in Spark 2.7.2): headers with empty strings are included as is in the responses.
response.type(null)
would be a solution, butspark.http.matching.Body.seralizeTo()
replaces null content types withtext/html; charset=utf-8
. Some HTTP clients don't like this. E.g. Jersey errors out when it receives a response that has a content type header but no body.Any advice on how to proceed?