Skip to content

Commit

Permalink
Don't die when we get empty bodies, which happens with 304s.
Browse files Browse the repository at this point in the history
  • Loading branch information
ieure committed Sep 21, 2011
1 parent 4bc3f7b commit 33ec39e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion simplegeo/places/places_12.py
Expand Up @@ -20,6 +20,10 @@ class Response(dict):
"""A response object which encapsulates headers & body."""

def __init__(self, body, headers):
try:
body = json_decode(body)
except DecodeError:
body = {}
dict.__init__(self, body)
self.headers = headers

Expand All @@ -40,7 +44,7 @@ def __init__(self, key, secret, **kwargs):

def _respond(self, headers, response):
"""Return the correct structure for this response."""
return Response(json_decode(response), headers)
return Response(response, headers)

def get_feature(self, place_id):
"""Return the GeoJSON representation of a feature."""
Expand Down

0 comments on commit 33ec39e

Please sign in to comment.