Mercurial > hg > nginx-vendor-current
annotate src/core/ngx_regex.c @ 58:b55cbf18157e NGINX_0_1_29
nginx 0.1.29
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; bug appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 12 May 2005 00:00:00 +0400 |
parents | 0d75d65c642f |
children | 9121a0a91f47 |
rev | line source |
---|---|
0 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
52 | 11 static void * ngx_libc_cdecl ngx_regex_malloc(size_t size); |
12 static void ngx_libc_cdecl ngx_regex_free(void *p); | |
0 | 13 |
14 | |
15 static ngx_pool_t *ngx_pcre_pool; | |
16 | |
17 | |
52 | 18 void |
19 ngx_regex_init(void) | |
0 | 20 { |
21 pcre_malloc = ngx_regex_malloc; | |
22 pcre_free = ngx_regex_free; | |
23 } | |
24 | |
25 | |
52 | 26 ngx_regex_t * |
27 ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options, ngx_pool_t *pool, | |
28 ngx_str_t *err) | |
0 | 29 { |
30 int erroff; | |
31 const char *errstr; | |
32 ngx_regex_t *re; | |
33 #if (NGX_THREADS) | |
34 ngx_core_tls_t *tls; | |
35 | |
36 #if (NGX_SUPPRESS_WARN) | |
37 tls = NULL; | |
38 #endif | |
39 | |
40 if (ngx_threaded) { | |
41 tls = ngx_thread_get_tls(ngx_core_tls_key); | |
42 tls->pool = pool; | |
43 } else { | |
44 ngx_pcre_pool = pool; | |
45 } | |
46 | |
47 #else | |
48 | |
49 ngx_pcre_pool = pool; | |
50 | |
51 #endif | |
52 | |
53 re = pcre_compile((const char *) pattern->data, (int) options, | |
54 &errstr, &erroff, NULL); | |
55 | |
56 if (re == NULL) { | |
57 if ((size_t) erroff == pattern->len) { | |
10 | 58 ngx_snprintf(err->data, err->len - 1, |
28 | 59 "pcre_compile() failed: %s in \"%s\"%Z", |
0 | 60 errstr, pattern->data); |
61 } else { | |
10 | 62 ngx_snprintf(err->data, err->len - 1, |
28 | 63 "pcre_compile() failed: %s in \"%s\" at \"%s\"%Z", |
0 | 64 errstr, pattern->data, pattern->data + erroff); |
65 } | |
66 } | |
67 | |
68 /* ensure that there is no current pool */ | |
69 | |
70 #if (NGX_THREADS) | |
71 if (ngx_threaded) { | |
72 tls->pool = NULL; | |
73 } else { | |
74 ngx_pcre_pool = NULL; | |
75 } | |
76 #else | |
77 ngx_pcre_pool = NULL; | |
78 #endif | |
79 | |
80 return re; | |
81 } | |
82 | |
83 | |
52 | 84 ngx_int_t |
85 ngx_regex_capture_count(ngx_regex_t *re) | |
30 | 86 { |
87 int rc, n; | |
88 | |
89 n = 0; | |
90 | |
91 rc = pcre_fullinfo(re, NULL, PCRE_INFO_CAPTURECOUNT, &n); | |
92 | |
50 | 93 if (rc < 0) { |
94 return (ngx_int_t) rc; | |
95 } | |
96 | |
97 return (ngx_int_t) n; | |
30 | 98 } |
99 | |
100 | |
52 | 101 ngx_int_t |
102 ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures, ngx_int_t size) | |
0 | 103 { |
104 int rc; | |
105 | |
106 rc = pcre_exec(re, NULL, (const char *) s->data, s->len, 0, 0, | |
30 | 107 captures, size); |
0 | 108 |
109 if (rc == -1) { | |
30 | 110 return NGX_REGEX_NO_MATCHED; |
0 | 111 } |
112 | |
113 return rc; | |
114 } | |
115 | |
116 | |
52 | 117 static void * ngx_libc_cdecl |
118 ngx_regex_malloc(size_t size) | |
0 | 119 { |
120 ngx_pool_t *pool; | |
121 #if (NGX_THREADS) | |
122 ngx_core_tls_t *tls; | |
123 | |
124 if (ngx_threaded) { | |
125 tls = ngx_thread_get_tls(ngx_core_tls_key); | |
126 pool = tls->pool; | |
127 } else { | |
128 pool = ngx_pcre_pool; | |
129 } | |
130 #else | |
131 pool = ngx_pcre_pool; | |
132 #endif | |
133 | |
134 if (pool) { | |
135 return ngx_palloc(pool, size); | |
136 } | |
137 | |
138 return NULL; | |
139 } | |
140 | |
141 | |
52 | 142 static void ngx_libc_cdecl |
143 ngx_regex_free(void *p) | |
0 | 144 { |
145 return; | |
146 } |