comparison src/http/ngx_http_script.c @ 546:e19e5f542878 NGINX_0_8_25

nginx 0.8.25 *) Change: now no message is written in an error log if a variable is not found by $r->variable() method. *) Feature: the ngx_http_degradation_module. *) Feature: regular expression named captures. *) Feature: now URI part is not required a "proxy_pass" directive if variables are used. *) Feature: now the "msie_padding" directive works for Chrome too. *) Bugfix: a segmentation fault occurred in a worker process on low memory condition; the bug had appeared in 0.8.18. *) Bugfix: nginx sent gzipped responses to clients those do not support gzip, if "gzip_static on" and "gzip_vary off"; the bug had appeared in 0.8.16.
author Igor Sysoev <http://sysoev.ru>
date Mon, 16 Nov 2009 00:00:00 +0300
parents f7ec98e3caeb
children ab7d265273ed
comparison
equal deleted inserted replaced
545:91e4b06e1a01 546:e19e5f542878
249 249
250 #if (NGX_PCRE) 250 #if (NGX_PCRE)
251 { 251 {
252 ngx_uint_t n; 252 ngx_uint_t n;
253 253
254 /* NGX_HTTP_MAX_CAPTURES is 9 */
255
256 if (sc->source->data[i] >= '1' && sc->source->data[i] <= '9') { 254 if (sc->source->data[i] >= '1' && sc->source->data[i] <= '9') {
257 255
258 n = sc->source->data[i] - '0'; 256 n = sc->source->data[i] - '0';
259 257
260 if (sc->captures_mask & (1 << n)) { 258 if (sc->captures_mask & (1 << n)) {
826 e->sp--; 824 e->sp--;
827 e->line.len = e->sp->len; 825 e->line.len = e->sp->len;
828 e->line.data = e->sp->data; 826 e->line.data = e->sp->data;
829 } 827 }
830 828
831 if (code->ncaptures && r->captures == NULL) { 829 rc = ngx_http_regex_exec(r, code->regex, &e->line);
832 830
833 r->captures = ngx_palloc(r->pool, 831 if (rc == NGX_DECLINED) {
834 (NGX_HTTP_MAX_CAPTURES + 1) * 3 * sizeof(int));
835 if (r->captures == NULL) {
836 e->ip = ngx_http_script_exit;
837 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
838 return;
839 }
840 }
841
842 rc = ngx_regex_exec(code->regex, &e->line, r->captures, code->ncaptures);
843
844 if (rc == NGX_REGEX_NO_MATCHED) {
845 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) { 832 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
846 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, 833 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
847 "\"%V\" does not match \"%V\"", 834 "\"%V\" does not match \"%V\"",
848 &code->name, &e->line); 835 &code->name, &e->line);
849 } 836 }
868 855
869 e->ip += code->next; 856 e->ip += code->next;
870 return; 857 return;
871 } 858 }
872 859
873 if (rc < 0) { 860 if (rc == NGX_ERROR) {
874 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
875 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"",
876 rc, &e->line, &code->name);
877
878 e->ip = ngx_http_script_exit; 861 e->ip = ngx_http_script_exit;
879 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; 862 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
880 return; 863 return;
881 } 864 }
882 865
883 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) { 866 if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
884 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0, 867 ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
885 "\"%V\" matches \"%V\"", &code->name, &e->line); 868 "\"%V\" matches \"%V\"", &code->name, &e->line);
886 } 869 }
887
888 r->ncaptures = code->ncaptures;
889 r->captures_data = e->line.data;
890 870
891 if (code->test) { 871 if (code->test) {
892 if (code->negative_test) { 872 if (code->negative_test) {
893 e->sp->len = 0; 873 e->sp->len = 0;
894 e->sp->data = (u_char *) ""; 874 e->sp->data = (u_char *) "";