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

Add cookies to request object #175

Merged
merged 3 commits into from
May 10, 2017
Merged

Conversation

legionth
Copy link
Contributor

This PR adds cookies to the PSR-7 ServerRequest. The implementation of cookies is line with the implementation of PHP.

I added a simple example to this to test this via a web browser.

@WyriHaximus WyriHaximus requested review from jsor and clue April 23, 2017 09:01
Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

Nice!

The RFC suggests that there must be a space between multiple cookie-pairs, such as Cookie: SID=31d4d96e407aad42; lang=en-US. Can you verify https://tools.ietf.org/html/rfc6265#section-4.2.1?

src/RequestHeaderParser.php Outdated Show resolved Hide resolved
@legionth
Copy link
Contributor Author

@clue you're right about the space between multiple cookies. Fixed it.

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

Changes LGTM, thanks! 👍

The RFC suggests there MUST be space after the semicolon, are clients that omit this space relevant? May I ask you to check how other parsers handle this situation? 👍

@legionth legionth force-pushed the cookies branch 2 times, most recently from d736267 to 3974e62 Compare April 27, 2017 15:40
*/
public static function parseCookie($cookie)
{
// PSR-7 `getHeadline('Cookies')` will return multiple
Copy link
Contributor

Choose a reason for hiding this comment

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

should be getHeaderLine

public static function parseCookie($cookie)
{
// PSR-7 `getHeadline('Cookies')` will return multiple
// cookie header coma-seperated. Multiple cookie headers
Copy link
Contributor

Choose a reason for hiding this comment

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

Comma

$this->assertEquals(array(), $requestValidation->getCookieParams());
}

public function testCookieWithSepeartorWillBeAddedToServerRequest()
Copy link
Contributor

Choose a reason for hiding this comment

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

MEthod name typo
M

@WyriHaximus
Copy link
Member

@legionth could you resolve merge conflicts and address @andig points?

@legionth legionth force-pushed the cookies branch 3 times, most recently from 04f89d2 to 0a4e5e1 Compare May 9, 2017 09:50
@legionth
Copy link
Contributor Author

legionth commented May 9, 2017

Sorry I'm very busy currently.

@andig Have a look. This should cover your remarks :)

@clue I checked Slim and Symfony. Both trim the spaces from the cookie string. I changed the behavior in this PR. Have a look!

{
// PSR-7 `getHeaderLine('Cookies')` will return multiple
// cookie header comma-seperated. Multiple cookie headers
// are not allowed according to https://tools.ietf.org/html/rfc6265#section-5.4
Copy link
Contributor

Choose a reason for hiding this comment

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

Should imho read

... PSR-7 getHeaderLine('Cookie') will return multiple comma-seperated cookie headers.

@WyriHaximus WyriHaximus merged commit bb4b14a into reactphp:master May 10, 2017
@WyriHaximus
Copy link
Member

FYI Travis failure was unrelated to this PR and only on the HHVM job.

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

Successfully merging this pull request may close these issues.

None yet

6 participants