From 924165c90ba51dd4ffea2c45541d46af56352d73 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Fri, 5 Jul 2019 18:42:30 +0300 Subject: PHP: improved response status code handling. There's no reason to parse "http_status_line"; the PHP interpreter already does this. If the line contains a valid status code, it's assigned to "http_response_code". This also fixes invalid status line handling, where the nxt_int_parse() function returned -1; it was cast to unsigned, yielding response code 65535. --- src/nxt_php_sapi.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/nxt_php_sapi.c') diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index df7cf243..dfad9eb8 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -730,7 +730,7 @@ static int nxt_php_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { int rc, fields_count; - char *colon, *status_line, *value; + char *colon, *value; uint16_t status; uint32_t resp_size; nxt_php_run_ctx_t *ctx; @@ -762,17 +762,7 @@ nxt_php_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) resp_size += h->header_len; } - if (SG(sapi_headers).http_status_line) { - status_line = SG(sapi_headers).http_status_line; - - status = nxt_int_parse((u_char *) status_line + 9, 3); - - } else if (SG(sapi_headers).http_response_code) { - status = SG(sapi_headers).http_response_code; - - } else { - status = 200; - } + status = SG(sapi_headers).http_response_code; rc = nxt_unit_response_init(req, status, fields_count, resp_size); if (nxt_slow_path(rc != NXT_UNIT_OK)) { -- cgit