playframework / play-ws

Standalone Play WS, an async HTTP client with fluent API
https://www.playframework.com/documentation/latest/JavaWS
Apache License 2.0
223 stars 86 forks source link

Can't override `Content-Type` once it's set #158

Open ignasi35 opened 7 years ago

ignasi35 commented 7 years ago

When the body of a request is set the Content-Type header is derived from the actual payload. Once set, the Content-Type can't be overriden.

See https://github.com/playframework/play-ws/commit/b7059c90a504335723c8e7c6621ffece2b792fa1#diff-4314f1bc7ecca562239ccbdaf002c36cR77

This is preventing advanced users from managing the serialization themselves, then provide (e.g.) a ByteString and finally set the the Content-Type manually. That is the case of Lagom.

wsargent commented 7 years ago

This is because withBody also sets the content type, and there were issues with content-type being set out of order.

wsargent commented 7 years ago

So the original rationale was repeated content types:

And then there's been reworking of the logic when handling typed bodies with content types.