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?

+3
python python-2.7 python-requests


source to share


No one has answered this question yet

Check out similar questions:

47
Very strange behavior of the "is" operator with methods
37
Scrapy - how to manage cookies / sessions
2
Reading data from the transfer settings of the website
1
Using Python Query Session to Execute Multiple Queries Denied
1
cookies required in Python requests
1
Logging in with Python requests (Cookies not activated)
1
TypeError for cookielib CookieJar cookie in Session requests
1
Python requests module - set key to null
0
Python GAE Requests do not return cookies after request
-3
how to receive certain cookies from requests when the library does not process them for you



All Articles
Loading...
X
Show
Funny
Dev
Pics