SiftScience / sift-python

Sift API (Python client)
MIT License
20 stars 23 forks source link

Transfer-Encodings other than Content-Length result in empty response. #45

Closed brenns10 closed 8 years ago

brenns10 commented 8 years ago

When a Response object is created, the client expects a Content-Length header in order to fill in details such as the body and api_status. However not all HTTP requests/responses have Content-Length headers. Some API responses from Sift (but not all, it's nondeterministic, but seems related to payload size) use Transfer-Encoding: chunked and thus have no Content-Length header. This results in a response that has a http_status_code of 200, but no api_status or body. This can be fixed by checking the truthiness of the http_response.text attribute, since it will be falsey if there is no body.

Pull request incoming for this issue :)