I am using python 2.7 requests module.
I made this HTTP GET with the custom header below;
header ={
"projectName": "zhikovapp",
"Authorization": "Bearer HZCdsf="
}
response = requests.get(bl_url, headers = header)
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.
{
'Accept-Encoding': 'gzip, deflate',
'projectName': 'zhikovapp',
'Accept': '*/*',
'User-Agent': 'python-requests/2.11.1',
'Connection': 'keep-alive',
'Authorization': 'Bearer HZCdsf='
}
The extra headers are Accept-Encoding
, Accept
, Connection
, User-Agent
. Is this a bug in python requests module? I am using requests ver 2.11.1
How can I remove these extra headers added by python requests module?
答案 0 :(得分:1)
you can do a prepared request.
http://docs.python-requests.org/en/latest/user/advanced/#prepared-requests
then you can delete the headers manually
del prepped.headers['Content-Type']