serviejs / popsicle

Simple HTTP requests for node and the browser
MIT License
246 stars 19 forks source link

getAttachCookies appends cookies even though this is against the RFC #82

Closed XuluWarrior closed 7 years ago

XuluWarrior commented 7 years ago

Using a cookies jar, I was having issues with after login POST, future requests still behaved as if I wasn't logged in.

I traced this down to getAttachedCookies which calls request.set('Cookie', / original cookies from request/) followed by request.append('Cookie', / Jar cookies /)

The server I was connecting to was obviously taking offense to the multiple cookie headers and according to the RFC it is correct to do so.

http://stackoverflow.com/questions/16305814/are-multiple-cookie-headers-allowed-in-an-http-request

XuluWarrior commented 7 years ago

Replacing 'append' with 'set' fixed my login issues but that obviously overwrites rather than merges the two cookie sources.

blakeembrey commented 7 years ago

Sounds like a reasonable fix, sorry about that. There should definitely be one header, I'll check what it would take (if it doesn't already) to make sure redirections handle cookies properly.

blakeembrey commented 7 years ago

Released with https://github.com/blakeembrey/popsicle/releases/tag/v9.0.0.

XuluWarrior commented 7 years ago

Great! That works for me. Thanks for the prompt fix.