title: Python Requests - ChunkedEncodingError(e) - requests.iter_lines
body: <p>I'm getting a <code>ChunkedEncodingError(e)</code> using Python requests. I'm using the following to rip down JSON:</p>
  
  <pre><code>r = requests.get(url, headers=auth, stream=True)
  </code></pre>
  
  <p>And the iterating over each line, using the carriage return as a delimiter, which is how this API distinguishes between distinct JSON events.</p>
  
  <pre><code>for d in r.iter_lines(delimiter="\n"):
      d += "\n"
      sock.send(d)
  </code></pre>
  
  <p>I'm delimiting on the carriage return and then adding it back in as the endpoint I'm pushing the logs to actually expects a carriage return at the end of each event also. This seems to work for roughly 100k log files. When I try to make a larger call I'll get this following thrown:</p>
  
  <pre><code>for d in r.iter_lines(delimiter="\n"):
  logs_1           |   File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 783, in iter_lines
  logs_1           |     for chunk in self.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode):
  logs_1           |   File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 742, in generate
  logs_1           |     raise ChunkedEncodingError(e)
  logs_1           | requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
  </code></pre>
  
  <p>UPDATE: I've discovered the API is sending back a <code>NoneType</code> at some point as well. So how can I account for this null byte somewhere in the response without blowing everything up? Each individual event is ended with a <code>\n</code>, and I need to be able to inspect each even individually. Should I chunk the content instead of <code>iter_lines</code>? Then ensure there is no <code>NoneType</code> in the chunk? That way I don't try to <code>iter_lines</code> over a <code>NoneType</code> and it blows up?</p>