WebClient: Explicit Content-Type application/octet-stream is overwritten #33303
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: waiting-for-triage
An issue we've not yet triaged or decided on
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: