lorien / test_server

Server to test HTTP clients
MIT License
4 stars 2 forks source link

Different request['url'] on py2 and py3 if null byte in the URI #13

Closed lorien closed 2 years ago

lorien commented 6 years ago

GET /\x00/ py2: /\x00/ py3: /%00/

jayvdb commented 4 years ago

This is the cause of a test failure on Python 2

[   79s] _______________________________ test_null_bytes ________________________________
[   79s] test/server.py:276: in test_null_bytes
[   79s]     res = urlopen(server.get_url())
[   79s] /usr/lib64/python2.7/urllib2.py:154: in urlopen
[   79s]     return opener.open(url, data, timeout)
[   79s] /usr/lib64/python2.7/urllib2.py:435: in open
[   79s]     response = meth(req, response)
[   79s] /usr/lib64/python2.7/urllib2.py:548: in http_response
[   79s]     'http', request, response, code, msg, hdrs)
[   79s] /usr/lib64/python2.7/urllib2.py:467: in error
[   79s]     result = self._call_chain(*args)
[   79s] /usr/lib64/python2.7/urllib2.py:407: in _call_chain
[   79s]     result = func(*args)
[   79s] /usr/lib64/python2.7/urllib2.py:654: in http_error_302
[   79s]     return self.parent.open(new, timeout=req.timeout)
[   79s] /usr/lib64/python2.7/urllib2.py:429: in open
[   79s]     response = self._open(req, data)
[   79s] /usr/lib64/python2.7/urllib2.py:447: in _open
[   79s]     '_open', req)
[   79s] /usr/lib64/python2.7/urllib2.py:407: in _call_chain
[   79s]     result = func(*args)
[   79s] /usr/lib64/python2.7/urllib2.py:1228: in http_open
[   79s]     return self.do_open(httplib.HTTPConnection, req)
[   79s] /usr/lib64/python2.7/urllib2.py:1195: in do_open
[   79s]     h.request(req.get_method(), req.get_selector(), req.data, headers)
[   79s] /usr/lib64/python2.7/httplib.py:1069: in request
[   79s]     self._send_request(method, url, body, headers)
[   79s] /usr/lib64/python2.7/httplib.py:1103: in _send_request
[   79s]     self.putrequest(method, url, **skips)
[   79s] /usr/lib64/python2.7/httplib.py:940: in putrequest
[   79s]     self._validate_path(url)
[   79s] /usr/lib64/python2.7/httplib.py:1030: in _validate_path
[   79s]     raise InvalidURL(msg)
[   79s] E   InvalidURL: URL can't contain control characters. '/\x00/' (found at least '\x00')
lorien commented 2 years ago

Closing this. Python 2 support will be dropped in next release of test server.