Scorpiion / vane

Server-side framework for Dart/Dartlang with a built-in middleware system.
BSD 3-Clause "New" or "Revised" License
59 stars 11 forks source link

Handle empty json POSTs #21

Closed Scorpiion closed 7 years ago

Scorpiion commented 8 years ago

Right now I think we get an error if the user tries to send a empty POST request with the content type set to json. While the correct thing might still be not to set content type to json for a request without any body, it still can create hard to figure out bugs when you API changes and you acccidentlity leave the json header but remove the body.

Example:

var response = await _client.post('$_backend/orgs/$org_id/pools/$pool_id/services/mongodbs/$service_id/databases/$database_name',
                                   headers: {"Content-type": "application/json"});

Solution: In the parsing of the json variable we could check for an empty body and if so don't try to parse the empty body as json.

Scorpiion commented 7 years ago

Fixed.