Skip to content

Fix set-cookie parsing #1675

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

Merged
merged 5 commits into from
Feb 20, 2023
Merged

Fix set-cookie parsing #1675

merged 5 commits into from
Feb 20, 2023

Conversation

Vovcharaa
Copy link
Contributor

@Vovcharaa Vovcharaa commented Feb 19, 2023

New Pull Request Checklist

  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary)
  • I have run the tests without failures

Additional context and info (if any)

Fix #1674

@Vovcharaa Vovcharaa requested a review from a team as a code owner February 19, 2023 13:31
@Vovcharaa
Copy link
Contributor Author

RegEx taken here: dart-lang/http#362 (comment)

Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests.

@Vovcharaa
Copy link
Contributor Author

Please add tests.

I have no experience with dart tests, so I am not sure if I can do this, but I will look into it.

@AlexV525
Copy link
Member

AlexV525 commented Feb 19, 2023

I have no experience with dart tests, so I am not sure if I can do this, but I will look into it.

This is easy by expecting a multi-value cookie to be parsed as multi values. An example:

final headers = Headers.fromMap({
'set-cookie': ['k=v', 'k1=v1'],
'content-length': ['200'],
'test': ['1', '2'],
});
headers.add('SET-COOKIE', 'k2=v2');
expect(headers.value('content-length'), '200');
expect(Future(() => headers.value('test')), throwsException);
expect(headers['set-cookie']?.length, 3);

@Vovcharaa Vovcharaa force-pushed the main branch 2 times, most recently from 4d809e3 to 58d4e45 Compare February 19, 2023 15:17
@Vovcharaa
Copy link
Contributor Author

@AlexV525 done

@AlexV525
Copy link
Member

Sorry, please update the CHANGELOG too.

@Vovcharaa
Copy link
Contributor Author

@AlexV525 done

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

Successfully merging this pull request may close these issues.

If multiply cookies present in set-cookie header, only first is saved.
3 participants