-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Http Statuscode-Line is ignored in ISS Server (and maybe other fastCGI servers) #19923
Comments
I can see that Symfony is sending
so it looks like our way. Do you think that your problem might come from misconfiguration of the server? |
I took lot of time investigation this problem. is corrent and fine for all "normal" webservers. I am not 100% sure if this happens for all servers in fast cgi mode, or only for IIS, or if it is any special configuration in IIS. |
Any disadvantages specifying statusCode argument? |
I could not find any disadvantages via google ect. But I found the matching RFC for this header see rfc3875. Maybe we should extend the qury for api type a bit to somthing linke the example on php.net to $sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
header("Status: {$statusCode} {$this->statusText}", true, $statusCode);
else
header("HTTP/{$this->version} {$statusCode} {$this->statusText}"); That makes it covering fast cgi and basic cgi-mode |
Yes. Good idea. |
Do you have time for a pull request? |
I think I can write the code, I am not sure if this is all, or if there is anything more to do in documentations ect.. |
What steps will reproduce the problem?
Set response-code in an IIS Server like this:
or create any critical php error (e.g.
echo 10/0
).What is the expected result?
Expected result is Statuscode 500 in Browser, and
HTTP/1.1 500 Internal Server Error
on first line of http headers.What do you get instead?
Statuscode 200 and first header line of
HTTP/1.1 200 OK
Additional info
my Researches to find the problem
I discovered, that yii does not return a statuscode 500 on php errors, and made some research.
I followed the defined status-code in the response until I found yii\web\Response::sendHeaders().
After more testing I can ensure that the statuscode is correctly passed in this method and correctly passed into the header function.
E.g. adding a custom header as debug like this (e.g. in one of your controller actions):
Gives the header
X-StatusLine: HTTP/1.0 500 Internal Server Error
, what makes me sure that a currect formated statusline is created in the sendHeaders() function, but statuscode is not delivered to browser.After more reseach I discovered the
Status
-header, and made some tests adding this extra header.The line
in Response::sendStatus did not chance anything.
But adding the stuscode to the 3. argument of the header function gave the expected result.
Suggestion to fix
Add the line
right after
yii2/framework/web/Response.php
Line 383 in 504a66d
or maybe replace the existing line with
Reasons
It seems that IIS (and maybe other servers) do not respect the statuscode / message set as
HTTP/{Protocol} {code} {message}
-header.Adding the extra header
Status: {code} {message}
tells this server to chance their statusline line expected.As far as I could find out, this behavior has something to do with cgi/fastCGI, so I thinkt this is not only an IIS exclusive problem, and could affect other server types too.
The text was updated successfully, but these errors were encountered: