Python requests add extra headers to HTTP GET
<p>I am using python 2.7 requests module.</p>

<p>I made this HTTP GET with the custom header below;</p>

<pre><code>header ={
            "projectName": "zhikovapp",
            "Authorization": "Bearer HZCdsf="
        }
response = requests.get(bl_url, headers = header)
</code></pre>

<p>The server returns a response that was not valid. On closer examination of the header that was sent, I discovered python requests module added some extra headers.</p>

<pre><code>{
'Accept-Encoding': 'gzip, deflate', 
'projectName': 'zhikovapp',
'Accept': '*/*', 
'User-Agent': 'python-requests/2.11.1', 
'Connection': 'keep-alive', 
'Authorization': 'Bearer HZCdsf='
}
</code></pre>

<p>The extra headers are <code>Accept-Encoding</code>, <code>Accept</code>, <code>Connection</code>, <code>User-Agent</code>. Is this a bug in python requests module? I am using requests ver 2.11.1</p>

<p>How can I remove these extra headers added by python requests module?</p>

<p>you can do a prepared request.</p>

<p><a href="http://docs.python-requests.org/en/latest/user/advanced/#prepared-requests" rel="nofollow">http://docs.python-requests.org/en/latest/user/advanced/#prepared-requests</a></p>

<p>then you can delete the headers manually</p>

<pre><code>del prepped.headers['Content-Type']
</code></pre>

python python-2.7 http-headers python-requests