]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Handle empty body
authorJanez Troha <dz0ny@users.noreply.github.com>
Wed, 2 Dec 2015 11:22:57 +0000 (12:22 +0100)
committerKevin McCarthy <me@kevinmccarthy.org>
Sun, 2 Oct 2016 20:24:38 +0000 (10:24 -1000)
vcr/matchers.py

index b54ed2fbea198dbea59c4f3f74334abec440df24..8fe334e49768a73572c4f24ff444400d8e316bef 100644 (file)
@@ -49,7 +49,8 @@ def _transform_json(body):
     # Request body is always a byte string, but json.loads() wants a text
     # string. RFC 7159 says the default encoding is UTF-8 (although UTF-16
     # and UTF-32 are also allowed: hmmmmm).
-    return json.loads(body.decode('utf-8'))
+    if body:
+        return json.loads(body.decode('utf-8'))
 
 
 _xml_header_checker = _header_checker('text/xml')