-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
When trying to create a simple script to test the cookie support I realized that setting cookies is a header manipulation affair right now. I think we should create a simpler way to access cookies from HTTP responses and specify them on HTTP requests (when one opts for manual cookie handling).
Maybe something akin to how the Python requests library does it, see http://docs.python-requests.org/en/master/user/quickstart/#cookies. Exposing the response cookies using response.cookies
and exposing a simple http.get("...", null, { "cookies": {"my_cookie": ["value1", "value2"]} })
as well as the full cookie jar kind of API:
let jar = new CookieJar();
jar.set('tasty_cookie', 'yum', domain='httpbin.org', path='/cookies')
http.get("...", null, { "cookies": jar })
Note that it's allowed for multiple cookies with the same name (hence why the "my_cookie" value is a list), see https://tools.ietf.org/html/rfc6265#section-4.2.2. Maybe that use case should be deferred to header manipulation though since I think we can pretty safely classify it as uncommon.