Skip to content

Conversation

@egeloen
Copy link

@egeloen egeloen commented Jul 26, 2016

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets ~
Documentation ~
License MIT

Hey!

What's in this PR?

This PR fixes an issue in the max age calculation. Basically, the PSR-7 implementations returns a string as header value whereas the max age should be an integer.

Why?

Since PHP is able to implicitely convert string to integer on the fly, it should not be an issue but when using with a PSR-6 provider such the Symfony one, adapters requires an integer as ttl otherwise it throws an exception (see here fox example).

if (!is_bool($maxAge)) {
$ageHeaders = $response->getHeader('Age');
foreach ($ageHeaders as $age) {
return $maxAge - ((int) $age);
Copy link
Contributor

Choose a reason for hiding this comment

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

this will cast to int automatically, right?

Copy link
Author

Choose a reason for hiding this comment

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

Yes the cast is implicit here.

@dbu
Copy link
Contributor

dbu commented Jul 26, 2016

thanks!

makes sense to me. should we add a note to the changelog for this?

@sagikazarmark
Copy link
Member

@egeloen can you please add some changelog for this?

## UNRELEASED

### Fixed

- Integer casting something ...

@egeloen
Copy link
Author

egeloen commented Jul 27, 2016

@sagikazarmark Done

@dbu dbu merged commit 3c1dac0 into php-http:master Jul 27, 2016
@dbu
Copy link
Contributor

dbu commented Jul 27, 2016

thanks a lot! i merged, the styleci error is not related to this PR.

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.

4 participants