Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BrowserKit] Add ability to handle an empty cookie #7039

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

Closed
alexcartwright opened this issue Feb 10, 2013 · 5 comments
Closed

[BrowserKit] Add ability to handle an empty cookie #7039

alexcartwright opened this issue Feb 10, 2013 · 5 comments

Comments

@alexcartwright
Copy link

Currently throws InvalidArgumentException when server responds to a request with an empty set-cookie header (am using version 2.1.7).

Would it make sense to edit CookieJar::updateFromSetCookie to test for empty set-cookie headers and igrnore them? (am new to GitHub)

@jfsimon
Copy link
Contributor

jfsimon commented Feb 28, 2013

According to the RFC2109, Set-Cookie must set one or more cookie(s).
Maybe it would be better to remove Set-Cookie header from request when it's empty.
@fabpot should it be the role of the HttpFoundation component (to "clean" a request)?

@jfsimon
Copy link
Contributor

jfsimon commented Mar 1, 2013

@alexcartwright I checked the Request class, and there is actually no way to build an empty Set-Cookie header (which does match the RFC). Have your request been build with HttpFoundation component?

@alexcartwright
Copy link
Author

@jfsimon Thanks for picking this up. I am using Goutte\Client->request (dev-master) to send the request. The external website sets the empty Set-Cookie header, which is then passed from Goutte\Client to BrowserKit\Client within the BrowserKit\Response object.

@jfsimon
Copy link
Contributor

jfsimon commented Mar 5, 2013

The problem is that an empty Set-Cookie header is considered as invalid.
If you want to handle invalid response anyway, you should maybe transformit.

@fabpot do you think it would be right to just ignore invalid cookies in the BrowserKit\Client

@fabpot
Copy link
Member

fabpot commented Mar 12, 2013

Let's just ignore the Set-Cookie header if it is empty.

fabpot added a commit that referenced this issue Mar 12, 2013
This PR was merged into the 2.1 branch.

Commits
-------

fc47589 [BrowserKit] added ability to ignored malformed set-cookie header

Discussion
----------

[BrowserKit] adds ability to ignore malformed set-cookie header

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7039
@fabpot fabpot closed this as completed Mar 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants