Skip to content

Commit 539390f

Browse files
committed
Revert "An empty string doesn't work around the 411 issue on PUTs. Use 'PLACEHOLDER'"
This reverts commit b488b84. requests now seems to do the right thing (2.3.0). And GitHub rejects bodies that don't validate as JSON.
1 parent 3213858 commit 539390f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pygithub3/services/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ def _patch(self, request, **kwargs):
111111
def _put(self, request, **kwargs):
112112
""" Bug in Github API? requests library?
113113
114-
I must send data when the specifications' of some PUT request are 'Not
115-
send input data'. If I don't do that and send data as None, the
116-
requests library doesn't send 'Content-length' header and the server
117-
returns 411 - Required Content length (at least 0)
114+
I must send data as empty string when the specifications' of some PUT
115+
request are 'Not send input data'. If I don't do that and send data as
116+
None, the requests library doesn't send 'Content-length' header and the
117+
server returns 411 - Required Content length (at least 0)
118118
119119
For instance:
120120
- follow-user request doesn't send input data
@@ -125,7 +125,7 @@ def _put(self, request, **kwargs):
125125
126126
Related: https://github.com/github/developer.github.com/pull/52
127127
"""
128-
input_data = request.get_body() or 'PLACEHOLDER'
128+
input_data = request.get_body() or ''
129129
response = self._client.put(request, data=input_data, **kwargs)
130130
if response.status_code != 204: # != NO_CONTENT
131131
return request.resource.loads(response.content)

pygithub3/tests/services/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_BOOL(self, request_method):
2828

2929
def test_PUT(self, request_method):
3030
self.s._put(self.r, **self.args)
31-
data = 'PLACEHOLDER' # See _put
31+
data = '' # See _put
3232
request_method.assert_called_with('put', _('dummyrequest'),
3333
data=data, params=self.args)
3434

0 commit comments

Comments
 (0)