Skip to content

Commit b488b84

Browse files
committed
An empty string doesn't work around the 411 issue on PUTs. Use 'PLACEHOLDER'
1 parent 5fa7037 commit b488b84

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
@@ -105,10 +105,10 @@ def _patch(self, request, **kwargs):
105105
def _put(self, request, **kwargs):
106106
""" Bug in Github API? requests library?
107107
108-
I must send data as empty string when the specifications' of some PUT
109-
request are 'Not send input data'. If I don't do that and send data as
110-
None, the requests library doesn't send 'Content-length' header and the
111-
server returns 411 - Required Content length (at least 0)
108+
I must send data when the specifications' of some PUT request are 'Not
109+
send input data'. If I don't do that and send data as None, the
110+
requests library doesn't send 'Content-length' header and the server
111+
returns 411 - Required Content length (at least 0)
112112
113113
For instance:
114114
- follow-user request doesn't send input data
@@ -119,7 +119,7 @@ def _put(self, request, **kwargs):
119119
120120
Related: https://github.com/github/developer.github.com/pull/52
121121
"""
122-
input_data = request.get_body() or ''
122+
input_data = request.get_body() or 'PLACEHOLDER'
123123
response = self._client.put(request, data=input_data, **kwargs)
124124
if response.status_code != 204: # != NO_CONTENT
125125
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
@@ -27,7 +27,7 @@ def test_BOOL(self, request_method):
2727

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

0 commit comments

Comments
 (0)