Don't try to parse responses without any data (fixes #513)

This PR fixes #513 by not trying to parse responses that don't contain any data (e.g. error responses, responses for PUT and DELETE requests).

There are also two minor refactorings. If those make the reviewing too hard, I can also open a separate PR for those.