diff options
author | 2012-02-06 21:35:33 +0100 | |
---|---|---|
committer | 2012-02-06 21:35:33 +0100 | |
commit | 91d3f4100083838218447497fad8107aa0970c94 (patch) | |
tree | fc8841ac4215047a886f6c499ccb0d188cec8cae | |
parent | Rename ghrequest to requests (diff) | |
download | python-github3-91d3f4100083838218447497fad8107aa0970c94.tar.xz python-github3-91d3f4100083838218447497fad8107aa0970c94.zip |
Something confusing about PUT request
It's solved as a provisional patch
Diffstat (limited to '')
-rw-r--r-- | pygithub3/core/client.py | 7 | ||||
-rw-r--r-- | pygithub3/services/base.py | 22 |
2 files changed, 23 insertions, 6 deletions
diff --git a/pygithub3/core/client.py b/pygithub3/core/client.py index bfb8416..866d40a 100644 --- a/pygithub3/core/client.py +++ b/pygithub3/core/client.py @@ -95,12 +95,9 @@ class Client(object): return response def put(self, request, **kwargs): - # TODO: Search info about this (bug in requests? in api? me?) - incoming_headers = kwargs.get('headers', {}) - incoming_headers.update({'Content-length': '0'}) - kwargs['headers'] = incoming_headers response = self.request('put', request, **kwargs) - assert response.status_code != '204' + # assert response.status_code != '204' + # I don't do an assert. See `services.base.Base._put` comment return response def delete(self, request, **kwargs): diff --git a/pygithub3/services/base.py b/pygithub3/services/base.py index 960912a..1ade763 100644 --- a/pygithub3/services/base.py +++ b/pygithub3/services/base.py @@ -45,7 +45,27 @@ class Base(object): def _put(self, request_uri, **kwargs): request = self.get_request(request_uri) - self.client.put(request, **kwargs) + resource = request.get_resource() + """ Bug in Github API? requests library? + + I must send data as empty string when the specifications' of some PUT + request are 'Not send input data'. If I don't do that and send data as + None, the requests library doesn't send 'Content-length' header and the + server returns 411 - Required Content length (at least 0) + + For instance: + - follow-user request doesn't send input data + - merge-pull request send data + + For that reason I must do a conditional because I don't want to return + an empty string on follow-user request because it could be confused + + Related: ht + """ + input_data = request.get_data() or '' + response = self.client.put(request, data=input_data, **kwargs) + if response.status_code != '204': # != NO_CONTENT + return resource.loads(response.content) def _delete(self, request_uri, **kwargs): request = self.get_request(request_uri) |