Skip to content

Conversation

@kevsta89
Copy link

@kevsta89 kevsta89 commented Apr 4, 2019

The object edata is a string and when this is sent using 'r = requests.post(url=self._url, data=edata)' no content-type is sent by requests to the receiving web service. If a dict object was set instead requests would detect this and automatically apply a content-type.

This change checks if edata can be decoded as json and if it can adds appropriate header with content-type. If not it still adds a content-type to make the request more robust for the receiving server.

Prior to this change requests was seeing the status_code as a 500, even though it wasn't, because the reply from the web service had no content-type in the header since it didn't know what content-type it had received.

kevsta89 added 2 commits April 4, 2019 10:42
The object edata is a string and when this is sent using 'r = requests.post(url=self._url, data=edata)' no content-type is sent by requests to the receiving web service. If a dict object was set instead requests would detect this and automatically apply a content-type.

This change checks if edata can be decoded as json and if it can adds appropriate header with content-type. If not it still adds a content-type to make the request more robust for the receiving server.

Prior to this change requests was seeing the status_code as a 500, even though it wasn't, because the reply from the web service had no content-type in the header since it didn't know what content-type it had received.
@josegonzalez
Copy link
Member

Do you mind taking a look at why tests are failing?

@kevsta89
Copy link
Author

kevsta89 commented Apr 4, 2019

Do you mind taking a look at why tests are failing?

Hi Jose

It looks like you've got a problem in the master branch? I see your last Travis CI tests also failed with the exact same messages as my tests (which were unrelated to my proposed changes) - https://travis-ci.org/python-beaver/python-beaver/builds/515298209

@josegonzalez
Copy link
Member

Yeah, just asking in case you have time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants