CodingAleCR / http_interceptor

A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Body is set to empty string when it should be null

s-yanev opened this issue · comments

Describe the bug
Currently when a GET request is invoked and the Request object is converted to RequestData in the RequestData.fromHttpRequest() function, even though the BODY in the Request object is null we end up with an empty string as body in the RequestData object.

This is wrong since later when the RequestData is converted back to Request object the empty string body is used and when the body is set as a String then automatically the Content-Type is set as text/plain in the headers, which is not acceptable for some APIs and leads to a 415 - Unsupported media type error. This can be checked in the http-0.13.5 package in the request.dart file in the body setter.

Expected behavior
BODY should be kept as null.

Version:

  • http_interceptor: ^1.0.2