dio icon indicating copy to clipboard operation
dio copied to clipboard

Mismatching `Content-Type` header value with Dio options' `ResponseType`.

Open bambinoua opened this issue 3 years ago • 1 comments

It seems there is a bug in transformResponse method of class DefaultTransformer (or somewhere deeper).

I use external API which returns token as JSON String, i.e. the result is:

""ZXlKaGJHY2lPa...""

And because dio consider this response as ResponseType.plain instead of ResponseType.json (but it is a JSON) it does not decode those JSON String to regular String.

dio_bug

As you may notice on image the Content-Type of HTTP response is application/json but internal options.responseType is not ResponseType.json which is requried for calling json.decode method.

Dio version 4.0.6 Flutter version: 3.0.5

bambinoua avatar Aug 01 '22 09:08 bambinoua

And please stop forcing the lower case on headers!

jhionan avatar Aug 18 '22 13:08 jhionan