-
Notifications
You must be signed in to change notification settings - Fork 38.5k
WebClient: Explicit Content-Type application/octet-stream is overwritten #33303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@bclozel |
Sorry for the delayed feedback. I'm not sure we can support this specific use case without undoing the mime type detection, which is widely used. I think Have you considered using a custom media type like |
That does work in my case but it still seems unfortunate to have to do that. Would it not be acceptable to you to have the setter set a flag to indicate that it was called, making the choice of the content-type explicit? I understand that mime type detection is a helpful feature, but if the setter is called on the builder, surely the user did not want that choice to be overridden? |
Thanks for the proposal, but I think we're going to stick with the current behavior. The |
Affected version: 6.1.11
The API I'm consuming requires the Content-Type header to be
application/octet-stream
for certain binary payloads.The Content-Type is set explicitly using
RequestBodySpec.contentType()
but it is later overwritten in this method:spring-framework/spring-web/src/main/java/org/springframework/http/codec/ResourceHttpMessageWriter.java
Lines 165 to 176 in 29dce74
This is unintuitive behaviour and not configurable. To circumvent this, I have to rename the file to an extension not present in spring-web/src/main/resources/org/springframework/http/mime.types so my explicitly set header is respected.
To reproduce, here is a function that sets the content type of the request:
Resulting request using netcat:
Expected result:
Thanks
The text was updated successfully, but these errors were encountered: