Strange request behavior when setting cookie value to None in method level parameter
There is a note in the documentation on queries under Session Objects :
Remove value from Dict parameter
Sometimes you want to omit the session level keys from the dict parameter. To do this, you simply set the value of these keys to None in the method level parameter. It will be automatically omitted.
I tested it with slightly modified examples from the documentation section.
After launch
s = requests.Session()
s.cookies.update({'from-my': 'browser'})
r = s.get('http://httpbin.org/cookies', cookies={'from-my': None})
print r.text
I get
{
"cookies": {}
}
which is consistent with the remark.
However, the conclusion
s = requests.Session()
s.cookies.update({'from-my': 'browser'})
r = s.get('http://httpbin.org/cookies', cookies={'another': 'cookie', 'from-my': None})
print r.text
is an
{
"cookies": {
"from-my; another": "cookie"
}
}
it looks like there is a cookie named from-my; another
. Whereas, according to the remark, the output should be
{
"cookies": {
"another": "cookie"
}
}
I am using Python 2.7.6 and requests 2.7.0.
Could this be a request issue or httplib.org - or am I just misinterpreting the documentation?
source to share
No one has answered this question yet
Check out similar questions: