Skip to content

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

Closed

Description

@lvpiao

image

Activity

  1. 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[/+] on Aug 30, 2022
  2. added 2 commits that reference this issue on Sep 7, 2022
  3. jeffthomasweb commented on Sep 9, 2022

    @jeffthomasweb

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

  4. lvpiao commented on Sep 12, 2022

    @lvpiao
    Author

    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.

  5. 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[/+] on Jan 5, 2023
  6. self-assigned this
    on Sep 11, 2024
  7. added
    fixedAn {bug|improvement} that has been {fixed|implemented}
    on Sep 11, 2024
  8. added this to the 1.18.2 milestone on Sep 11, 2024
  9. jhy commented on Sep 11, 2024

    @jhy
    Owner

    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.

  10. added a commit that references this issue on Sep 11, 2024
    b6bd4b4
  11. anonyein commented on Sep 15, 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!

  12. jhy commented on Nov 21, 2024

    @jhy
    Owner

    @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

Metadata

Metadata

Assignees

Labels

fixedAn {bug|improvement} that has been {fixed|implemented}

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions