mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
fix #36400 (Custom 5xx error does not return correct HTTP response error code)
This commit is contained in:
parent
aa4cfd6d2f
commit
eb49217161
1 changed files with 20 additions and 1 deletions
|
@ -63,6 +63,7 @@ static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTabl
|
||||||
/* ### these should be defined in mod_php5.h or somewhere else */
|
/* ### these should be defined in mod_php5.h or somewhere else */
|
||||||
#define USE_PATH 1
|
#define USE_PATH 1
|
||||||
#define IGNORE_URL 2
|
#define IGNORE_URL 2
|
||||||
|
#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION")
|
||||||
|
|
||||||
module MODULE_VAR_EXPORT php5_module;
|
module MODULE_VAR_EXPORT php5_module;
|
||||||
|
|
||||||
|
@ -204,17 +205,35 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
|
||||||
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
|
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
|
||||||
{
|
{
|
||||||
request_rec *r = SG(server_context);
|
request_rec *r = SG(server_context);
|
||||||
|
char *status_buf = NULL;
|
||||||
|
const char *sline = SG(sapi_headers).http_status_line;
|
||||||
|
int sline_len;
|
||||||
|
|
||||||
if(r == NULL) { /* server_context is not here anymore */
|
if(r == NULL) { /* server_context is not here anymore */
|
||||||
return SAPI_HEADER_SEND_FAILED;
|
return SAPI_HEADER_SEND_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->status = SG(sapi_headers).http_response_code;
|
r->status = SG(sapi_headers).http_response_code;
|
||||||
|
|
||||||
|
/* httpd requires that r->status_line is set to the first digit of
|
||||||
|
* the status-code: */
|
||||||
|
if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') {
|
||||||
|
if ((sline_len - 9) > MAX_STATUS_LENGTH) {
|
||||||
|
status_buf = estrndup(sline + 9, MAX_STATUS_LENGTH);
|
||||||
|
} else {
|
||||||
|
status_buf = estrndup(sline + 9, sline_len - 9);
|
||||||
|
}
|
||||||
|
r->status_line = status_buf;
|
||||||
|
}
|
||||||
|
|
||||||
if(r->status==304) {
|
if(r->status==304) {
|
||||||
send_error_response(r,0);
|
send_error_response(r,0);
|
||||||
} else {
|
} else {
|
||||||
send_http_header(r);
|
send_http_header(r);
|
||||||
}
|
}
|
||||||
|
if (status_buf) {
|
||||||
|
efree(status_buf);
|
||||||
|
}
|
||||||
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue