RestRequestBuilder adds Content-Type header when it should not
rsertelon opened this issue · 5 comments
RestRequestBuilder
automatically adds a Content-Type
header with value application/json; charset=utf-8
whatever the method of the request.
This leads to browser potentially sending uneeded OPTIONS requests when CORS is used. (And, also, it shouldn't be sent).
Why the Content-Type forces an OPTIONS request ?
With a builder designed for JSON requests, I would prefer to keep this as default.
If we remove it, it might break existing code.
The problem is that the Content-Type
header is set to application/json
:) This is not listed as a safe value for this header (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS).
I don't mind having the OPTIONS request for POST, but it is also set for GET requests. Which should not. I forgot to write that it was sent with GET too, sorry.
@nmorel do you think you'll be able to have a look at pull requests soon? We'd love to have a release with those ;)
Thanks!
A version 0.5.0 should be available soon. Thanks!
(I hate so much maven-release-plugin)
As said in PR:
@nmorel I've just realised this might be flawed, sorry. I think this change makes it impossible to override content type from user side (even with @Consumes auto-detection).
Will submit a patch.