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

Improper header checks in http plugin #1534

Open
funkybob opened this issue May 17, 2017 · 2 comments
Open

Improper header checks in http plugin #1534

funkybob opened this issue May 17, 2017 · 2 comments

Comments

@funkybob
Copy link
Contributor

http.c:191: else if (uhttp.auto_gzip && !uwsgi_strnicmp("ACCEPT-ENCODING", 15, hh, keylen)) {
http.c:302: else if (uhttp.auto_gzip && !uwsgi_strncmp("ACCEPT_ENCODING", 15, hh, keylen)) {

At least one of these is wrong.

One calls strnicmp, the other strncmp.

One has _ the other has -

I wonder if this is related to why I can never get http-auto-gzip to work.

@unbit
Copy link
Owner

unbit commented May 17, 2017

The right one is the 191 (we are managing the true header in case insensitive way, so the dash is the right char). Waiting for your pull request :)

funkybob added a commit to funkybob/uwsgi that referenced this issue May 17, 2017
unbit added a commit that referenced this issue May 18, 2017
xrmx added a commit to xrmx/uwsgi that referenced this issue May 20, 2017
This reverts commit 23c284d.

As spotted by @gdamjan http_add_uwsgi_header is called after
http_headers_to_cgi has normalized the headers substituting
dashes with underscores.
@funkybob
Copy link
Contributor Author

Some clarity is needed on how headers are checked:

            else if (!uwsgi_strnicmp("SEC-WEBSOCKET-VERSION", 21, hh, keylen)) {
            else if (!uwsgi_strnicmp("SEC-WEBSOCKET-KEY", 17, hh, keylen)) {
    if (!uwsgi_strnicmp("CONTENT-LENGTH", 14, hh, keylen)) {
    else if (!uwsgi_strnicmp("TRANSFER_ENCODING", 17, hh, keylen)) {
    else if (uhttp.auto_gzip && !uwsgi_strnicmp("ACCEPT-ENCODING", 15, hh, keylen)) {
if (uwsgi_strncmp("CONTENT_LENGTH", 14, hh, *keylen) && uwsgi_strncmp("CONTENT_TYPE", 12, hh, *keylen)) {

Can we assume that:

  1. incoming headers are CGIified - that is, upper cased and '-' changed to '_'
  2. outbound headers are all caps, and .... how are '-' and '_' handled?

If these are true, we can dispense with the case-insensitive compare [small speed up, maybe]

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

No branches or pull requests

2 participants