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

For static files, if header Content-Length is 0 no HTTP 400 should be returned #247

Closed
LHaferkamp opened this issue Oct 24, 2019 · 4 comments

Comments

@LHaferkamp
Copy link
Contributor

As described here: https://stackoverflow.com/a/58541479/2854141
a HTTP 400 is returned when serving static files if header Content-Length:0 is set. This case should be considered as valid and be excluded in the check in webapplication.cpp


// Make sure that there's no message body.
  if (pRequest->hasHeader("Content-Length") || pRequest->hasHeader("Transfer-Encoding")) {
    return error_response(pRequest, 400);
  }
LHaferkamp added a commit to LHaferkamp/httpuv that referenced this issue Oct 28, 2019
@wch
Copy link
Collaborator

wch commented Oct 29, 2019

Here's what I see in https://tools.ietf.org/html/rfc7230#section-3.3.2:

A user agent SHOULD NOT send a Content-Length header field when the request message does not contain a payload body and the method semantics do not anticipate such a body.

If you think that this doesn't apply to the situation you are encountering, can you please provide an example of the exact HTTP request that is used? It's not entirely clear to me from reading the Stack Overflow answer.

@LHaferkamp
Copy link
Contributor Author

You are right, this RFC statement applies to the situation. Unfortunately I can't control this additional header injected by the Azure proxy. So it would be really beneficial to be less strict, and it would still comply to the RFC as its not a MUST to decline such requests

@wch
Copy link
Collaborator

wch commented Oct 31, 2019

OK, that sounds reasonable.

LHaferkamp added a commit to LHaferkamp/httpuv that referenced this issue Nov 14, 2019
wch added a commit that referenced this issue Nov 14, 2019
Issue #247 fixed, Content-Length:0 is valid header for static files
@wch
Copy link
Collaborator

wch commented Nov 14, 2019

Closed by #248.

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