This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rugk
Recipients rugk
Date 2016-06-11.14:03:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465653841.12.0.169767702558.issue27296@psf.upfronthosting.co.za>
In-reply-to
Content
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...
History
Date User Action Args
2016-06-11 14:04:01rugksetrecipients: + rugk
2016-06-11 14:04:01rugksetmessageid: <1465653841.12.0.169767702558.issue27296@psf.upfronthosting.co.za>
2016-06-11 14:04:01rugklinkissue27296 messages
2016-06-11 14:03:59rugkcreate