Skip to content

Add request header accessors (à la PSR-7) - #103

Merged
clue merged 2 commits into
reactphp:masterfrom
clue-labs:headers
Feb 10, 2017
Merged

Add request header accessors (à la PSR-7)#103
clue merged 2 commits into
reactphp:masterfrom
clue-labs:headers

Conversation

@clue

@clueclue commented Feb 9, 2017

Copy link
Copy Markdown
Member

Note that this PR does not implement the PSR-7 interfaces, but follows its method signatures for the header methods to ease a future switch to PSR-7 via #28.

This is also the base for an upcoming PR that fixes#51.

@clueclue added this to the v0.4.3 milestone Feb 9, 2017
jsor
jsor approved these changes Feb 9, 2017
Comment threadsrc/Request.php Outdated
* there's only a single value or an array of strings if this header has
* multiple values.
*
* Note that this differs from the PSR-7 implementation of this method.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's probably worth mentioning in which way it differs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed, could you add that @clue?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Absolutely 👍

Comment threadsrc/Request.php Outdated
* there's only a single value or an array of strings if this header has
* multiple values.
*
* Note that this differs from the PSR-7 implementation of this method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed, could you add that @clue?

Comment threadsrc/Request.php Outdated
foreach ($this->headers as $key => $value) {
if (strtolower($key) === $name) {
foreach((array)$value as $one) {
$found []= $one;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this be $found[] = $one;?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

There are valid reasons for both styles IMO, but I have no real preference here, so yeah 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not used to this syntax, but I prefer to be consistent 😄

@WyriHaximusWyriHaximus modified the milestones: v0.4.4, v0.4.3Feb 9, 2017
@clue

clue commented Feb 9, 2017

Copy link
Copy Markdown
MemberAuthor

Updated :shipit:

@kelunik

Copy link
Copy Markdown

@clue What's the reason for differing from PSR-7 here? I think the PSR-7 behavior makes more sense.

@WyriHaximus

Copy link
Copy Markdown
Member

@kelunik mainly that this will go into 0.4.3 and PSR-7 will come in 0.5 so this is more a step in the right direction 😄

@kelunik

Copy link
Copy Markdown

@WyriHaximus I missed that getHeaders is an existing method.

@WyriHaximus

Copy link
Copy Markdown
Member

@kelunik np 😄

@clue

clue commented Feb 10, 2017

Copy link
Copy Markdown
MemberAuthor

Rebased on current master to resolve merge conflicts :shipit:

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Header names are not case-sensitive

4 participants

@clue@kelunik@WyriHaximus@jsor