Fuel: jsonBody does not replace default content encoding

Created on 18 Oct 2018  路  3Comments  路  Source: kittinunf/fuel

Bug Report

Description

when POST-ing a json body the generated request contains both of these headers

Content-Type : application/x-www-form-urlencoded
content-type : application/json

because of https://github.com/kittinunf/Fuel/blob/master/fuel/src/main/kotlin/com/github/kittinunf/fuel/core/Request.kt#L149

To Reproduce

Steps to reproduce the behavior:

val curl = Fuel.post("https://someurl.com")
            .jsonBody(body = "{}")
            .cUrlString()
println(curl)

Expected behavior

the POST request should have only one Content-Type

bug

All 3 comments

Correct. @markGilchrist I want to change the behaviour so that:

  • headers that only allow one value (things like Date, Content-Type, Content-Language, Expires) don't concat
  • defaults set by us are either "only set if not already set" or "always overwritten when the header is processed/used/changed"

for now #474 fixes it without a complete rewrite of headers, but it would break if somone sets a Content type and then calls jsonBody
but it should be obvious to users that it will break

This is the same issue as #472.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Querschlag picture Querschlag  路  5Comments

Xianyang picture Xianyang  路  4Comments

iNoles picture iNoles  路  5Comments

georg-jung picture georg-jung  路  6Comments

IvanKulikov picture IvanKulikov  路  5Comments