Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple cookie parser keeps first cookie with same name, not most recently set #1831

Closed
lvpiao opened this issue Aug 30, 2022 · 5 comments
Closed
Assignees
Labels
Milestone

Comments

@lvpiao
Copy link

lvpiao commented Aug 30, 2022

image

@lvpiao lvpiao changed the title I recently ran into an issue and found out that the reason was that the first cookie was kept after a request, which is different from the browser's behavior I recently encountered a problem and found that the reason is that when there are multiple Set-Cookies setting the same cookie in the header of a response, only the first cookie is retained, which is different from the browser's behavior Aug 30, 2022
lvpiao added a commit to lvpiao/jsoup that referenced this issue Sep 7, 2022
lvpiao added a commit to lvpiao/jsoup that referenced this issue Sep 7, 2022
@jeffthomasweb
Copy link

Hi, to help others duplicate this issue, can you please include a code sample and the error you receive? Thanks!

@lvpiao
Copy link
Author

lvpiao commented Sep 12, 2022

image
image

As shown in the figures, if there are two identical Set-Cookie in the response header, the browser (e.g. Edge) will save the second one, however Jsoup will save the first one, and when the subsequent request carrie that cookie, the exception will occur.

@jhy jhy linked a pull request Jan 5, 2023 that will close this issue
@jhy jhy changed the title I recently encountered a problem and found that the reason is that when there are multiple Set-Cookies setting the same cookie in the header of a response, only the first cookie is retained, which is different from the browser's behavior Simple cookie parser keeps first cookie with same name, not most recently set Jan 5, 2023
@jhy jhy closed this as completed in b6bd4b4 Sep 11, 2024
@jhy jhy self-assigned this Sep 11, 2024
@jhy jhy added the fixed label Sep 11, 2024
@jhy jhy added this to the 1.18.2 milestone Sep 11, 2024
@jhy
Copy link
Owner

jhy commented Sep 11, 2024

Thanks, fixed. I simplified the implementation to have the simple cookie map populated by the set result of the Cookie Store, which corrects for order, path, etc.

@anonyein
Copy link

anonyein commented Sep 15, 2024

This fix makes lots of trouble! "set-cookie" will be none sence by this fix and many "set-cookie"s are ignored after this fix. You must test more cases to check whether it is fine!

@jhy
Copy link
Owner

jhy commented Nov 21, 2024

@anonyein

This fix makes lots of trouble! "set-cookie" will be none sence by this fix and many "set-cookie"s are ignored after this fix. You must test more cases to check whether it is fine!

Yeah... I rolled it back in 8dec9c3 and we just keep the last set one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants