<p dir="auto">Apologies if this is a duplicate or not a bug – I ran into this recently and figured I should report it.</p>
<p dir="auto"><code class="notranslate">iter_content</code> takes a <code class="notranslate">chunk_size</code> argument, which defaults to 1. Various code snippets on the internet call <code class="notranslate">request.iter_content()</code>. This is incredibly inefficient, because it is using a buffer size of 1 <em>byte</em>. I think <code class="notranslate">requests</code> should either a) set <code class="notranslate">chunk_size</code> to something more reasonable, like 2048 or 4096, or b) make <code class="notranslate">chunk_size</code> a required argument. (Solution a is more palatable since it's backwards compatible.)</p>
<p dir="auto">Currently any duplicate header on responses gets merged on the response.headers dict, using a comma to delimit de two different header values. For example</p>
<p dir="auto">HTTP/1.1 200 OK<br>
HeaderX: Value1<br>
HeaderX: Value2</p>
<blockquote>
<p dir="auto">print response.headers<br>
{ 'headerx' : ' Value1, Value2' }</p>
</blockquote>
<p dir="auto">This makes impossible to detect responses with duplicate headers, particularly when header values already include commas by themselves (e.g., 'last-modified')</p>
<p dir="auto">Potential alternative repr:</p>
<blockquote>
<p dir="auto">print response.headers<br>
{ 'headerx' : ['Value1', 'Value2'] }</p>
</blockquote>
<p dir="auto">Problem: breaks backward compatibility as scripts expecting a string would get a list</p>
<blockquote>
<p dir="auto">print response.headers<br>
{ 'headerx' : 'Value1  'Value2'}</p>
</blockquote>
<p dir="auto">Where SEP would be a separator that can't be found on values (newline?)</p>