Made QUERY_STRING mandatory.
According to CGI/1.1 RFC 3875:
The server MUST set this variable; if the Script-URI does not include a
query component, the QUERY_STRING MUST be defined as an empty string ("").
Python's PEP 333(3) allows omitting it in WSGI interface; PHP docs force no
requirements; PSGI and Rack specifications require it even if empty.
When nginx proxies requests over FastCGI, it always provides QUERY_STRING.
and some PHP apps have been observed to fail if it is missing (see issue
#201 on GitHub).
A drawback of this change (besides a small overhead) is that there will be
no easy way to tell a missing query string from an empty one (i.e. requests
with or without the "?" character); yet, it's negligible compared to the
possible benefits of wider application compatibility.
This closes #226 issue on GitHub.
This commit is contained in:
@@ -917,10 +917,8 @@ nxt_php_register_variables(zval *track_vars_array TSRMLS_DC)
|
||||
track_vars_array TSRMLS_CC);
|
||||
nxt_php_set_sptr(req, "REQUEST_URI", &r->target, r->target_length,
|
||||
track_vars_array TSRMLS_CC);
|
||||
if (r->query.offset) {
|
||||
nxt_php_set_sptr(req, "QUERY_STRING", &r->query, r->query_length,
|
||||
track_vars_array TSRMLS_CC);
|
||||
}
|
||||
|
||||
nxt_php_set_sptr(req, "REMOTE_ADDR", &r->remote, r->remote_length,
|
||||
track_vars_array TSRMLS_CC);
|
||||
|
||||
@@ -720,11 +720,7 @@ nxt_python_get_environ(nxt_python_run_ctx_t *ctx)
|
||||
RC(nxt_python_add_sptr(ctx, "REQUEST_METHOD", &r->method,
|
||||
r->method_length));
|
||||
RC(nxt_python_add_sptr(ctx, "REQUEST_URI", &r->target, r->target_length));
|
||||
|
||||
if (r->query.offset) {
|
||||
RC(nxt_python_add_sptr(ctx, "QUERY_STRING", &r->query,
|
||||
r->query_length));
|
||||
}
|
||||
RC(nxt_python_add_sptr(ctx, "QUERY_STRING", &r->query, r->query_length));
|
||||
RC(nxt_python_add_sptr(ctx, "PATH_INFO", &r->path, r->path_length));
|
||||
|
||||
RC(nxt_python_add_sptr(ctx, "REMOTE_ADDR", &r->remote, r->remote_length));
|
||||
|
||||
@@ -548,10 +548,8 @@ nxt_perl_psgi_env_create(PerlInterpreter *my_perl,
|
||||
RC(nxt_perl_psgi_add_value(my_perl, hash_env, NL("psgi.streaming"),
|
||||
&PL_sv_no));
|
||||
|
||||
if (r->query.offset) {
|
||||
RC(nxt_perl_psgi_add_sptr(my_perl, hash_env, NL("QUERY_STRING"),
|
||||
&r->query, r->query_length));
|
||||
}
|
||||
RC(nxt_perl_psgi_add_sptr(my_perl, hash_env, NL("SERVER_PROTOCOL"),
|
||||
&r->version, r->version_length));
|
||||
RC(nxt_perl_psgi_add_sptr(my_perl, hash_env, NL("REMOTE_ADDR"),
|
||||
|
||||
@@ -442,10 +442,8 @@ nxt_ruby_read_request(VALUE hash_env)
|
||||
nxt_ruby_add_sptr(hash_env, NL("REQUEST_URI"), &r->target,
|
||||
r->target_length);
|
||||
nxt_ruby_add_sptr(hash_env, NL("PATH_INFO"), &r->path, r->path_length);
|
||||
if (r->query.offset) {
|
||||
nxt_ruby_add_sptr(hash_env, NL("QUERY_STRING"), &r->query,
|
||||
r->query_length);
|
||||
}
|
||||
nxt_ruby_add_sptr(hash_env, NL("SERVER_PROTOCOL"), &r->version,
|
||||
r->version_length);
|
||||
nxt_ruby_add_sptr(hash_env, NL("REMOTE_ADDR"), &r->remote,
|
||||
|
||||
@@ -65,7 +65,6 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython):
|
||||
self.assertEqual(resp['headers']['Query-String'], '',
|
||||
'query string empty')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_python_application_query_string_absent(self):
|
||||
self.load('query_string')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user