Skip to content

Commit

Permalink
stop returning empty dict when request has zero content-length
Browse files Browse the repository at this point in the history
  • Loading branch information
olucurious committed Jun 2, 2017
1 parent f43b9ae commit 39f112f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyfcm/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__summary__ = 'Python client for FCM - Firebase Cloud Messaging (Android & iOS)..'
__url__ = 'https://github.com/olucurious/pyfcm'

__version__ = '1.3.1'
__version__ = '1.3.2'

__install_requires__ = ['requests', 'requests-toolbelt']

Expand Down
32 changes: 16 additions & 16 deletions pyfcm/baseapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,23 @@ def parse_responses(self):
Returns a python dict of multicast_id(long), success(int), failure(int), canonical_ids(int), results(list)
"""
if 'content-length' in response.headers and int(response.headers['content-length']) <= 0:
return {}

parsed_response = response.json()
response_list.append({})
else:
parsed_response = response.json()

multicast_id = parsed_response.get('multicast_id', None)
success = parsed_response.get('success', 0)
failure = parsed_response.get('failure', 0)
canonical_ids = parsed_response.get('canonical_ids', 0)
results = parsed_response.get('results', [])
message_id = parsed_response.get('message_id', None) # for topic messages
if message_id:
success = 1
response_list.append({'multicast_id': multicast_id,
'success': success,
'failure': failure,
'canonical_ids': canonical_ids,
'results': results})
multicast_id = parsed_response.get('multicast_id', None)
success = parsed_response.get('success', 0)
failure = parsed_response.get('failure', 0)
canonical_ids = parsed_response.get('canonical_ids', 0)
results = parsed_response.get('results', [])
message_id = parsed_response.get('message_id', None) # for topic messages
if message_id:
success = 1
response_list.append({'multicast_id': multicast_id,
'success': success,
'failure': failure,
'canonical_ids': canonical_ids,
'results': results})
elif response.status_code == 401:
raise AuthenticationError("There was an error authenticating the sender account")
elif response.status_code == 400:
Expand Down

0 comments on commit 39f112f

Please sign in to comment.