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

Empty values for headers are skipped #4287

Closed
tobiastom opened this Issue May 31, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@tobiastom
Contributor

tobiastom commented May 31, 2017

What are you trying to achieve?

I'm trying to set a DNT header to the value of 0, as it is described in the specification:

$I->haveHttpHeader('DNT', '0');

What do you get instead?

The DNT header is not set to the server as it is skipped.

Details

The problem is in this line of code:

if (!$val) {
continue;
}
.

The string value 0 is evaluated as false and will not be send.
A possible solution would be to check if the value is a string, and if it is use it anyway. I could create a pull request for this, if it is an acceptable fix for you.

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda May 31, 2017

Member

To behave in the same way as set_cookie function that condition should be if($val === null || $val === '') { continue; }
https://github.com/php/php-src/blob/430eea84b84a8c9d733a38cafaa32d494cadf13b/ext/standard/head.c#L127

Please make a pull request.

Member

Naktibalda commented May 31, 2017

To behave in the same way as set_cookie function that condition should be if($val === null || $val === '') { continue; }
https://github.com/php/php-src/blob/430eea84b84a8c9d733a38cafaa32d494cadf13b/ext/standard/head.c#L127

Please make a pull request.

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