diff options
author | nat-goodspeed <nat@lindenlab.com> | 2018-12-20 09:39:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-20 09:39:08 -0500 |
commit | 551580928797e00a94d56e0280cbdf4a33bdeea5 (patch) | |
tree | ccead3ed43a964545e2c6446b90c35078a2d19f1 | |
parent | b80ec5f0e09b6b1965b68f4c3fafb36ebbd876e9 (diff) | |
download | eventlet-551580928797e00a94d56e0280cbdf4a33bdeea5.tar.gz |
Issue 535: use Python 2 compatible syntax for keyword-only args. (#536)
* Issue #535: use Python 2 compatible syntax for keyword-only args.
* Validate that encode_chunked is the *only* keyword argument passed.
-rw-r--r-- | eventlet/green/http/client.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/eventlet/green/http/client.py b/eventlet/green/http/client.py index 07ebccf..e4bd2ad 100644 --- a/eventlet/green/http/client.py +++ b/eventlet/green/http/client.py @@ -1281,22 +1281,32 @@ class HTTPConnection: header = header + b': ' + value self._output(header) - def endheaders(self, message_body=None, *, encode_chunked=False): + def endheaders(self, message_body=None, **kwds): """Indicate that the last header line has been sent to the server. This method sends the request to the server. The optional message_body argument can be used to pass a message body associated with the request. """ + encode_chunked = kwds.pop('encode_chunked', False) + if kwds: + # mimic interpreter error for unrecognized keyword + raise TypeError("endheaders() got an unexpected keyword argument '{0}'" + .format(kwds.popitem()[0])) + if self.__state == _CS_REQ_STARTED: self.__state = _CS_REQ_SENT else: raise CannotSendHeader() self._send_output(message_body, encode_chunked=encode_chunked) - def request(self, method, url, body=None, headers={}, *, - encode_chunked=False): + def request(self, method, url, body=None, headers={}, **kwds): """Send a complete request to the server.""" + encode_chunked = kwds.pop('encode_chunked', False) + if kwds: + # mimic interpreter error for unrecognized keyword + raise TypeError("request() got an unexpected keyword argument '{0}'" + .format(kwds.popitem()[0])) self._send_request(method, url, body, headers, encode_chunked) def _set_content_length(self, body, method): |