summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_php_sapi.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-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);
}