<p dir="auto">All of the below testing was done with Fiddler. User and password proxy auth in Fiddler was enabled the default way by doing Rules-&gt;Require Proxy Authentication which requires user be '1' and password be '1'. The code below does not contain the https section of the proxy as it's largely identical.</p>
<p dir="auto">If a proxy is set on the session without user and password and Fiddler auth is off, Fiddler is used correctly:<br>
<code class="notranslate">session.proxies['http'] = 'http://127.0.0.1:8888'.format(proxy_string) session.request(....)</code></p>
<p dir="auto">If a proxy is set on the session with user and password, Fiddler returns proxy auth failures:<br>
<code class="notranslate">session.proxies['http'] = 'http://1:1@127.0.0.1:8888'.format(proxy_string) session.request(....)</code></p>
<p dir="auto">If I do exactly the same thing but send the proxy with the request directly, both cases work.<br>
<code class="notranslate">proxies = {} proxies['http'] = 'http://1:1@127.0.0.1:8888'.format(proxy_string) session.request(...., proxies=proxies)</code></p>
<p dir="auto">When subscribing to a Server Sent Events endpoint, I notice an error given the processing of a heartbeat. Heartbeats in SSE can be sent as an empty line. Consider the following SSE reply for chunked transfer encoding:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    00000000  48 54 54 50 2f 31 2e 31  20 32 30 30 20 4f 4b 0d HTTP/1.1  200 OK.
    00000010  0a 53 65 72 76 65 72 3a  20 6f 70 65 6e 72 65 73 .Server:  openres
    00000020  74 79 2f 31 2e 39 2e 31  35 2e 31 0d 0a 44 61 74 ty/1.9.1 5.1..Dat
    00000030  65 3a 20 46 72 69 2c 20  32 38 20 4f 63 74 20 32 e: Fri,  28 Oct 2
    00000040  30 31 36 20 30 32 3a 33  39 3a 35 34 20 47 4d 54 016 02:3 9:54 GMT
    00000050  0d 0a 43 6f 6e 74 65 6e  74 2d 54 79 70 65 3a 20 ..Conten t-Type: 
    00000060  74 65 78 74 2f 65 76 65  6e 74 2d 73 74 72 65 61 text/eve nt-strea
    00000070  6d 0d 0a 54 72 61 6e 73  66 65 72 2d 45 6e 63 6f m..Trans fer-Enco
    00000080  64 69 6e 67 3a 20 63 68  75 6e 6b 65 64 0d 0a 43 ding: ch unked..C
    00000090  6f 6e 6e 65 63 74 69 6f  6e 3a 20 6b 65 65 70 2d onnectio n: keep-
    000000A0  61 6c 69 76 65 0d 0a 0d  0a                      alive... .
    000000A9  31 0d 0a 0a 0d 0a                                1....."><pre class="notranslate"><code class="notranslate">    00000000  48 54 54 50 2f 31 2e 31  20 32 30 30 20 4f 4b 0d HTTP/1.1  200 OK.
    00000010  0a 53 65 72 76 65 72 3a  20 6f 70 65 6e 72 65 73 .Server:  openres
    00000020  74 79 2f 31 2e 39 2e 31  35 2e 31 0d 0a 44 61 74 ty/1.9.1 5.1..Dat
    00000030  65 3a 20 46 72 69 2c 20  32 38 20 4f 63 74 20 32 e: Fri,  28 Oct 2
    00000040  30 31 36 20 30 32 3a 33  39 3a 35 34 20 47 4d 54 016 02:3 9:54 GMT
    00000050  0d 0a 43 6f 6e 74 65 6e  74 2d 54 79 70 65 3a 20 ..Conten t-Type: 
    00000060  74 65 78 74 2f 65 76 65  6e 74 2d 73 74 72 65 61 text/eve nt-strea
    00000070  6d 0d 0a 54 72 61 6e 73  66 65 72 2d 45 6e 63 6f m..Trans fer-Enco
    00000080  64 69 6e 67 3a 20 63 68  75 6e 6b 65 64 0d 0a 43 ding: ch unked..C
    00000090  6f 6e 6e 65 63 74 69 6f  6e 3a 20 6b 65 65 70 2d onnectio n: keep-
    000000A0  61 6c 69 76 65 0d 0a 0d  0a                      alive... .
    000000A9  31 0d 0a 0a 0d 0a                                1.....
</code></pre></div>
<p dir="auto">With the last line, the <code class="notranslate">31</code> indicates that there is just one byte to receive (ASCII <code class="notranslate">1</code>). The chunked size is then followed by a CRLF and then the empty line (<code class="notranslate">LF</code>), followed again by a CRLF.</p>
<p dir="auto">This appears to cause the following stacktrace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  ...
  File &quot;/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/utils.py&quot;, line 377, in stream_decode_response_unicode
    for chunk in iterator:
  File &quot;/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/models.py&quot;, line 676, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File &quot;/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py&quot;, line 353, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File &quot;/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py&quot;, line 502, in read_chunked
    self._update_chunk_length()
  File &quot;/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py&quot;, line 448, in _update_chunk_length
    line = self._fp.fp.readline()
AttributeError: 'NoneType' object has no attribute 'readline'"><pre class="notranslate"><code class="notranslate">  ...
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/utils.py", line 377, in stream_decode_response_unicode
    for chunk in iterator:
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/models.py", line 676, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 353, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 502, in read_chunked
    self._update_chunk_length()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/packages/urllib3/response.py", line 448, in _update_chunk_length
    line = self._fp.fp.readline()
AttributeError: 'NoneType' object has no attribute 'readline'
</code></pre></div>
<p dir="auto">What I'm left wondering is whether chunked responses that only contain a newline cause the requests library a problem.</p>
<p dir="auto">I'm using requests  2.11.1.</p>