summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_php_sapi.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-02-27 17:25:07 +0300
committerValentin Bartenev <vbart@nginx.com>2019-02-27 17:25:07 +0300
commite929d08201aae949db25ae8c1051a91e96ba3011 (patch)
tree76af15b49cb67547dbd1942466a6bb360459fc6b /src/nxt_php_sapi.c
parenta881c31abdb9fda2ba0d2e05c45c2ce890a6cfab (diff)
downloadunit-e929d08201aae949db25ae8c1051a91e96ba3011.tar.gz
unit-e929d08201aae949db25ae8c1051a91e96ba3011.tar.bz2
Fixed processing of SERVER_NAME after 77aad2c142a0.
Previously, the nxt_router_prepare_msg() function expected server host among other headers unmodified. It's not true anymore since normalization of the Host header has been introduced in 77aad2c142a0. The nxt_unit_split_host() function was removed. It didn't work correctly with IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router while Host header processing.
Diffstat (limited to 'src/nxt_php_sapi.c')
-rw-r--r--src/nxt_php_sapi.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c
index 8c25f82a..559a3e37 100644
--- a/src/nxt_php_sapi.c
+++ b/src/nxt_php_sapi.c
@@ -62,7 +62,7 @@ static void nxt_php_set_sptr(nxt_unit_request_info_t *req, const char *name,
nxt_inline void nxt_php_set_str(nxt_unit_request_info_t *req, const char *name,
nxt_str_t *s, zval *track_vars_array TSRMLS_DC);
static void nxt_php_set_cstr(nxt_unit_request_info_t *req, const char *name,
- char *str, uint32_t len, zval *track_vars_array TSRMLS_DC);
+ const char *str, uint32_t len, zval *track_vars_array TSRMLS_DC);
static void nxt_php_register_variables(zval *track_vars_array TSRMLS_DC);
#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE
static void nxt_php_log_message(char *message, int syslog_type_int);
@@ -846,8 +846,6 @@ nxt_php_read_cookies(TSRMLS_D)
static void
nxt_php_register_variables(zval *track_vars_array TSRMLS_DC)
{
- char *host_start, *port_start;
- uint32_t host_length, port_length;
const char *name;
nxt_unit_field_t *f, *f_end;
nxt_php_run_ctx_t *ctx;
@@ -928,6 +926,10 @@ nxt_php_register_variables(zval *track_vars_array TSRMLS_DC)
nxt_php_set_sptr(req, "SERVER_ADDR", &r->local, r->local_length,
track_vars_array TSRMLS_CC);
+ nxt_php_set_sptr(req, "SERVER_NAME", &r->server_name, r->server_name_length,
+ track_vars_array TSRMLS_CC);
+ nxt_php_set_cstr(req, "SERVER_PORT", "80", 2, track_vars_array TSRMLS_CC);
+
f_end = r->fields + r->fields_count;
for (f = r->fields; f < f_end; f++) {
name = nxt_unit_sptr_get(&f->name);
@@ -949,25 +951,6 @@ nxt_php_register_variables(zval *track_vars_array TSRMLS_DC)
nxt_php_set_sptr(req, "CONTENT_TYPE", &f->value, f->value_length,
track_vars_array TSRMLS_CC);
}
-
- if (r->host_field != NXT_UNIT_NONE_FIELD) {
- f = r->fields + r->host_field;
-
- host_start = nxt_unit_sptr_get(&f->value);
- host_length = f->value_length;
-
- } else {
- host_start = NULL;
- host_length = 0;
- }
-
- nxt_unit_split_host(host_start, host_length, &host_start, &host_length,
- &port_start, &port_length);
-
- nxt_php_set_cstr(req, "SERVER_NAME", host_start, host_length,
- track_vars_array TSRMLS_CC);
- nxt_php_set_cstr(req, "SERVER_PORT", port_start, port_length,
- track_vars_array TSRMLS_CC);
}
@@ -997,7 +980,7 @@ nxt_php_set_str(nxt_unit_request_info_t *req, const char *name,
static void
nxt_php_set_cstr(nxt_unit_request_info_t *req, const char *name,
- char *cstr, uint32_t len, zval *track_vars_array TSRMLS_DC)
+ const char *cstr, uint32_t len, zval *track_vars_array TSRMLS_DC)
{
if (nxt_slow_path(cstr == NULL)) {
return;
@@ -1005,7 +988,7 @@ nxt_php_set_cstr(nxt_unit_request_info_t *req, const char *name,
nxt_unit_req_debug(req, "php: register %s='%.*s'", name, (int) len, cstr);
- php_register_variable_safe((char *) name, cstr, len,
+ php_register_variable_safe((char *) name, (char *) cstr, len,
track_vars_array TSRMLS_CC);
}