httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
32.67k stars 3.68k forks source link

Don't expire cookie with later setting in the same headers #1584

Open agriffis opened 5 days ago

agriffis commented 5 days ago

I'm interacting with a server that likes to simultaneously expire a cookie and give it a new value in the same headers:

Set-Cookie: JSESSIONID=expire; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: JSESSIONID=ED0E0934E642AC44A7ACDE6CED16D904; Path=/; Secure; HttpOnly

This isn't spec, as I understand it, but it turns out the browsers don't care. They just use the last value given.

So this PR updates httpie to behave in the same way, by ignoring an earlier expiration in favor of a later setting in the same headers.

Without this change, httpie drops the cookie rather than setting it, which makes interacting with this particular server quite difficult.