Skip to content

Getallheaders fpm #904

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
wants to merge 2 commits into from
Closed

Getallheaders fpm #904

wants to merge 2 commits into from

Conversation

ralt
Copy link
Contributor

@ralt ralt commented Nov 19, 2014

Following up on #523 , fixed the comments by refactoring and fixing the trailing character.

Reminder: fixes https://bugs.php.net/bug.php?id=62596

(Since it's a follow-up, cc @krakjoe @TazeTSchnitzel @manuelm)

@ralt ralt force-pushed the getallheaders-fpm branch from 1183859 to a3674b5 Compare November 19, 2014 13:56
@remicollet
Copy link
Member

As this PR introduce a new function, it will be nice to include a unit test (5.6+)

@ralt
Copy link
Contributor Author

ralt commented Nov 21, 2014

@remicollet indeed, will do. I learned less than an hour ago that fpm had tests now! :) Thanks for your work on this.

@ralt
Copy link
Contributor Author

ralt commented Nov 21, 2014

As discussed together, I will make another PR for master, since some functions are not compatible anymore, namely add_assoc_stringl_ex.

@remicollet
Copy link
Member

And FYI, I just add 017.phpt which is the first one to run some specific code inside the FPM server.

@ralt
Copy link
Contributor Author

ralt commented Nov 21, 2014

Hmmm how should I handle the fact that this PR is for php-5.5, but the tests are for php-5.6 only?

@remicollet
Copy link
Member

apache_request_headers / getallheaders functions are available in nsapi, apache*, cli server, cgi and litespeed, so make sense for FPM.

All other SAPI use PHP_FALIAS(getallheaders, apache_request_headers,
So probably better to do the same (switch alias / function name)

@remicollet
Copy link
Member

I also think having cgi_add_request_header and fpm_add_request_header is a bit tricky
Why not simply only use sapi_add_request_header (of course with the correct val_len value) ?

Hmmm how should I handle the fact that this PR is for php-5.5, but the tests are for php-5.6 only?

We'll just have to be careful during the merge (probably merging all in 5.6 and cherry-pick only the revelant commit in 5.5)

@ralt
Copy link
Contributor Author

ralt commented Nov 21, 2014

All other SAPI use PHP_FALIAS(getallheaders, apache_request_headers,
So probably better to do the same (switch alias / function name)

Will do.

Why not simply only use sapi_add_request_header (of course with the correct val_len value) ?

How do I pass the correct value? It's used as a function callback, so I need an intermediary function.

We'll just have to be careful during the merge (probably merging all in 5.6 and cherry-pick only the revelant commit in 5.5)

I'll let you handle it then :-)

@ralt ralt force-pushed the getallheaders-fpm branch 2 times, most recently from 89a1827 to 3516803 Compare November 21, 2014 14:42
@ralt
Copy link
Contributor Author

ralt commented Nov 21, 2014

The failed tests don't really seem related to this PR...

@ralt ralt mentioned this pull request Nov 21, 2014
@ralt
Copy link
Contributor Author

ralt commented Nov 22, 2014

@remicollet I fixed:

  • The alias orders
  • The duplication (it uses sapi_add_request_header right away)

The PR #910 adds the missing test.

@ralt ralt force-pushed the getallheaders-fpm branch from 3516803 to e0bfbf4 Compare November 24, 2014 11:34
@cjsfj
Copy link

cjsfj commented Mar 18, 2015

Seems like this change normalizes the case of the headers, as well as leaves off the last character. At least that's what it did when I patched my source.

Shouldn't the headers come through as-is rather than the case changed?

@hikari-no-yume
Copy link
Contributor

It'd be better to preserve case, definitely. For the CLI server getallheaders() I made it case-preserving, as trying to "correct" HTTP header names both mangles input and requires a list of HTTP headers which must be kept current.

@hikari-no-yume
Copy link
Contributor

In its case, all headers were stored in an array with lowercase keys for retrieval. The solution was to add a second array with original-case keys which pointed to the same values.

@cjsfj
Copy link

cjsfj commented Mar 19, 2015

Of course keeping a standard list of http headers is impossible in the case where developers are adding custom headers in their web applications.

@TazeTSchnitzel So in this case, normalization is probably the best policy when dealing with fpm. Do you agree? If so I think Title case is the wrong approach -- something more like you've implemented with cli (lower case) would be more appropriate.

@hikari-no-yume
Copy link
Contributor

I'm not familiar with the intricacies of FastCGI, but are you sure case normalisation is the only way to go? Bear in mind this won't work properly anyway as the rules have exceptions.

@cjsfj
Copy link

cjsfj commented Mar 19, 2015

Honestly my understanding of this type of development is very elementary. I just wanted to post and indicate that while this pull request is submitted, when I applied it to my source, the resulting getallheaders output had the following issues:

  • The keys were all missing the last character
  • The case of the keys do not match when compared to running the same function on an instance using the Apache module.

Thanks for your attention. If I'm in err please let me know.

@cmb69
Copy link
Member

cmb69 commented Jul 21, 2015

It seems this PR can be closed, because PHP 5.5 is in security support mode, and there's the follow-up PR #910 which targets PHP 5.6.

@nikic nikic closed this Jul 21, 2015
Sign up for free to 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.

8 participants