summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_variables.c (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2018-12-11Copy regex unnamed captures to cloned subrequests.Roman Arutyunyan1-1/+3
Previously, unnamed regex captures matched in the parent request, were not available in a cloned subrequest. Now 3 fields related to unnamed captures are copied to a cloned subrequest: r->ncaptures, r->captures and r->captures_data. Since r->captures cannot be changed by either request after creating a clone, a new flag r->realloc_captures is introduced to force reallocation of r->captures. The issue was reported as a proxy_cache_background_update misbehavior in http://mailman.nginx.org/pipermail/nginx/2018-December/057251.html.
2018-03-07Improved code readablity.Ruslan Ermilov1-2/+6
No functional changes.
2018-02-08Basic support of the Link response header.Ruslan Ermilov1-0/+3
2017-10-04Fixed handling of unix sockets in $binary_remote_addr.Maxim Dounin1-0/+12
Previously, unix sockets were treated as AF_INET ones, and this may result in buffer overread on Linux, where unbound unix sockets have 2-byte addresses. Note that it is not correct to use just sun_path as a binary representation for unix sockets. This will result in an empty string for unbound unix sockets, and thus behaviour of limit_req and limit_conn will change when switching from $remote_addr to $binary_remote_addr. As such, normal text representation is used. Reported by Stephan Dollberg.
2017-08-01Variables: macros for null variables.Ruslan Ermilov1-1/+1
No functional changes.
2017-07-07Variables: use ngx_http_variable_null_value where appropriate.Ruslan Ermilov1-11/+5
2017-03-24Added support for trailers in HTTP responses.Piotr Sikora1-0/+15
Example: ngx_table_elt_t *h; h = ngx_list_push(&r->headers_out.trailers); if (h == NULL) { return NGX_ERROR; } ngx_str_set(&h->key, "Fun"); ngx_str_set(&h->value, "with trailers"); h->hash = ngx_hash_key_lc(h->key.data, h->key.len); The code above adds "Fun: with trailers" trailer to the response. Modules that want to emit trailers must set r->expect_trailers = 1 in header filter, otherwise they might not be emitted for HTTP/1.1 responses that aren't already chunked. This change also adds $sent_trailer_* variables. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-01-31Variables: generic prefix variables.Dmitry Volyntsev1-122/+118
2016-12-21Limited recursion when evaluating variables.Ruslan Ermilov1-6/+30
Unlimited recursion might cause stack exhaustion in some misconfigurations.
2016-06-20Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.Roman Arutyunyan1-50/+4
2016-05-23Added the $proxy_protocol_port variable.Dmitry Volyntsev1-0/+31
2016-04-26Variable $request_id.Vladimir Homutov1-0/+47
The variable contains text representation based on random data, usable as a unique request identifier.
2016-03-31Fixed logging with variable field width.Sergey Kandaurov1-3/+2
2015-10-19Fixed variables prefix comparison.Maxim Dounin1-12/+26
Variable names are not null-terminated, so using ngx_strncmp() without extra length checks is wrong. Reported by Markus Linnala, http://mailman.nginx.org/pipermail/nginx-devel/2015-August/007211.html.
2015-03-23Request body: unbuffered reading.Maxim Dounin1-0/+4
The r->request_body_no_buffering flag was introduced. It instructs client request body reading code to avoid reading the whole body, and to call post_handler early instead. The caller should use the ngx_http_read_unbuffered_request_body() function to read remaining parts of the body. Upstream module is now able to use this mode, if configured with the proxy_request_buffering directive.
2014-08-27Variables: fixed non-indexed access of prefix vars (ticket #600).Maxim Dounin1-2/+5
Previously, a configuration like location / { ssi on; ssi_types *; set $http_foo "bar"; return 200 '<!--#echo var="http_foo" -->\n'; } resulted in NULL pointer dereference in ngx_http_get_variable() as the variable was explicitly added to the variables hash, but its get_handler wasn't properly set in the hash. Fix is to make sure that get_handler is properly set by ngx_http_variables_init_vars().
2014-05-19Setting $args now invalidates unparsed uri.Maxim Dounin1-1/+19
Prodded by Yichun Zhang.
2014-04-29Upstream: added the "$upstream_cookie_<name>" variables.Vladimir Homutov1-0/+19
2014-03-17Added server-side support for PROXY protocol v1 (ticket #355).Roman Arutyunyan1-0/+19
Client address specified in the PROXY protocol header is now saved in the $proxy_protocol_addr variable and can be used in the realip module. This is currently not implemented for mail.
2013-12-09Fixed handling of UNIX-domain sockets.Ruslan Ermilov1-0/+12
When evaluating $local_port, $server_port, and $server_addr, UNIX-domain sockets were mistakenly interpreted as IPv4 sockets.
2013-10-31Removed extra allocation for $sent_http_last_modified.Maxim Dounin1-2/+1
There is no need to allocate memory for "Last-Modified: " string, the variable only contains date itself.
2013-09-04Win32: $request_time fixed.Maxim Dounin1-1/+1
On win32, time_t is 64 bits wide by default, and passing an ngx_msec_int_t argument for %T format specifier doesn't work. This doesn't manifest itself on other platforms as time_t and ngx_msec_int_t are usually of the same size.
2013-08-20Format specifier fixes in error logging.Sergey Kandaurov1-1/+1
2013-08-06Fixed memory leaks in the root and auth_basic_user_file directives.Valentin Bartenev1-2/+6
If a relative path is set by variables, then the ngx_conf_full_name() function was called while processing requests, which causes allocations from the cycle pool. A new function that takes pool as an argument was introduced.
2013-05-02PCRE: retain input pattern for all regular expressions.Piotr Sikora1-1/+1
Previously, input pattern was kept only for regular expressions with named captures, which resulted in error log entries without input pattern for PCRE errors that occured while processing regular expressions without them. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2013-02-27Correctly handle multiple X-Forwarded-For headers (ticket #106).Ruslan Ermilov1-3/+3
2013-02-27Fixed separator in $sent_http_cache_control.Ruslan Ermilov1-6/+27
In case multiple "Cache-Control" headers are sent to a client, multiple values in $sent_http_cache_control were incorrectly split by a semicolon. Now they are split by a comma.
2013-02-18Proxy: support for connection upgrade (101 Switching Protocols).Maxim Dounin1-1/+5
This allows to proxy WebSockets by using configuration like this: location /chat/ { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } Connection upgrade is allowed as long as it was requested by a client via the Upgrade request header.
2013-01-21Variables $pipe, $request_length, $time_iso8601, and $time_local.Ruslan Ermilov1-0/+102
Log module counterparts are preserved for efficiency. Based on patch by Kiril Kalchev.
2012-12-17Added checks that disallow adding a variable with an empty name.Ruslan Ermilov1-0/+12
Added variable name syntax checks to "geo" and "map" directives.
2012-11-21Request body: $content_length variable to honor real body size.Maxim Dounin1-2/+37
This allows to handle requests with chunked body by fastcgi and uwsgi modules, and also simplifies handling of various request body modifications.
2012-11-21Request body: $request_body variable generalization.Maxim Dounin1-5/+13
The $request_body variable was assuming there can't be more than two buffers. While this is currently true due to request body reading implementation details, this is not a good thing to depend on and may change in the future.
2012-11-16Variables $request_time and $msec.Ruslan Ermilov1-0/+63
Log module counterparts are preserved for efficiency.
2012-10-29Variables $connection and $connection_requests.Maxim Dounin1-0/+53
Log module counterparts are removed as they aren't used often and there is no need to preserve them for efficiency.
2012-10-03Variable $bytes_sent.Maxim Dounin1-0/+26
It replicates variable $bytes_sent as previously available in log module only. Patch by Benjamin Grössing (with minor changes).
2012-06-21Fixed compile-time conditionals used to detect if X-Forwarded-For supportRuslan Ermilov1-1/+1
is needed.
2012-06-18Style fix.Andrey Belov1-1/+1
2012-06-18New core variable: $status.Andrey Belov1-0/+39
Contains response status code as a 3-digit integer (with leading zeroes if necessary), or one of the following values: 000 - response status code has not yet been assigned 009 - HTTP/0.9 request is being processed
2012-05-17Fixed core variables dynamic access after reconfiguration.Maxim Dounin1-2/+9
If variable was indexed in previous configuration but not in current one, the NGX_HTTP_VAR_INDEXED flag was left set and confused ngx_http_get_variable(). Patch by Yichun Zhang (agentzh), slightly modified.
2012-04-03Fixed spelling in multiline C comments.Ruslan Ermilov1-1/+1
2012-03-27Fixed unconditional MAX_PATH usage (ticket #22).Maxim Dounin1-2/+20
POSIX doesn't require it to be defined, and Debian GNU/Hurd doesn't define it. Note that if there is no MAX_PATH defined we have to use realpath() with NULL argument and free() the result.
2012-03-16Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, andRuslan Ermilov1-0/+73
$tcpinfo_rcv_space variables. Supported on Linux and FreeBSD.
2012-03-15Slight optimization in ngx_http_get_variable_index().Ruslan Ermilov1-1/+1
2012-02-13Variables: honor no_cacheable for not_found variables.Maxim Dounin1-1/+1
Variables with the "not_found" flag set follow the same rules as ones with the "valid" flag set. Make sure ngx_http_get_flushed_variable() will flush non-cacheable variables with the "not_found" flag set. This fixes at least one known problem with $args not available in a subrequest (with args) when there were no args in the main request and $args variable was queried in the main request (reported by Laurence Rowe aka elro on irc). Also this eliminates unneeded call to ngx_http_get_indexed_variable() in cacheable case (as it will return cached value anyway).
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-12-09Fixed: some of $sent_http_* variables may contain header entries that actuallyValentin Bartenev1-12/+29
haven't been sent to a client. The ngx_http_variable_headers() and ngx_http_variable_unknown_header() functions did not ignore response header entries with zero "hash" field. Thanks to Yichun Zhang (agentzh).
2011-12-09Added the $https variable.Valentin Bartenev1-0/+28
2011-05-30change ngx_http_map_find(): use case sensitive regexesIgor Sysoev1-6/+22
2011-03-16allow regex as "map" parameterIgor Sysoev1-0/+44
2010-06-23change ngx_http_variable_value_node_t to more generic ngx_str_node_tIgor Sysoev1-84/+0