New submission from rugk: Test file: https://gist.github.com/rugk/3ea35d04d66c2295e02d0b6cb6d822a2 Python version: 2.7.5+
Issue description: When Urllib gets a HTTP header with line breaks/new line characters it shows the following error: ``` Traceback (most recent call last): File "./downloadtest.py", line 17, in <module> respdata = resp.read() File "/usr/lib/python2.7/socket.py", line 351, in read data = self._sock.recv(rbufsize) File "/usr/lib/python2.7/httplib.py", line 543, in read return self._read_chunked(amt) File "/usr/lib/python2.7/httplib.py", line 597, in _read_chunked raise IncompleteRead(''.join(value)) httplib.IncompleteRead: IncompleteRead(0 bytes read) ``` Compare the results with curl... # Broken version ## curl ``` $curl -i https://rugk.dedyn.io/pythontest/bug HTTP/1.1 200 OK Server: nginx Date: Sat, 11 Jun 2016 13:34:36 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: keep-alive Strict-Transport-Security: max-age=15768000; includeSubDomains; preload Public-Key-Pins: pin-sha256="306cc4Cc2py0x48ZiX2G5vt5OxF9afmouqccrFqb8Jc="; pin-sha256="dWkVtg0EuckExnceVFvu3tuEApEygbxr2FPTlpHAUrQ="; pin-sha256="DjjVxb2/6kxfX8qyP2TE/j8B0tOB60MhTTvJdNsFPaU="; max-age=5184000; includeSubDomains; report-uri="https://rugkdyndns.report-uri.io/r/default/hpkp/enforce" Bug: ``` ## python ``` $ ./downloadtest.py https://rugk.dedyn.io/pythontest/bug Accessing https://rugk.dedyn.io/pythontest/bug... Traceback (most recent call last): File "./downloadtest.py", line 17, in <module> respdata = resp.read() File "/usr/lib/python2.7/socket.py", line 351, in read data = self._sock.recv(rbufsize) File "/usr/lib/python2.7/httplib.py", line 543, in read return self._read_chunked(amt) File "/usr/lib/python2.7/httplib.py", line 597, in _read_chunked raise IncompleteRead(''.join(value)) httplib.IncompleteRead: IncompleteRead(0 bytes read) ``` # working version ## curl ``` $ curl -i https://rugk.dedyn.io/pythontest/works HTTP/1.1 200 OK Server: nginx Date: Sat, 11 Jun 2016 13:46:09 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: keep-alive Strict-Transport-Security: max-age=15768000; includeSubDomains; preload Public-Key-Pins: pin-sha256="306cc4Cc2py0x48ZiX2G5vt5OxF9afmouqccrFqb8Jc="; pin-sha256="dWkVtg0EuckExnceVFvu3tuEApEygbxr2FPTlpHAUrQ="; pin-sha256="DjjVxb2/6kxfX8qyP2TE/j8B0tOB60MhTTvJdNsFPaU="; max-age=5184000; includeSubDomains; report-uri="https://rugkdyndns.report-uri.io/r/default/hpkp/enforce" Bug: ``` ## python ``` $ ./downloadtest.py https://rugk.dedyn.io/pythontest/works Accessing https://rugk.dedyn.io/pythontest/works... RAW: Bug: Decoded: Bug: ``` You can also test it with HTTP URLs and get the same result. In usual browsers every request works... I cannot guarantee that the test server will stay available... ---------- components: Library (Lib) messages: 268212 nosy: rugk priority: normal severity: normal status: open title: Urllib/Urlopen IncompleteRead with HTTP header with new line characters type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27296> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com