Skip to content

Commit

Permalink
Merge pull request #248 from ably/respect-content-type-values-that-in…
Browse files Browse the repository at this point in the history
…clude-a-charset

Respect content-type with charset
  • Loading branch information
tomkirbygreen authored Feb 24, 2022
2 parents d50b616 + 5502f1d commit eef6f9c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ably/http/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ def to_native(self):
return None

content_type = self.__response.headers.get('content-type')
if content_type == 'application/x-msgpack':
return msgpack.unpackb(content)
elif content_type == 'application/json':
return self.__response.json()
else:
raise ValueError("Unsupported content type")
if isinstance(content_type, str):
if content_type.startswith('application/x-msgpack'):
return msgpack.unpackb(content)
elif content_type.startswith('application/json'):
return self.__response.json()

raise ValueError("Unsupported content type")

@property
def response(self):
Expand Down

0 comments on commit eef6f9c

Please sign in to comment.