comparison src/http/modules/perl/nginx.xs @ 254:f3ec44f4a53b NGINX_0_4_12

nginx 0.4.12 *) Feature: the ngx_http_perl_module supports the $r->variable method. *) Bugfix: if a big static file was included using SSI in a response, then the response may be transferred incomplete. *) Bugfix: nginx did not omit the "#fragment" part in URI.
author Igor Sysoev <http://sysoev.ru>
date Tue, 31 Oct 2006 00:00:00 +0300
parents 644510700914
children 6ae1357b7b7c
comparison
equal deleted inserted replaced
253:b75231e1a353 254:f3ec44f4a53b
761 *dst = '\0'; 761 *dst = '\0';
762 762
763 ngx_http_perl_set_targ(p, dst - p, 1); 763 ngx_http_perl_set_targ(p, dst - p, 1);
764 764
765 ST(0) = TARG; 765 ST(0) = TARG;
766
767
768 void
769 variable(r, name, value = NULL)
770 CODE:
771
772 dXSTARG;
773 ngx_http_request_t *r;
774 SV *name, *value;
775 u_char *p, *lowcase;
776 STRLEN len;
777 ngx_str_t var, val;
778 ngx_uint_t i, hash;
779 ngx_http_variable_value_t *vv;
780
781 ngx_http_perl_set_request(r);
782
783 name = ST(1);
784
785 if (SvROK(name) && SvTYPE(SvRV(name)) == SVt_PV) {
786 name = SvRV(name);
787 }
788
789 if (items == 2) {
790 value = NULL;
791
792 } else {
793 value = ST(2);
794
795 if (SvROK(value) && SvTYPE(SvRV(value)) == SVt_PV) {
796 value = SvRV(value);
797 }
798
799 if (ngx_http_perl_sv2str(aTHX_ r, &val, value) != NGX_OK) {
800 XSRETURN_UNDEF;
801 }
802 }
803
804 p = (u_char *) SvPV(name, len);
805
806 lowcase = ngx_palloc(r->pool, len);
807 if (lowcase == NULL) {
808 XSRETURN_UNDEF;
809 }
810
811 hash = 0;
812 for (i = 0; i < len; i++) {
813 lowcase[i] = ngx_tolower(p[i]);
814 hash = ngx_hash(hash, lowcase[i]);
815 }
816
817 var.len = len;
818 var.data = lowcase;
819
820 vv = ngx_http_get_variable(r, &var, hash, 1);
821 if (vv == NULL) {
822 XSRETURN_UNDEF;
823 }
824
825 if (vv->not_found) {
826 if (value == NULL) {
827 XSRETURN_UNDEF;
828 }
829
830 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
831 "variable \"%V\" not found", &var);
832
833 XSRETURN_UNDEF;
834 }
835
836 if (value) {
837 vv->len = val.len;
838 vv->valid = 1;
839 vv->no_cachable = 0;
840 vv->not_found = 0;
841 vv->data = val.data;
842
843 XSRETURN_UNDEF;
844 }
845
846 ngx_http_perl_set_targ(vv->data, vv->len, 0);
847
848 ST(0) = TARG;