Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_script.c @ 126:df17fbafec8f NGINX_0_3_10
nginx 0.3.10
*) Change: the "valid_referers" directive and the "$invalid_referer"
variable were moved to the new ngx_http_referer_module from the
ngx_http_rewrite_module.
*) Change: the "$apache_bytes_sent" variable name was changed to
"$body_bytes_sent".
*) Feature: the "$sent_http_..." variables.
*) Feature: the "if" directive supports the "=" and "!=" operations.
*) Feature: the "proxy_pass" directive supports the HTTPS protocol.
*) Feature: the "proxy_set_body" directive.
*) Feature: the "post_action" directive.
*) Feature: the ngx_http_empty_gif_module.
*) Feature: the "worker_cpu_affinity" directive for Linux.
*) Bugfix: the "rewrite" directive did not unescape URI part in
redirect, now it is unescaped except the %00-%25 and %7F-%FF
characters.
*) Bugfix: nginx could not be built by the icc 9.0 compiler.
*) Bugfix: if the SSI was enabled for zero size static file, then the
chunked response was encoded incorrectly.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 15 Nov 2005 00:00:00 +0300 |
parents | d25a1d6034f1 |
children | 50bd986c5d63 |
comparison
equal
deleted
inserted
replaced
125:97504de1f89e | 126:df17fbafec8f |
---|---|
501 void | 501 void |
502 ngx_http_script_start_args_code(ngx_http_script_engine_t *e) | 502 ngx_http_script_start_args_code(ngx_http_script_engine_t *e) |
503 { | 503 { |
504 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | 504 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, |
505 "http script args"); | 505 "http script args"); |
506 | 506 |
507 e->args = e->pos; | 507 e->args = e->pos; |
508 e->ip += sizeof(uintptr_t); | 508 e->ip += sizeof(uintptr_t); |
509 } | 509 } |
510 | 510 |
511 | 511 |
662 | 662 |
663 | 663 |
664 void | 664 void |
665 ngx_http_script_regex_end_code(ngx_http_script_engine_t *e) | 665 ngx_http_script_regex_end_code(ngx_http_script_engine_t *e) |
666 { | 666 { |
667 u_char *dst, *src; | |
667 ngx_http_request_t *r; | 668 ngx_http_request_t *r; |
668 ngx_http_script_regex_end_code_t *code; | 669 ngx_http_script_regex_end_code_t *code; |
669 | 670 |
670 code = (ngx_http_script_regex_end_code_t *) e->ip; | 671 code = (ngx_http_script_regex_end_code_t *) e->ip; |
671 | 672 |
676 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 677 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
677 "http script regex end"); | 678 "http script regex end"); |
678 | 679 |
679 if (code->redirect) { | 680 if (code->redirect) { |
680 | 681 |
681 if (code->add_args && r->args.len) { | 682 dst = e->buf.data; |
683 src = e->buf.data; | |
684 | |
685 ngx_unescape_uri(&dst, &src, e->pos - e->buf.data); | |
686 | |
687 if (src < e->pos) { | |
688 dst = ngx_copy(dst, src, e->pos - src); | |
689 } | |
690 | |
691 e->pos = dst; | |
692 | |
693 if (code->add_args && r->args.len) { | |
682 *e->pos++ = (u_char) (code->args ? '&' : '?'); | 694 *e->pos++ = (u_char) (code->args ? '&' : '?'); |
683 e->pos = ngx_copy(e->pos, r->args.data, r->args.len); | 695 e->pos = ngx_copy(e->pos, r->args.data, r->args.len); |
684 } | 696 } |
685 | 697 |
686 e->buf.len = e->pos - e->buf.data; | 698 e->buf.len = e->pos - e->buf.data; |
695 e->ip = ngx_http_script_exit; | 707 e->ip = ngx_http_script_exit; |
696 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; | 708 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; |
697 return; | 709 return; |
698 } | 710 } |
699 | 711 |
700 r->headers_out.location->hash = 1; | 712 r->headers_out.location->hash = 1; |
701 r->headers_out.location->key.len = sizeof("Location") - 1; | 713 r->headers_out.location->key.len = sizeof("Location") - 1; |
702 r->headers_out.location->key.data = (u_char *) "Location"; | 714 r->headers_out.location->key.data = (u_char *) "Location"; |
703 r->headers_out.location->value = e->buf; | 715 r->headers_out.location->value = e->buf; |
704 | 716 |
705 e->ip += sizeof(ngx_http_script_regex_end_code_t); | 717 e->ip += sizeof(ngx_http_script_regex_end_code_t); |
706 return; | 718 return; |
707 } | 719 } |
708 | 720 |
709 if (e->args) { | 721 if (e->args) { |
710 e->buf.len = e->args - e->buf.data; | 722 e->buf.len = e->args - e->buf.data; |
711 | 723 |
712 if (code->add_args && r->args.len) { | 724 if (code->add_args && r->args.len) { |
713 *e->pos++ = '&'; | 725 *e->pos++ = '&'; |
714 e->pos = ngx_copy(e->pos, r->args.data, r->args.len); | 726 e->pos = ngx_copy(e->pos, r->args.data, r->args.len); |
753 #endif | 765 #endif |
754 | 766 |
755 | 767 |
756 void | 768 void |
757 ngx_http_script_return_code(ngx_http_script_engine_t *e) | 769 ngx_http_script_return_code(ngx_http_script_engine_t *e) |
758 { | 770 { |
759 ngx_http_script_return_code_t *code; | 771 ngx_http_script_return_code_t *code; |
760 | 772 |
761 code = (ngx_http_script_return_code_t *) e->ip; | 773 code = (ngx_http_script_return_code_t *) e->ip; |
762 | 774 |
763 e->status = code->status; | 775 e->status = code->status; |
764 | 776 |
765 e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t); | 777 e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t); |
796 e->ip += sizeof(ngx_http_script_if_code_t); | 808 e->ip += sizeof(ngx_http_script_if_code_t); |
797 return; | 809 return; |
798 } | 810 } |
799 | 811 |
800 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | 812 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, |
801 "http script if false"); | 813 "http script if: false"); |
802 | 814 |
803 e->ip += code->next; | 815 e->ip += code->next; |
816 } | |
817 | |
818 | |
819 void | |
820 ngx_http_script_equal_code(ngx_http_script_engine_t *e) | |
821 { | |
822 ngx_http_variable_value_t *val, *res; | |
823 | |
824 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
825 "http script equal"); | |
826 | |
827 e->sp--; | |
828 val = e->sp; | |
829 res = e->sp - 1; | |
830 | |
831 e->ip += sizeof(uintptr_t); | |
832 | |
833 if (val->len == res->len && ngx_strncmp(val->data, res->data, res->len) | |
834 == 0) | |
835 { | |
836 *res = ngx_http_variable_true_value; | |
837 return; | |
838 } | |
839 | |
840 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
841 "http script equal: no"); | |
842 | |
843 *res = ngx_http_variable_null_value; | |
844 } | |
845 | |
846 | |
847 void | |
848 ngx_http_script_not_equal_code(ngx_http_script_engine_t *e) | |
849 { | |
850 ngx_http_variable_value_t *val, *res; | |
851 | |
852 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
853 "http script not equal"); | |
854 | |
855 e->sp--; | |
856 val = e->sp; | |
857 res = e->sp - 1; | |
858 | |
859 e->ip += sizeof(uintptr_t); | |
860 | |
861 if (val->len == res->len && ngx_strncmp(val->data, res->data, res->len) | |
862 == 0) | |
863 { | |
864 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
865 "http script not equal: no"); | |
866 | |
867 *res = ngx_http_variable_null_value; | |
868 return; | |
869 } | |
870 | |
871 *res = ngx_http_variable_true_value; | |
804 } | 872 } |
805 | 873 |
806 | 874 |
807 void | 875 void |
808 ngx_http_script_complex_value_code(ngx_http_script_engine_t *e) | 876 ngx_http_script_complex_value_code(ngx_http_script_engine_t *e) |
838 return; | 906 return; |
839 } | 907 } |
840 | 908 |
841 e->pos = e->buf.data; | 909 e->pos = e->buf.data; |
842 | 910 |
911 e->sp->len = e->buf.len; | |
843 e->sp->data = e->buf.data; | 912 e->sp->data = e->buf.data; |
844 e->sp->len = e->buf.len; | |
845 e->sp++; | 913 e->sp++; |
846 } | 914 } |
847 | 915 |
848 | 916 |
849 void | 917 void |
852 ngx_http_script_value_code_t *code; | 920 ngx_http_script_value_code_t *code; |
853 | 921 |
854 code = (ngx_http_script_value_code_t *) e->ip; | 922 code = (ngx_http_script_value_code_t *) e->ip; |
855 | 923 |
856 e->ip += sizeof(ngx_http_script_value_code_t); | 924 e->ip += sizeof(ngx_http_script_value_code_t); |
857 | |
858 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
859 "http script value"); | |
860 | 925 |
861 e->sp->len = code->text_len; | 926 e->sp->len = code->text_len; |
862 e->sp->data = (u_char *) code->text_data; | 927 e->sp->data = (u_char *) code->text_data; |
928 | |
929 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0, | |
930 "http script value: \"%V\"", e->sp); | |
931 | |
863 e->sp++; | 932 e->sp++; |
864 } | 933 } |
865 | 934 |
866 | 935 |
867 void | 936 void |
912 e->sp++; | 981 e->sp++; |
913 | 982 |
914 return; | 983 return; |
915 } | 984 } |
916 | 985 |
917 e->sp->data = (u_char *) ""; | 986 *e->sp = ngx_http_variable_null_value; |
918 e->sp->len = 0; | |
919 e->sp++; | 987 e->sp++; |
920 } | 988 } |
921 | 989 |
922 | 990 |
923 void | 991 void |