<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/ef56f0212660c26ffd6f245a68e59277bc863f39b90d1f3dc717aa29abb3e4ad/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f333039373935362f32373030302f36623566373166612d346236372d313165322d393134642d3761666563306363396661622e706e67"><img src="https://camo.githubusercontent.com/ef56f0212660c26ffd6f245a68e59277bc863f39b90d1f3dc717aa29abb3e4ad/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f333039373935362f32373030302f36623566373166612d346236372d313165322d393134642d3761666563306363396661622e706e67" alt=" " data-canonical-src="https://f.cloud.github.com/assets/3097956/27000/6b5f71fa-4b67-11e2-914d-7afec0cc9fab.png" style="max-width: 100%;"></a></p>
<p dir="auto">Hello All,</p>
<p dir="auto">I am a <em>big</em> fan of Requests, and have just upgraded from v0.14.0 on Python 3.2.3 to v0.14.2 on Python 3.3.0. I think that the upgrade to Requests broke my code when using a <code class="notranslate">requests.session()</code> object. I use Fiddler for some transport debugging, which is why I'm using the loopback address on port 8888.</p>
<p dir="auto"><em>Please note</em> that everything works as expected if I use a <code class="notranslate">requests.post()</code> object instead of using a <code class="notranslate">requests.session()</code> object for the request (obviously bypassing the proxy).</p>
<p dir="auto">My code looks as follows:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="s = requests.session(proxies={'http': '127.0.0.1:8888'})
r = s.post(url, data=soap_req, headers=headers)"><pre class="notranslate"><span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">requests</span>.<span class="pl-en">session</span>(<span class="pl-s1">proxies</span><span class="pl-c1">=</span>{<span class="pl-s">'http'</span>: <span class="pl-s">'127.0.0.1:8888'</span>})
<span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">s</span>.<span class="pl-en">post</span>(<span class="pl-s1">url</span>, <span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">soap_req</span>, <span class="pl-s1">headers</span><span class="pl-c1">=</span><span class="pl-s1">headers</span>)</pre></div>
<p dir="auto">The call to <code class="notranslate">s.post()</code> results in a <code class="notranslate">KeyError: None</code> exception in <code class="notranslate">connection_from_host()</code> in <code class="notranslate">class PoolManager</code> in poolmanager.py.</p>
<p dir="auto">The offending line is:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    pool_cls = pool_classes_by_scheme[scheme]"><pre class="notranslate">    <span class="pl-s1">pool_cls</span> <span class="pl-c1">=</span> <span class="pl-s1">pool_classes_by_scheme</span>[<span class="pl-s1">scheme</span>]</pre></div>
<p dir="auto">Debugging shows <code class="notranslate">pool_key = (None, '127.0.0.1', 8888)</code></p>
<p dir="auto">What puzzles me is that scheme shows up as <em>None</em> (as shown in the 1st element in the tuple above). Debugging indeed verifies scheme is NoneType, which makes no sense, since it has a default value of 'http' when it enters the method.</p>
<p dir="auto">I would appreciate anyone who can shed light and/or provide a fix for the above. I'm at the limit of my debugging skills. Please advise if you need more info from my side for further troubleshooting.</p>
<p dir="auto">Thanks in advance,</p>
<p dir="auto">Jean-Marc</p>