Fix multiple cookies for follow_set_cookies
It appears that cookies.js expects the format ofthe Set Cookies header to function. This sounds reasonable, but the original request's cookies are stored as a string (for convenience I believe?) not as key-value pair strings, so it needs to be separated again to be forwarded correctly in the redirect.
Fixes #350.
Could you please add some tests? It looks to me this would break if the cookies header is empty...
You are right it fails if there are no cookies... I think this should work instead?
There is already a test for an exmpty cookie with redirect, but I added one for multiple request cookies anyway.
I can't actually run all tests because I don't have access to a Linux machine which could, but all cookies-related tests are passing.
cookies
with default options
√ no cookie header is set on request
(node:7320) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
if response does not contain cookies
√ response.cookies is undefined
if response contains cookies
√ puts them on resp.cookies
√ parses them as a object
√ must decode it
when a cookie value is invalid
√ doesnt blow up
and response is a redirect
and follow_set_cookies is false
with original request cookie
√ request cookie is not passed to redirects
√ response cookies are not passed either
without original request cookie
√ no request cookies are sent
√ response cookies are not passed either
and follow_set_cookies is true
with original request cookie
√ request cookie is passed passed to redirects, and response cookies are added too
√ response cookies are passed as well
with multiple original request cookies
√ request cookie is passed passed to redirects, and response cookies are added too
√ response cookies are passed as well
without original request cookie
√ response cookies are passed to redirects
√ response cookies are passed as well
with parse_cookies = false
√ does not parse them
if request contains cookie header
√ must be a valid cookie string
√ dont have to encode allowed characters
√ must encode forbidden characters