You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in some cases the request was made with Content-Type: application/octet-stream instead of application/pdf.
Apparently the RessourceHttpMessageWriter will set the Content-Type Header based on the resources filename overwriting the explicitly set contentType on the Request in ResourceHttpMessageWriter.writeResource.
rstoyanchev
changed the title
WebClient explicit Content-Type Header is overwritten by ResourceHttpMessageWriter
Explicit Content-Type Header in WebClient is overwritten by ResourceHttpMessageWriter
Jan 16, 2020
I discovered this on spring-boot 2.1 I can reproduce the same behaviour using spring-boot 2.2.2.
I'm trying to post binary Content with a specified Content-Type Header using WebClient:
in some cases the request was made with
Content-Type: application/octet-stream
instead ofapplication/pdf
.Apparently the RessourceHttpMessageWriter will set the Content-Type Header based on the resources filename overwriting the explicitly set contentType on the Request in ResourceHttpMessageWriter.writeResource.
See https://github.com/hgarus/webclient-content-type-example/blob/master/src/test/java/com/example/demo/WebClientContentTypeTest.java for a minimal testcase.
The text was updated successfully, but these errors were encountered: