diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2016-02-06 10:07:43 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2016-02-06 10:07:43 -0500 |
commit | 40dbf22a89aee46b180514d360ebedc592c5b80b (patch) | |
tree | a2732d83e8b94bdf6f81051ee693d95f11682113 | |
parent | cf8169f3426f444caadcf05302248de5639e065e (diff) | |
download | cherrypy-40dbf22a89aee46b180514d360ebedc592c5b80b.tar.gz |
Remove a hacky monkeypatch. Replace with a simple decoding of the URL on Python 3.
-rw-r--r-- | cherrypy/test/webtest.py | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/cherrypy/test/webtest.py b/cherrypy/test/webtest.py index b738d7f2..fc3cab49 100644 --- a/cherrypy/test/webtest.py +++ b/cherrypy/test/webtest.py @@ -510,38 +510,11 @@ def openURL(url, headers=None, method="GET", body=None, conn._http_vsn_str = protocol conn._http_vsn = int("".join([x for x in protocol if x.isdigit()])) - if not py3k: - conn.putrequest(method.upper(), url, skip_host=True, - skip_accept_encoding=True) - else: - import http.client - # Replace the stdlib method, which only accepts ASCII url's - - def putrequest(self, method, url): - if ( - self._HTTPConnection__response and - self._HTTPConnection__response.isclosed() - ): - self._HTTPConnection__response = None - - if self._HTTPConnection__state == http.client._CS_IDLE: - self._HTTPConnection__state = ( - http.client._CS_REQ_STARTED) - else: - raise http.client.CannotSendRequest() - - self._method = method - if not url: - url = ntob('/') - request = ntob(' ').join( - (method.encode("ASCII"), - url, - self._http_vsn_str.encode("ASCII"))) - self._output(request) - import types - conn.putrequest = types.MethodType(putrequest, conn) - - conn.putrequest(method.upper(), url) + if py3k and isinstance(url, bytes): + url = url.decode() + + conn.putrequest(method.upper(), url, skip_host=True, + skip_accept_encoding=True) for key, value in headers: conn.putheader(key, value.encode("Latin-1")) |