nginxtra 1.0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -0
- data/bin/nginxtra +5 -0
- data/lib/nginxtra.rb +12 -0
- data/lib/nginxtra/action.rb +36 -0
- data/lib/nginxtra/actions/compile.rb +60 -0
- data/lib/nginxtra/actions/install.rb +99 -0
- data/lib/nginxtra/actions/reload.rb +14 -0
- data/lib/nginxtra/actions/restart.rb +15 -0
- data/lib/nginxtra/actions/start.rb +53 -0
- data/lib/nginxtra/actions/status.rb +31 -0
- data/lib/nginxtra/actions/stop.rb +14 -0
- data/lib/nginxtra/cli.rb +77 -0
- data/lib/nginxtra/config.rb +339 -0
- data/lib/nginxtra/error.rb +13 -0
- data/lib/nginxtra/status.rb +57 -0
- data/src/nginx/CHANGES +5630 -0
- data/src/nginx/CHANGES.ru +5716 -0
- data/src/nginx/LICENSE +25 -0
- data/src/nginx/README +3 -0
- data/src/nginx/auto/cc/acc +15 -0
- data/src/nginx/auto/cc/bcc +72 -0
- data/src/nginx/auto/cc/ccc +46 -0
- data/src/nginx/auto/cc/conf +189 -0
- data/src/nginx/auto/cc/gcc +183 -0
- data/src/nginx/auto/cc/icc +121 -0
- data/src/nginx/auto/cc/msvc +138 -0
- data/src/nginx/auto/cc/name +101 -0
- data/src/nginx/auto/cc/owc +104 -0
- data/src/nginx/auto/cc/sunc +158 -0
- data/src/nginx/auto/define +12 -0
- data/src/nginx/auto/endianess +45 -0
- data/src/nginx/auto/feature +123 -0
- data/src/nginx/auto/have +12 -0
- data/src/nginx/auto/have_headers +12 -0
- data/src/nginx/auto/headers +13 -0
- data/src/nginx/auto/include +61 -0
- data/src/nginx/auto/init +51 -0
- data/src/nginx/auto/install +184 -0
- data/src/nginx/auto/lib/conf +83 -0
- data/src/nginx/auto/lib/geoip/conf +79 -0
- data/src/nginx/auto/lib/google-perftools/conf +45 -0
- data/src/nginx/auto/lib/libatomic/conf +43 -0
- data/src/nginx/auto/lib/libatomic/make +14 -0
- data/src/nginx/auto/lib/libgd/conf +83 -0
- data/src/nginx/auto/lib/libxslt/conf +156 -0
- data/src/nginx/auto/lib/make +32 -0
- data/src/nginx/auto/lib/md5/conf +103 -0
- data/src/nginx/auto/lib/md5/make +96 -0
- data/src/nginx/auto/lib/md5/makefile.bcc +22 -0
- data/src/nginx/auto/lib/md5/makefile.msvc +22 -0
- data/src/nginx/auto/lib/md5/makefile.owc +11 -0
- data/src/nginx/auto/lib/openssl/conf +74 -0
- data/src/nginx/auto/lib/openssl/make +67 -0
- data/src/nginx/auto/lib/openssl/makefile.bcc +18 -0
- data/src/nginx/auto/lib/openssl/makefile.msvc +14 -0
- data/src/nginx/auto/lib/pcre/conf +180 -0
- data/src/nginx/auto/lib/pcre/make +64 -0
- data/src/nginx/auto/lib/pcre/makefile.bcc +26 -0
- data/src/nginx/auto/lib/pcre/makefile.msvc +22 -0
- data/src/nginx/auto/lib/pcre/makefile.owc +24 -0
- data/src/nginx/auto/lib/perl/conf +60 -0
- data/src/nginx/auto/lib/perl/make +36 -0
- data/src/nginx/auto/lib/sha1/conf +79 -0
- data/src/nginx/auto/lib/sha1/make +96 -0
- data/src/nginx/auto/lib/sha1/makefile.bcc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.msvc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.owc +11 -0
- data/src/nginx/auto/lib/test +40 -0
- data/src/nginx/auto/lib/zlib/conf +76 -0
- data/src/nginx/auto/lib/zlib/make +114 -0
- data/src/nginx/auto/lib/zlib/makefile.bcc +15 -0
- data/src/nginx/auto/lib/zlib/makefile.msvc +14 -0
- data/src/nginx/auto/lib/zlib/makefile.owc +14 -0
- data/src/nginx/auto/lib/zlib/patch.zlib.h +10 -0
- data/src/nginx/auto/make +417 -0
- data/src/nginx/auto/modules +479 -0
- data/src/nginx/auto/nohave +12 -0
- data/src/nginx/auto/options +490 -0
- data/src/nginx/auto/os/conf +105 -0
- data/src/nginx/auto/os/darwin +116 -0
- data/src/nginx/auto/os/freebsd +136 -0
- data/src/nginx/auto/os/linux +152 -0
- data/src/nginx/auto/os/solaris +60 -0
- data/src/nginx/auto/os/win32 +29 -0
- data/src/nginx/auto/sources +518 -0
- data/src/nginx/auto/stubs +8 -0
- data/src/nginx/auto/summary +114 -0
- data/src/nginx/auto/types/sizeof +83 -0
- data/src/nginx/auto/types/typedef +77 -0
- data/src/nginx/auto/types/uintptr_t +42 -0
- data/src/nginx/auto/types/value +12 -0
- data/src/nginx/auto/unix +719 -0
- data/src/nginx/conf/fastcgi.conf +24 -0
- data/src/nginx/conf/fastcgi_params +23 -0
- data/src/nginx/conf/koi-utf +109 -0
- data/src/nginx/conf/koi-win +103 -0
- data/src/nginx/conf/mime.types +80 -0
- data/src/nginx/conf/nginx.conf +118 -0
- data/src/nginx/conf/scgi_params +15 -0
- data/src/nginx/conf/uwsgi_params +15 -0
- data/src/nginx/conf/win-utf +126 -0
- data/src/nginx/configure +108 -0
- data/src/nginx/contrib/README +15 -0
- data/src/nginx/contrib/geo2nginx.pl +58 -0
- data/src/nginx/contrib/unicode2nginx/koi-utf +131 -0
- data/src/nginx/contrib/unicode2nginx/unicode-to-nginx.pl +45 -0
- data/src/nginx/contrib/unicode2nginx/win-utf +130 -0
- data/src/nginx/html/50x.html +18 -0
- data/src/nginx/html/index.html +8 -0
- data/src/nginx/man/nginx.8 +202 -0
- data/src/nginx/src/core/nginx.c +1333 -0
- data/src/nginx/src/core/nginx.h +20 -0
- data/src/nginx/src/core/ngx_array.c +147 -0
- data/src/nginx/src/core/ngx_array.h +53 -0
- data/src/nginx/src/core/ngx_buf.c +218 -0
- data/src/nginx/src/core/ngx_buf.h +162 -0
- data/src/nginx/src/core/ngx_conf_file.c +1506 -0
- data/src/nginx/src/core/ngx_conf_file.h +348 -0
- data/src/nginx/src/core/ngx_config.h +134 -0
- data/src/nginx/src/core/ngx_connection.c +1074 -0
- data/src/nginx/src/core/ngx_connection.h +195 -0
- data/src/nginx/src/core/ngx_core.h +95 -0
- data/src/nginx/src/core/ngx_cpuinfo.c +139 -0
- data/src/nginx/src/core/ngx_crc.h +39 -0
- data/src/nginx/src/core/ngx_crc32.c +129 -0
- data/src/nginx/src/core/ngx_crc32.h +79 -0
- data/src/nginx/src/core/ngx_crypt.c +238 -0
- data/src/nginx/src/core/ngx_crypt.h +20 -0
- data/src/nginx/src/core/ngx_cycle.c +1379 -0
- data/src/nginx/src/core/ngx_cycle.h +142 -0
- data/src/nginx/src/core/ngx_file.c +993 -0
- data/src/nginx/src/core/ngx_file.h +151 -0
- data/src/nginx/src/core/ngx_hash.c +976 -0
- data/src/nginx/src/core/ngx_hash.h +122 -0
- data/src/nginx/src/core/ngx_inet.c +1008 -0
- data/src/nginx/src/core/ngx_inet.h +120 -0
- data/src/nginx/src/core/ngx_list.c +71 -0
- data/src/nginx/src/core/ngx_list.h +83 -0
- data/src/nginx/src/core/ngx_log.c +459 -0
- data/src/nginx/src/core/ngx_log.h +250 -0
- data/src/nginx/src/core/ngx_md5.c +289 -0
- data/src/nginx/src/core/ngx_md5.h +60 -0
- data/src/nginx/src/core/ngx_murmurhash.c +50 -0
- data/src/nginx/src/core/ngx_murmurhash.h +19 -0
- data/src/nginx/src/core/ngx_open_file_cache.c +882 -0
- data/src/nginx/src/core/ngx_open_file_cache.h +119 -0
- data/src/nginx/src/core/ngx_output_chain.c +673 -0
- data/src/nginx/src/core/ngx_palloc.c +433 -0
- data/src/nginx/src/core/ngx_palloc.h +95 -0
- data/src/nginx/src/core/ngx_parse.c +249 -0
- data/src/nginx/src/core/ngx_parse.h +24 -0
- data/src/nginx/src/core/ngx_queue.c +80 -0
- data/src/nginx/src/core/ngx_queue.h +112 -0
- data/src/nginx/src/core/ngx_radix_tree.c +291 -0
- data/src/nginx/src/core/ngx_radix_tree.h +46 -0
- data/src/nginx/src/core/ngx_rbtree.c +383 -0
- data/src/nginx/src/core/ngx_rbtree.h +84 -0
- data/src/nginx/src/core/ngx_regex.c +206 -0
- data/src/nginx/src/core/ngx_regex.h +56 -0
- data/src/nginx/src/core/ngx_resolver.c +2201 -0
- data/src/nginx/src/core/ngx_resolver.h +149 -0
- data/src/nginx/src/core/ngx_sha1.h +31 -0
- data/src/nginx/src/core/ngx_shmtx.c +284 -0
- data/src/nginx/src/core/ngx_shmtx.h +38 -0
- data/src/nginx/src/core/ngx_slab.c +701 -0
- data/src/nginx/src/core/ngx_slab.h +54 -0
- data/src/nginx/src/core/ngx_spinlock.c +53 -0
- data/src/nginx/src/core/ngx_string.c +1837 -0
- data/src/nginx/src/core/ngx_string.h +231 -0
- data/src/nginx/src/core/ngx_times.c +407 -0
- data/src/nginx/src/core/ngx_times.h +51 -0
- data/src/nginx/src/event/modules/ngx_aio_module.c +171 -0
- data/src/nginx/src/event/modules/ngx_devpoll_module.c +569 -0
- data/src/nginx/src/event/modules/ngx_epoll_module.c +833 -0
- data/src/nginx/src/event/modules/ngx_eventport_module.c +602 -0
- data/src/nginx/src/event/modules/ngx_kqueue_module.c +785 -0
- data/src/nginx/src/event/modules/ngx_poll_module.c +443 -0
- data/src/nginx/src/event/modules/ngx_rtsig_module.c +735 -0
- data/src/nginx/src/event/modules/ngx_select_module.c +435 -0
- data/src/nginx/src/event/modules/ngx_win32_select_module.c +400 -0
- data/src/nginx/src/event/ngx_event.c +1275 -0
- data/src/nginx/src/event/ngx_event.h +573 -0
- data/src/nginx/src/event/ngx_event_accept.c +428 -0
- data/src/nginx/src/event/ngx_event_busy_lock.c +286 -0
- data/src/nginx/src/event/ngx_event_busy_lock.h +65 -0
- data/src/nginx/src/event/ngx_event_connect.c +258 -0
- data/src/nginx/src/event/ngx_event_connect.h +76 -0
- data/src/nginx/src/event/ngx_event_mutex.c +70 -0
- data/src/nginx/src/event/ngx_event_openssl.c +2382 -0
- data/src/nginx/src/event/ngx_event_openssl.h +162 -0
- data/src/nginx/src/event/ngx_event_pipe.c +996 -0
- data/src/nginx/src/event/ngx_event_pipe.h +95 -0
- data/src/nginx/src/event/ngx_event_posted.c +173 -0
- data/src/nginx/src/event/ngx_event_posted.h +75 -0
- data/src/nginx/src/event/ngx_event_timer.c +159 -0
- data/src/nginx/src/event/ngx_event_timer.h +102 -0
- data/src/nginx/src/http/modules/ngx_http_access_module.c +384 -0
- data/src/nginx/src/http/modules/ngx_http_addition_filter_module.c +250 -0
- data/src/nginx/src/http/modules/ngx_http_auth_basic_module.c +478 -0
- data/src/nginx/src/http/modules/ngx_http_autoindex_module.c +701 -0
- data/src/nginx/src/http/modules/ngx_http_browser_module.c +713 -0
- data/src/nginx/src/http/modules/ngx_http_charset_filter_module.c +1681 -0
- data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_dav_module.c +1141 -0
- data/src/nginx/src/http/modules/ngx_http_degradation_module.c +243 -0
- data/src/nginx/src/http/modules/ngx_http_empty_gif_module.c +140 -0
- data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +2916 -0
- data/src/nginx/src/http/modules/ngx_http_flv_module.c +254 -0
- data/src/nginx/src/http/modules/ngx_http_geo_module.c +1441 -0
- data/src/nginx/src/http/modules/ngx_http_geoip_module.c +671 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +1206 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +299 -0
- data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +616 -0
- data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1489 -0
- data/src/nginx/src/http/modules/ngx_http_index_module.c +516 -0
- data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +809 -0
- data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +553 -0
- data/src/nginx/src/http/modules/ngx_http_log_module.c +1357 -0
- data/src/nginx/src/http/modules/ngx_http_map_module.c +575 -0
- data/src/nginx/src/http/modules/ngx_http_memcached_module.c +624 -0
- data/src/nginx/src/http/modules/ngx_http_mp4_module.c +3000 -0
- data/src/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +143 -0
- data/src/nginx/src/http/modules/ngx_http_proxy_module.c +2831 -0
- data/src/nginx/src/http/modules/ngx_http_random_index_module.c +317 -0
- data/src/nginx/src/http/modules/ngx_http_range_filter_module.c +855 -0
- data/src/nginx/src/http/modules/ngx_http_realip_module.c +476 -0
- data/src/nginx/src/http/modules/ngx_http_referer_module.c +613 -0
- data/src/nginx/src/http/modules/ngx_http_rewrite_module.c +1019 -0
- data/src/nginx/src/http/modules/ngx_http_scgi_module.c +1714 -0
- data/src/nginx/src/http/modules/ngx_http_secure_link_module.c +355 -0
- data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +2913 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.h +114 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.c +652 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.h +52 -0
- data/src/nginx/src/http/modules/ngx_http_static_module.c +278 -0
- data/src/nginx/src/http/modules/ngx_http_stub_status_module.c +144 -0
- data/src/nginx/src/http/modules/ngx_http_sub_filter_module.c +716 -0
- data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +237 -0
- data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +846 -0
- data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +1774 -0
- data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +984 -0
- data/src/nginx/src/http/modules/perl/Makefile.PL +42 -0
- data/src/nginx/src/http/modules/perl/nginx.pm +137 -0
- data/src/nginx/src/http/modules/perl/nginx.xs +986 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.c +1076 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.h +67 -0
- data/src/nginx/src/http/modules/perl/typemap +3 -0
- data/src/nginx/src/http/ngx_http.c +2073 -0
- data/src/nginx/src/http/ngx_http.h +160 -0
- data/src/nginx/src/http/ngx_http_busy_lock.c +307 -0
- data/src/nginx/src/http/ngx_http_busy_lock.h +54 -0
- data/src/nginx/src/http/ngx_http_cache.h +148 -0
- data/src/nginx/src/http/ngx_http_config.h +75 -0
- data/src/nginx/src/http/ngx_http_copy_filter_module.c +300 -0
- data/src/nginx/src/http/ngx_http_core_module.c +4736 -0
- data/src/nginx/src/http/ngx_http_core_module.h +541 -0
- data/src/nginx/src/http/ngx_http_file_cache.c +1715 -0
- data/src/nginx/src/http/ngx_http_header_filter_module.c +623 -0
- data/src/nginx/src/http/ngx_http_parse.c +1734 -0
- data/src/nginx/src/http/ngx_http_parse_time.c +276 -0
- data/src/nginx/src/http/ngx_http_postpone_filter_module.c +178 -0
- data/src/nginx/src/http/ngx_http_request.c +3181 -0
- data/src/nginx/src/http/ngx_http_request.h +573 -0
- data/src/nginx/src/http/ngx_http_request_body.c +644 -0
- data/src/nginx/src/http/ngx_http_script.c +1752 -0
- data/src/nginx/src/http/ngx_http_script.h +257 -0
- data/src/nginx/src/http/ngx_http_special_response.c +789 -0
- data/src/nginx/src/http/ngx_http_upstream.c +4555 -0
- data/src/nginx/src/http/ngx_http_upstream.h +350 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.c +791 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.h +85 -0
- data/src/nginx/src/http/ngx_http_variables.c +2053 -0
- data/src/nginx/src/http/ngx_http_variables.h +115 -0
- data/src/nginx/src/http/ngx_http_write_filter_module.c +315 -0
- data/src/nginx/src/mail/ngx_mail.c +542 -0
- data/src/nginx/src/mail/ngx_mail.h +407 -0
- data/src/nginx/src/mail/ngx_mail_auth_http_module.c +1452 -0
- data/src/nginx/src/mail/ngx_mail_core_module.c +553 -0
- data/src/nginx/src/mail/ngx_mail_handler.c +773 -0
- data/src/nginx/src/mail/ngx_mail_imap_handler.c +457 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.c +253 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.h +39 -0
- data/src/nginx/src/mail/ngx_mail_parse.c +885 -0
- data/src/nginx/src/mail/ngx_mail_pop3_handler.c +500 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.c +264 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.h +38 -0
- data/src/nginx/src/mail/ngx_mail_proxy_module.c +1089 -0
- data/src/nginx/src/mail/ngx_mail_smtp_handler.c +872 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.c +308 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.h +45 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.c +491 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.h +52 -0
- data/src/nginx/src/misc/ngx_cpp_test_module.cpp +27 -0
- data/src/nginx/src/misc/ngx_google_perftools_module.c +126 -0
- data/src/nginx/src/os/unix/ngx_aio_read.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_read_chain.c +78 -0
- data/src/nginx/src/os/unix/ngx_aio_write.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_write_chain.c +100 -0
- data/src/nginx/src/os/unix/ngx_alloc.c +90 -0
- data/src/nginx/src/os/unix/ngx_alloc.h +45 -0
- data/src/nginx/src/os/unix/ngx_atomic.h +311 -0
- data/src/nginx/src/os/unix/ngx_channel.c +258 -0
- data/src/nginx/src/os/unix/ngx_channel.h +34 -0
- data/src/nginx/src/os/unix/ngx_daemon.c +69 -0
- data/src/nginx/src/os/unix/ngx_darwin.h +20 -0
- data/src/nginx/src/os/unix/ngx_darwin_config.h +96 -0
- data/src/nginx/src/os/unix/ngx_darwin_init.c +166 -0
- data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +366 -0
- data/src/nginx/src/os/unix/ngx_errno.c +87 -0
- data/src/nginx/src/os/unix/ngx_errno.h +68 -0
- data/src/nginx/src/os/unix/ngx_file_aio_read.c +208 -0
- data/src/nginx/src/os/unix/ngx_files.c +566 -0
- data/src/nginx/src/os/unix/ngx_files.h +343 -0
- data/src/nginx/src/os/unix/ngx_freebsd.h +24 -0
- data/src/nginx/src/os/unix/ngx_freebsd_config.h +119 -0
- data/src/nginx/src/os/unix/ngx_freebsd_init.c +259 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +756 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +122 -0
- data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +436 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_amd64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_ppc.h +155 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_x86.h +127 -0
- data/src/nginx/src/os/unix/ngx_linux.h +18 -0
- data/src/nginx/src/os/unix/ngx_linux_aio_read.c +137 -0
- data/src/nginx/src/os/unix/ngx_linux_config.h +117 -0
- data/src/nginx/src/os/unix/ngx_linux_init.c +91 -0
- data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +378 -0
- data/src/nginx/src/os/unix/ngx_os.h +84 -0
- data/src/nginx/src/os/unix/ngx_posix_config.h +153 -0
- data/src/nginx/src/os/unix/ngx_posix_init.c +124 -0
- data/src/nginx/src/os/unix/ngx_process.c +590 -0
- data/src/nginx/src/os/unix/ngx_process.h +87 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.c +1390 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.h +61 -0
- data/src/nginx/src/os/unix/ngx_pthread_thread.c +278 -0
- data/src/nginx/src/os/unix/ngx_readv_chain.c +258 -0
- data/src/nginx/src/os/unix/ngx_recv.c +180 -0
- data/src/nginx/src/os/unix/ngx_send.c +73 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.c +135 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.h +52 -0
- data/src/nginx/src/os/unix/ngx_shmem.c +126 -0
- data/src/nginx/src/os/unix/ngx_shmem.h +29 -0
- data/src/nginx/src/os/unix/ngx_socket.c +116 -0
- data/src/nginx/src/os/unix/ngx_socket.h +64 -0
- data/src/nginx/src/os/unix/ngx_solaris.h +16 -0
- data/src/nginx/src/os/unix/ngx_solaris_config.h +107 -0
- data/src/nginx/src/os/unix/ngx_solaris_init.c +75 -0
- data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +251 -0
- data/src/nginx/src/os/unix/ngx_sunpro_amd64.il +43 -0
- data/src/nginx/src/os/unix/ngx_sunpro_atomic_sparc64.h +61 -0
- data/src/nginx/src/os/unix/ngx_sunpro_sparc64.il +36 -0
- data/src/nginx/src/os/unix/ngx_sunpro_x86.il +44 -0
- data/src/nginx/src/os/unix/ngx_thread.h +128 -0
- data/src/nginx/src/os/unix/ngx_time.c +104 -0
- data/src/nginx/src/os/unix/ngx_time.h +66 -0
- data/src/nginx/src/os/unix/ngx_udp_recv.c +115 -0
- data/src/nginx/src/os/unix/ngx_user.c +109 -0
- data/src/nginx/src/os/unix/ngx_user.h +24 -0
- data/src/nginx/src/os/unix/ngx_writev_chain.c +181 -0
- data/src/nginx/src/os/unix/rfork_thread.S +73 -0
- metadata +419 -0
@@ -0,0 +1,1752 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#include <ngx_config.h>
|
9
|
+
#include <ngx_core.h>
|
10
|
+
#include <ngx_http.h>
|
11
|
+
|
12
|
+
|
13
|
+
static ngx_int_t ngx_http_script_init_arrays(ngx_http_script_compile_t *sc);
|
14
|
+
static ngx_int_t ngx_http_script_done(ngx_http_script_compile_t *sc);
|
15
|
+
static ngx_int_t ngx_http_script_add_copy_code(ngx_http_script_compile_t *sc,
|
16
|
+
ngx_str_t *value, ngx_uint_t last);
|
17
|
+
static ngx_int_t ngx_http_script_add_var_code(ngx_http_script_compile_t *sc,
|
18
|
+
ngx_str_t *name);
|
19
|
+
static ngx_int_t ngx_http_script_add_args_code(ngx_http_script_compile_t *sc);
|
20
|
+
#if (NGX_PCRE)
|
21
|
+
static ngx_int_t ngx_http_script_add_capture_code(ngx_http_script_compile_t *sc,
|
22
|
+
ngx_uint_t n);
|
23
|
+
#endif
|
24
|
+
static ngx_int_t
|
25
|
+
ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc);
|
26
|
+
static size_t ngx_http_script_full_name_len_code(ngx_http_script_engine_t *e);
|
27
|
+
static void ngx_http_script_full_name_code(ngx_http_script_engine_t *e);
|
28
|
+
|
29
|
+
|
30
|
+
#define ngx_http_script_exit (u_char *) &ngx_http_script_exit_code
|
31
|
+
|
32
|
+
static uintptr_t ngx_http_script_exit_code = (uintptr_t) NULL;
|
33
|
+
|
34
|
+
|
35
|
+
void
|
36
|
+
ngx_http_script_flush_complex_value(ngx_http_request_t *r,
|
37
|
+
ngx_http_complex_value_t *val)
|
38
|
+
{
|
39
|
+
ngx_uint_t *index;
|
40
|
+
|
41
|
+
index = val->flushes;
|
42
|
+
|
43
|
+
if (index) {
|
44
|
+
while (*index != (ngx_uint_t) -1) {
|
45
|
+
|
46
|
+
if (r->variables[*index].no_cacheable) {
|
47
|
+
r->variables[*index].valid = 0;
|
48
|
+
r->variables[*index].not_found = 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
index++;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
ngx_int_t
|
58
|
+
ngx_http_complex_value(ngx_http_request_t *r, ngx_http_complex_value_t *val,
|
59
|
+
ngx_str_t *value)
|
60
|
+
{
|
61
|
+
size_t len;
|
62
|
+
ngx_http_script_code_pt code;
|
63
|
+
ngx_http_script_len_code_pt lcode;
|
64
|
+
ngx_http_script_engine_t e;
|
65
|
+
|
66
|
+
if (val->lengths == NULL) {
|
67
|
+
*value = val->value;
|
68
|
+
return NGX_OK;
|
69
|
+
}
|
70
|
+
|
71
|
+
ngx_http_script_flush_complex_value(r, val);
|
72
|
+
|
73
|
+
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
74
|
+
|
75
|
+
e.ip = val->lengths;
|
76
|
+
e.request = r;
|
77
|
+
e.flushed = 1;
|
78
|
+
|
79
|
+
len = 0;
|
80
|
+
|
81
|
+
while (*(uintptr_t *) e.ip) {
|
82
|
+
lcode = *(ngx_http_script_len_code_pt *) e.ip;
|
83
|
+
len += lcode(&e);
|
84
|
+
}
|
85
|
+
|
86
|
+
value->len = len;
|
87
|
+
value->data = ngx_pnalloc(r->pool, len);
|
88
|
+
if (value->data == NULL) {
|
89
|
+
return NGX_ERROR;
|
90
|
+
}
|
91
|
+
|
92
|
+
e.ip = val->values;
|
93
|
+
e.pos = value->data;
|
94
|
+
e.buf = *value;
|
95
|
+
|
96
|
+
while (*(uintptr_t *) e.ip) {
|
97
|
+
code = *(ngx_http_script_code_pt *) e.ip;
|
98
|
+
code((ngx_http_script_engine_t *) &e);
|
99
|
+
}
|
100
|
+
|
101
|
+
*value = e.buf;
|
102
|
+
|
103
|
+
return NGX_OK;
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
ngx_int_t
|
108
|
+
ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv)
|
109
|
+
{
|
110
|
+
ngx_str_t *v;
|
111
|
+
ngx_uint_t i, n, nv, nc;
|
112
|
+
ngx_array_t flushes, lengths, values, *pf, *pl, *pv;
|
113
|
+
ngx_http_script_compile_t sc;
|
114
|
+
|
115
|
+
v = ccv->value;
|
116
|
+
|
117
|
+
if (v->len == 0) {
|
118
|
+
ngx_conf_log_error(NGX_LOG_EMERG, ccv->cf, 0, "empty parameter");
|
119
|
+
return NGX_ERROR;
|
120
|
+
}
|
121
|
+
|
122
|
+
nv = 0;
|
123
|
+
nc = 0;
|
124
|
+
|
125
|
+
for (i = 0; i < v->len; i++) {
|
126
|
+
if (v->data[i] == '$') {
|
127
|
+
if (v->data[i + 1] >= '1' && v->data[i + 1] <= '9') {
|
128
|
+
nc++;
|
129
|
+
|
130
|
+
} else {
|
131
|
+
nv++;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
if (v->data[0] != '$' && (ccv->conf_prefix || ccv->root_prefix)) {
|
137
|
+
|
138
|
+
if (ngx_conf_full_name(ccv->cf->cycle, v, ccv->conf_prefix) != NGX_OK) {
|
139
|
+
return NGX_ERROR;
|
140
|
+
}
|
141
|
+
|
142
|
+
ccv->conf_prefix = 0;
|
143
|
+
ccv->root_prefix = 0;
|
144
|
+
}
|
145
|
+
|
146
|
+
ccv->complex_value->value = *v;
|
147
|
+
ccv->complex_value->flushes = NULL;
|
148
|
+
ccv->complex_value->lengths = NULL;
|
149
|
+
ccv->complex_value->values = NULL;
|
150
|
+
|
151
|
+
if (nv == 0 && nc == 0) {
|
152
|
+
return NGX_OK;
|
153
|
+
}
|
154
|
+
|
155
|
+
n = nv + 1;
|
156
|
+
|
157
|
+
if (ngx_array_init(&flushes, ccv->cf->pool, n, sizeof(ngx_uint_t))
|
158
|
+
!= NGX_OK)
|
159
|
+
{
|
160
|
+
return NGX_ERROR;
|
161
|
+
}
|
162
|
+
|
163
|
+
n = nv * (2 * sizeof(ngx_http_script_copy_code_t)
|
164
|
+
+ sizeof(ngx_http_script_var_code_t))
|
165
|
+
+ sizeof(uintptr_t);
|
166
|
+
|
167
|
+
if (ngx_array_init(&lengths, ccv->cf->pool, n, 1) != NGX_OK) {
|
168
|
+
return NGX_ERROR;
|
169
|
+
}
|
170
|
+
|
171
|
+
n = (nv * (2 * sizeof(ngx_http_script_copy_code_t)
|
172
|
+
+ sizeof(ngx_http_script_var_code_t))
|
173
|
+
+ sizeof(uintptr_t)
|
174
|
+
+ v->len
|
175
|
+
+ sizeof(uintptr_t) - 1)
|
176
|
+
& ~(sizeof(uintptr_t) - 1);
|
177
|
+
|
178
|
+
if (ngx_array_init(&values, ccv->cf->pool, n, 1) != NGX_OK) {
|
179
|
+
return NGX_ERROR;
|
180
|
+
}
|
181
|
+
|
182
|
+
pf = &flushes;
|
183
|
+
pl = &lengths;
|
184
|
+
pv = &values;
|
185
|
+
|
186
|
+
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
187
|
+
|
188
|
+
sc.cf = ccv->cf;
|
189
|
+
sc.source = v;
|
190
|
+
sc.flushes = &pf;
|
191
|
+
sc.lengths = &pl;
|
192
|
+
sc.values = &pv;
|
193
|
+
sc.complete_lengths = 1;
|
194
|
+
sc.complete_values = 1;
|
195
|
+
sc.zero = ccv->zero;
|
196
|
+
sc.conf_prefix = ccv->conf_prefix;
|
197
|
+
sc.root_prefix = ccv->root_prefix;
|
198
|
+
|
199
|
+
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
200
|
+
return NGX_ERROR;
|
201
|
+
}
|
202
|
+
|
203
|
+
if (flushes.nelts) {
|
204
|
+
ccv->complex_value->flushes = flushes.elts;
|
205
|
+
ccv->complex_value->flushes[flushes.nelts] = (ngx_uint_t) -1;
|
206
|
+
}
|
207
|
+
|
208
|
+
ccv->complex_value->lengths = lengths.elts;
|
209
|
+
ccv->complex_value->values = values.elts;
|
210
|
+
|
211
|
+
return NGX_OK;
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
char *
|
216
|
+
ngx_http_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
217
|
+
{
|
218
|
+
char *p = conf;
|
219
|
+
|
220
|
+
ngx_str_t *value;
|
221
|
+
ngx_http_complex_value_t **cv;
|
222
|
+
ngx_http_compile_complex_value_t ccv;
|
223
|
+
|
224
|
+
cv = (ngx_http_complex_value_t **) (p + cmd->offset);
|
225
|
+
|
226
|
+
if (*cv != NULL) {
|
227
|
+
return "duplicate";
|
228
|
+
}
|
229
|
+
|
230
|
+
*cv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t));
|
231
|
+
if (*cv == NULL) {
|
232
|
+
return NGX_CONF_ERROR;
|
233
|
+
}
|
234
|
+
|
235
|
+
value = cf->args->elts;
|
236
|
+
|
237
|
+
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
238
|
+
|
239
|
+
ccv.cf = cf;
|
240
|
+
ccv.value = &value[1];
|
241
|
+
ccv.complex_value = *cv;
|
242
|
+
|
243
|
+
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
244
|
+
return NGX_CONF_ERROR;
|
245
|
+
}
|
246
|
+
|
247
|
+
return NGX_CONF_OK;
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
ngx_int_t
|
252
|
+
ngx_http_test_predicates(ngx_http_request_t *r, ngx_array_t *predicates)
|
253
|
+
{
|
254
|
+
ngx_str_t val;
|
255
|
+
ngx_uint_t i;
|
256
|
+
ngx_http_complex_value_t *cv;
|
257
|
+
|
258
|
+
if (predicates == NULL) {
|
259
|
+
return NGX_OK;
|
260
|
+
}
|
261
|
+
|
262
|
+
cv = predicates->elts;
|
263
|
+
|
264
|
+
for (i = 0; i < predicates->nelts; i++) {
|
265
|
+
if (ngx_http_complex_value(r, &cv[i], &val) != NGX_OK) {
|
266
|
+
return NGX_ERROR;
|
267
|
+
}
|
268
|
+
|
269
|
+
if (val.len && (val.len != 1 || val.data[0] != '0')) {
|
270
|
+
return NGX_DECLINED;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
return NGX_OK;
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
char *
|
279
|
+
ngx_http_set_predicate_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
280
|
+
{
|
281
|
+
char *p = conf;
|
282
|
+
|
283
|
+
ngx_str_t *value;
|
284
|
+
ngx_uint_t i;
|
285
|
+
ngx_array_t **a;
|
286
|
+
ngx_http_complex_value_t *cv;
|
287
|
+
ngx_http_compile_complex_value_t ccv;
|
288
|
+
|
289
|
+
a = (ngx_array_t **) (p + cmd->offset);
|
290
|
+
|
291
|
+
if (*a == NGX_CONF_UNSET_PTR) {
|
292
|
+
*a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t));
|
293
|
+
if (*a == NULL) {
|
294
|
+
return NGX_CONF_ERROR;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
value = cf->args->elts;
|
299
|
+
|
300
|
+
for (i = 1; i < cf->args->nelts; i++) {
|
301
|
+
cv = ngx_array_push(*a);
|
302
|
+
if (cv == NULL) {
|
303
|
+
return NGX_CONF_ERROR;
|
304
|
+
}
|
305
|
+
|
306
|
+
ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
307
|
+
|
308
|
+
ccv.cf = cf;
|
309
|
+
ccv.value = &value[i];
|
310
|
+
ccv.complex_value = cv;
|
311
|
+
|
312
|
+
if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
313
|
+
return NGX_CONF_ERROR;
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
return NGX_CONF_OK;
|
318
|
+
}
|
319
|
+
|
320
|
+
|
321
|
+
ngx_uint_t
|
322
|
+
ngx_http_script_variables_count(ngx_str_t *value)
|
323
|
+
{
|
324
|
+
ngx_uint_t i, n;
|
325
|
+
|
326
|
+
for (n = 0, i = 0; i < value->len; i++) {
|
327
|
+
if (value->data[i] == '$') {
|
328
|
+
n++;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
return n;
|
333
|
+
}
|
334
|
+
|
335
|
+
|
336
|
+
ngx_int_t
|
337
|
+
ngx_http_script_compile(ngx_http_script_compile_t *sc)
|
338
|
+
{
|
339
|
+
u_char ch;
|
340
|
+
ngx_str_t name;
|
341
|
+
ngx_uint_t i, bracket;
|
342
|
+
|
343
|
+
if (ngx_http_script_init_arrays(sc) != NGX_OK) {
|
344
|
+
return NGX_ERROR;
|
345
|
+
}
|
346
|
+
|
347
|
+
for (i = 0; i < sc->source->len; /* void */ ) {
|
348
|
+
|
349
|
+
name.len = 0;
|
350
|
+
|
351
|
+
if (sc->source->data[i] == '$') {
|
352
|
+
|
353
|
+
if (++i == sc->source->len) {
|
354
|
+
goto invalid_variable;
|
355
|
+
}
|
356
|
+
|
357
|
+
#if (NGX_PCRE)
|
358
|
+
{
|
359
|
+
ngx_uint_t n;
|
360
|
+
|
361
|
+
if (sc->source->data[i] >= '1' && sc->source->data[i] <= '9') {
|
362
|
+
|
363
|
+
n = sc->source->data[i] - '0';
|
364
|
+
|
365
|
+
if (sc->captures_mask & (1 << n)) {
|
366
|
+
sc->dup_capture = 1;
|
367
|
+
}
|
368
|
+
|
369
|
+
sc->captures_mask |= 1 << n;
|
370
|
+
|
371
|
+
if (ngx_http_script_add_capture_code(sc, n) != NGX_OK) {
|
372
|
+
return NGX_ERROR;
|
373
|
+
}
|
374
|
+
|
375
|
+
i++;
|
376
|
+
|
377
|
+
continue;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
#endif
|
381
|
+
|
382
|
+
if (sc->source->data[i] == '{') {
|
383
|
+
bracket = 1;
|
384
|
+
|
385
|
+
if (++i == sc->source->len) {
|
386
|
+
goto invalid_variable;
|
387
|
+
}
|
388
|
+
|
389
|
+
name.data = &sc->source->data[i];
|
390
|
+
|
391
|
+
} else {
|
392
|
+
bracket = 0;
|
393
|
+
name.data = &sc->source->data[i];
|
394
|
+
}
|
395
|
+
|
396
|
+
for ( /* void */ ; i < sc->source->len; i++, name.len++) {
|
397
|
+
ch = sc->source->data[i];
|
398
|
+
|
399
|
+
if (ch == '}' && bracket) {
|
400
|
+
i++;
|
401
|
+
bracket = 0;
|
402
|
+
break;
|
403
|
+
}
|
404
|
+
|
405
|
+
if ((ch >= 'A' && ch <= 'Z')
|
406
|
+
|| (ch >= 'a' && ch <= 'z')
|
407
|
+
|| (ch >= '0' && ch <= '9')
|
408
|
+
|| ch == '_')
|
409
|
+
{
|
410
|
+
continue;
|
411
|
+
}
|
412
|
+
|
413
|
+
break;
|
414
|
+
}
|
415
|
+
|
416
|
+
if (bracket) {
|
417
|
+
ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0,
|
418
|
+
"the closing bracket in \"%V\" "
|
419
|
+
"variable is missing", &name);
|
420
|
+
return NGX_ERROR;
|
421
|
+
}
|
422
|
+
|
423
|
+
if (name.len == 0) {
|
424
|
+
goto invalid_variable;
|
425
|
+
}
|
426
|
+
|
427
|
+
sc->variables++;
|
428
|
+
|
429
|
+
if (ngx_http_script_add_var_code(sc, &name) != NGX_OK) {
|
430
|
+
return NGX_ERROR;
|
431
|
+
}
|
432
|
+
|
433
|
+
continue;
|
434
|
+
}
|
435
|
+
|
436
|
+
if (sc->source->data[i] == '?' && sc->compile_args) {
|
437
|
+
sc->args = 1;
|
438
|
+
sc->compile_args = 0;
|
439
|
+
|
440
|
+
if (ngx_http_script_add_args_code(sc) != NGX_OK) {
|
441
|
+
return NGX_ERROR;
|
442
|
+
}
|
443
|
+
|
444
|
+
i++;
|
445
|
+
|
446
|
+
continue;
|
447
|
+
}
|
448
|
+
|
449
|
+
name.data = &sc->source->data[i];
|
450
|
+
|
451
|
+
while (i < sc->source->len) {
|
452
|
+
|
453
|
+
if (sc->source->data[i] == '$') {
|
454
|
+
break;
|
455
|
+
}
|
456
|
+
|
457
|
+
if (sc->source->data[i] == '?') {
|
458
|
+
|
459
|
+
sc->args = 1;
|
460
|
+
|
461
|
+
if (sc->compile_args) {
|
462
|
+
break;
|
463
|
+
}
|
464
|
+
}
|
465
|
+
|
466
|
+
i++;
|
467
|
+
name.len++;
|
468
|
+
}
|
469
|
+
|
470
|
+
sc->size += name.len;
|
471
|
+
|
472
|
+
if (ngx_http_script_add_copy_code(sc, &name, (i == sc->source->len))
|
473
|
+
!= NGX_OK)
|
474
|
+
{
|
475
|
+
return NGX_ERROR;
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
479
|
+
return ngx_http_script_done(sc);
|
480
|
+
|
481
|
+
invalid_variable:
|
482
|
+
|
483
|
+
ngx_conf_log_error(NGX_LOG_EMERG, sc->cf, 0, "invalid variable name");
|
484
|
+
|
485
|
+
return NGX_ERROR;
|
486
|
+
}
|
487
|
+
|
488
|
+
|
489
|
+
u_char *
|
490
|
+
ngx_http_script_run(ngx_http_request_t *r, ngx_str_t *value,
|
491
|
+
void *code_lengths, size_t len, void *code_values)
|
492
|
+
{
|
493
|
+
ngx_uint_t i;
|
494
|
+
ngx_http_script_code_pt code;
|
495
|
+
ngx_http_script_len_code_pt lcode;
|
496
|
+
ngx_http_script_engine_t e;
|
497
|
+
ngx_http_core_main_conf_t *cmcf;
|
498
|
+
|
499
|
+
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
500
|
+
|
501
|
+
for (i = 0; i < cmcf->variables.nelts; i++) {
|
502
|
+
if (r->variables[i].no_cacheable) {
|
503
|
+
r->variables[i].valid = 0;
|
504
|
+
r->variables[i].not_found = 0;
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|
508
|
+
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
509
|
+
|
510
|
+
e.ip = code_lengths;
|
511
|
+
e.request = r;
|
512
|
+
e.flushed = 1;
|
513
|
+
|
514
|
+
while (*(uintptr_t *) e.ip) {
|
515
|
+
lcode = *(ngx_http_script_len_code_pt *) e.ip;
|
516
|
+
len += lcode(&e);
|
517
|
+
}
|
518
|
+
|
519
|
+
|
520
|
+
value->len = len;
|
521
|
+
value->data = ngx_pnalloc(r->pool, len);
|
522
|
+
if (value->data == NULL) {
|
523
|
+
return NULL;
|
524
|
+
}
|
525
|
+
|
526
|
+
e.ip = code_values;
|
527
|
+
e.pos = value->data;
|
528
|
+
|
529
|
+
while (*(uintptr_t *) e.ip) {
|
530
|
+
code = *(ngx_http_script_code_pt *) e.ip;
|
531
|
+
code((ngx_http_script_engine_t *) &e);
|
532
|
+
}
|
533
|
+
|
534
|
+
return e.pos;
|
535
|
+
}
|
536
|
+
|
537
|
+
|
538
|
+
void
|
539
|
+
ngx_http_script_flush_no_cacheable_variables(ngx_http_request_t *r,
|
540
|
+
ngx_array_t *indices)
|
541
|
+
{
|
542
|
+
ngx_uint_t n, *index;
|
543
|
+
|
544
|
+
if (indices) {
|
545
|
+
index = indices->elts;
|
546
|
+
for (n = 0; n < indices->nelts; n++) {
|
547
|
+
if (r->variables[index[n]].no_cacheable) {
|
548
|
+
r->variables[index[n]].valid = 0;
|
549
|
+
r->variables[index[n]].not_found = 0;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
|
556
|
+
static ngx_int_t
|
557
|
+
ngx_http_script_init_arrays(ngx_http_script_compile_t *sc)
|
558
|
+
{
|
559
|
+
ngx_uint_t n;
|
560
|
+
|
561
|
+
if (sc->flushes && *sc->flushes == NULL) {
|
562
|
+
n = sc->variables ? sc->variables : 1;
|
563
|
+
*sc->flushes = ngx_array_create(sc->cf->pool, n, sizeof(ngx_uint_t));
|
564
|
+
if (*sc->flushes == NULL) {
|
565
|
+
return NGX_ERROR;
|
566
|
+
}
|
567
|
+
}
|
568
|
+
|
569
|
+
if (*sc->lengths == NULL) {
|
570
|
+
n = sc->variables * (2 * sizeof(ngx_http_script_copy_code_t)
|
571
|
+
+ sizeof(ngx_http_script_var_code_t))
|
572
|
+
+ sizeof(uintptr_t);
|
573
|
+
|
574
|
+
*sc->lengths = ngx_array_create(sc->cf->pool, n, 1);
|
575
|
+
if (*sc->lengths == NULL) {
|
576
|
+
return NGX_ERROR;
|
577
|
+
}
|
578
|
+
}
|
579
|
+
|
580
|
+
if (*sc->values == NULL) {
|
581
|
+
n = (sc->variables * (2 * sizeof(ngx_http_script_copy_code_t)
|
582
|
+
+ sizeof(ngx_http_script_var_code_t))
|
583
|
+
+ sizeof(uintptr_t)
|
584
|
+
+ sc->source->len
|
585
|
+
+ sizeof(uintptr_t) - 1)
|
586
|
+
& ~(sizeof(uintptr_t) - 1);
|
587
|
+
|
588
|
+
*sc->values = ngx_array_create(sc->cf->pool, n, 1);
|
589
|
+
if (*sc->values == NULL) {
|
590
|
+
return NGX_ERROR;
|
591
|
+
}
|
592
|
+
}
|
593
|
+
|
594
|
+
sc->variables = 0;
|
595
|
+
|
596
|
+
return NGX_OK;
|
597
|
+
}
|
598
|
+
|
599
|
+
|
600
|
+
static ngx_int_t
|
601
|
+
ngx_http_script_done(ngx_http_script_compile_t *sc)
|
602
|
+
{
|
603
|
+
ngx_str_t zero;
|
604
|
+
uintptr_t *code;
|
605
|
+
|
606
|
+
if (sc->zero) {
|
607
|
+
|
608
|
+
zero.len = 1;
|
609
|
+
zero.data = (u_char *) "\0";
|
610
|
+
|
611
|
+
if (ngx_http_script_add_copy_code(sc, &zero, 0) != NGX_OK) {
|
612
|
+
return NGX_ERROR;
|
613
|
+
}
|
614
|
+
}
|
615
|
+
|
616
|
+
if (sc->conf_prefix || sc->root_prefix) {
|
617
|
+
if (ngx_http_script_add_full_name_code(sc) != NGX_OK) {
|
618
|
+
return NGX_ERROR;
|
619
|
+
}
|
620
|
+
}
|
621
|
+
|
622
|
+
if (sc->complete_lengths) {
|
623
|
+
code = ngx_http_script_add_code(*sc->lengths, sizeof(uintptr_t), NULL);
|
624
|
+
if (code == NULL) {
|
625
|
+
return NGX_ERROR;
|
626
|
+
}
|
627
|
+
|
628
|
+
*code = (uintptr_t) NULL;
|
629
|
+
}
|
630
|
+
|
631
|
+
if (sc->complete_values) {
|
632
|
+
code = ngx_http_script_add_code(*sc->values, sizeof(uintptr_t),
|
633
|
+
&sc->main);
|
634
|
+
if (code == NULL) {
|
635
|
+
return NGX_ERROR;
|
636
|
+
}
|
637
|
+
|
638
|
+
*code = (uintptr_t) NULL;
|
639
|
+
}
|
640
|
+
|
641
|
+
return NGX_OK;
|
642
|
+
}
|
643
|
+
|
644
|
+
|
645
|
+
void *
|
646
|
+
ngx_http_script_start_code(ngx_pool_t *pool, ngx_array_t **codes, size_t size)
|
647
|
+
{
|
648
|
+
if (*codes == NULL) {
|
649
|
+
*codes = ngx_array_create(pool, 256, 1);
|
650
|
+
if (*codes == NULL) {
|
651
|
+
return NULL;
|
652
|
+
}
|
653
|
+
}
|
654
|
+
|
655
|
+
return ngx_array_push_n(*codes, size);
|
656
|
+
}
|
657
|
+
|
658
|
+
|
659
|
+
void *
|
660
|
+
ngx_http_script_add_code(ngx_array_t *codes, size_t size, void *code)
|
661
|
+
{
|
662
|
+
u_char *elts, **p;
|
663
|
+
void *new;
|
664
|
+
|
665
|
+
elts = codes->elts;
|
666
|
+
|
667
|
+
new = ngx_array_push_n(codes, size);
|
668
|
+
if (new == NULL) {
|
669
|
+
return NULL;
|
670
|
+
}
|
671
|
+
|
672
|
+
if (code) {
|
673
|
+
if (elts != codes->elts) {
|
674
|
+
p = code;
|
675
|
+
*p += (u_char *) codes->elts - elts;
|
676
|
+
}
|
677
|
+
}
|
678
|
+
|
679
|
+
return new;
|
680
|
+
}
|
681
|
+
|
682
|
+
|
683
|
+
static ngx_int_t
|
684
|
+
ngx_http_script_add_copy_code(ngx_http_script_compile_t *sc, ngx_str_t *value,
|
685
|
+
ngx_uint_t last)
|
686
|
+
{
|
687
|
+
u_char *p;
|
688
|
+
size_t size, len, zero;
|
689
|
+
ngx_http_script_copy_code_t *code;
|
690
|
+
|
691
|
+
zero = (sc->zero && last);
|
692
|
+
len = value->len + zero;
|
693
|
+
|
694
|
+
code = ngx_http_script_add_code(*sc->lengths,
|
695
|
+
sizeof(ngx_http_script_copy_code_t), NULL);
|
696
|
+
if (code == NULL) {
|
697
|
+
return NGX_ERROR;
|
698
|
+
}
|
699
|
+
|
700
|
+
code->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
|
701
|
+
code->len = len;
|
702
|
+
|
703
|
+
size = (sizeof(ngx_http_script_copy_code_t) + len + sizeof(uintptr_t) - 1)
|
704
|
+
& ~(sizeof(uintptr_t) - 1);
|
705
|
+
|
706
|
+
code = ngx_http_script_add_code(*sc->values, size, &sc->main);
|
707
|
+
if (code == NULL) {
|
708
|
+
return NGX_ERROR;
|
709
|
+
}
|
710
|
+
|
711
|
+
code->code = ngx_http_script_copy_code;
|
712
|
+
code->len = len;
|
713
|
+
|
714
|
+
p = ngx_cpymem((u_char *) code + sizeof(ngx_http_script_copy_code_t),
|
715
|
+
value->data, value->len);
|
716
|
+
|
717
|
+
if (zero) {
|
718
|
+
*p = '\0';
|
719
|
+
sc->zero = 0;
|
720
|
+
}
|
721
|
+
|
722
|
+
return NGX_OK;
|
723
|
+
}
|
724
|
+
|
725
|
+
|
726
|
+
size_t
|
727
|
+
ngx_http_script_copy_len_code(ngx_http_script_engine_t *e)
|
728
|
+
{
|
729
|
+
ngx_http_script_copy_code_t *code;
|
730
|
+
|
731
|
+
code = (ngx_http_script_copy_code_t *) e->ip;
|
732
|
+
|
733
|
+
e->ip += sizeof(ngx_http_script_copy_code_t);
|
734
|
+
|
735
|
+
return code->len;
|
736
|
+
}
|
737
|
+
|
738
|
+
|
739
|
+
void
|
740
|
+
ngx_http_script_copy_code(ngx_http_script_engine_t *e)
|
741
|
+
{
|
742
|
+
u_char *p;
|
743
|
+
ngx_http_script_copy_code_t *code;
|
744
|
+
|
745
|
+
code = (ngx_http_script_copy_code_t *) e->ip;
|
746
|
+
|
747
|
+
p = e->pos;
|
748
|
+
|
749
|
+
if (!e->skip) {
|
750
|
+
e->pos = ngx_copy(p, e->ip + sizeof(ngx_http_script_copy_code_t),
|
751
|
+
code->len);
|
752
|
+
}
|
753
|
+
|
754
|
+
e->ip += sizeof(ngx_http_script_copy_code_t)
|
755
|
+
+ ((code->len + sizeof(uintptr_t) - 1) & ~(sizeof(uintptr_t) - 1));
|
756
|
+
|
757
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
758
|
+
"http script copy: \"%*s\"", e->pos - p, p);
|
759
|
+
}
|
760
|
+
|
761
|
+
|
762
|
+
static ngx_int_t
|
763
|
+
ngx_http_script_add_var_code(ngx_http_script_compile_t *sc, ngx_str_t *name)
|
764
|
+
{
|
765
|
+
ngx_int_t index, *p;
|
766
|
+
ngx_http_script_var_code_t *code;
|
767
|
+
|
768
|
+
index = ngx_http_get_variable_index(sc->cf, name);
|
769
|
+
|
770
|
+
if (index == NGX_ERROR) {
|
771
|
+
return NGX_ERROR;
|
772
|
+
}
|
773
|
+
|
774
|
+
if (sc->flushes) {
|
775
|
+
p = ngx_array_push(*sc->flushes);
|
776
|
+
if (p == NULL) {
|
777
|
+
return NGX_ERROR;
|
778
|
+
}
|
779
|
+
|
780
|
+
*p = index;
|
781
|
+
}
|
782
|
+
|
783
|
+
code = ngx_http_script_add_code(*sc->lengths,
|
784
|
+
sizeof(ngx_http_script_var_code_t), NULL);
|
785
|
+
if (code == NULL) {
|
786
|
+
return NGX_ERROR;
|
787
|
+
}
|
788
|
+
|
789
|
+
code->code = (ngx_http_script_code_pt) ngx_http_script_copy_var_len_code;
|
790
|
+
code->index = (uintptr_t) index;
|
791
|
+
|
792
|
+
code = ngx_http_script_add_code(*sc->values,
|
793
|
+
sizeof(ngx_http_script_var_code_t),
|
794
|
+
&sc->main);
|
795
|
+
if (code == NULL) {
|
796
|
+
return NGX_ERROR;
|
797
|
+
}
|
798
|
+
|
799
|
+
code->code = ngx_http_script_copy_var_code;
|
800
|
+
code->index = (uintptr_t) index;
|
801
|
+
|
802
|
+
return NGX_OK;
|
803
|
+
}
|
804
|
+
|
805
|
+
|
806
|
+
size_t
|
807
|
+
ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e)
|
808
|
+
{
|
809
|
+
ngx_http_variable_value_t *value;
|
810
|
+
ngx_http_script_var_code_t *code;
|
811
|
+
|
812
|
+
code = (ngx_http_script_var_code_t *) e->ip;
|
813
|
+
|
814
|
+
e->ip += sizeof(ngx_http_script_var_code_t);
|
815
|
+
|
816
|
+
if (e->flushed) {
|
817
|
+
value = ngx_http_get_indexed_variable(e->request, code->index);
|
818
|
+
|
819
|
+
} else {
|
820
|
+
value = ngx_http_get_flushed_variable(e->request, code->index);
|
821
|
+
}
|
822
|
+
|
823
|
+
if (value && !value->not_found) {
|
824
|
+
return value->len;
|
825
|
+
}
|
826
|
+
|
827
|
+
return 0;
|
828
|
+
}
|
829
|
+
|
830
|
+
|
831
|
+
void
|
832
|
+
ngx_http_script_copy_var_code(ngx_http_script_engine_t *e)
|
833
|
+
{
|
834
|
+
u_char *p;
|
835
|
+
ngx_http_variable_value_t *value;
|
836
|
+
ngx_http_script_var_code_t *code;
|
837
|
+
|
838
|
+
code = (ngx_http_script_var_code_t *) e->ip;
|
839
|
+
|
840
|
+
e->ip += sizeof(ngx_http_script_var_code_t);
|
841
|
+
|
842
|
+
if (!e->skip) {
|
843
|
+
|
844
|
+
if (e->flushed) {
|
845
|
+
value = ngx_http_get_indexed_variable(e->request, code->index);
|
846
|
+
|
847
|
+
} else {
|
848
|
+
value = ngx_http_get_flushed_variable(e->request, code->index);
|
849
|
+
}
|
850
|
+
|
851
|
+
if (value && !value->not_found) {
|
852
|
+
p = e->pos;
|
853
|
+
e->pos = ngx_copy(p, value->data, value->len);
|
854
|
+
|
855
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP,
|
856
|
+
e->request->connection->log, 0,
|
857
|
+
"http script var: \"%*s\"", e->pos - p, p);
|
858
|
+
}
|
859
|
+
}
|
860
|
+
}
|
861
|
+
|
862
|
+
|
863
|
+
static ngx_int_t
|
864
|
+
ngx_http_script_add_args_code(ngx_http_script_compile_t *sc)
|
865
|
+
{
|
866
|
+
uintptr_t *code;
|
867
|
+
|
868
|
+
code = ngx_http_script_add_code(*sc->lengths, sizeof(uintptr_t), NULL);
|
869
|
+
if (code == NULL) {
|
870
|
+
return NGX_ERROR;
|
871
|
+
}
|
872
|
+
|
873
|
+
*code = (uintptr_t) ngx_http_script_mark_args_code;
|
874
|
+
|
875
|
+
code = ngx_http_script_add_code(*sc->values, sizeof(uintptr_t), &sc->main);
|
876
|
+
if (code == NULL) {
|
877
|
+
return NGX_ERROR;
|
878
|
+
}
|
879
|
+
|
880
|
+
*code = (uintptr_t) ngx_http_script_start_args_code;
|
881
|
+
|
882
|
+
return NGX_OK;
|
883
|
+
}
|
884
|
+
|
885
|
+
|
886
|
+
size_t
|
887
|
+
ngx_http_script_mark_args_code(ngx_http_script_engine_t *e)
|
888
|
+
{
|
889
|
+
e->is_args = 1;
|
890
|
+
e->ip += sizeof(uintptr_t);
|
891
|
+
|
892
|
+
return 1;
|
893
|
+
}
|
894
|
+
|
895
|
+
|
896
|
+
void
|
897
|
+
ngx_http_script_start_args_code(ngx_http_script_engine_t *e)
|
898
|
+
{
|
899
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
900
|
+
"http script args");
|
901
|
+
|
902
|
+
e->is_args = 1;
|
903
|
+
e->args = e->pos;
|
904
|
+
e->ip += sizeof(uintptr_t);
|
905
|
+
}
|
906
|
+
|
907
|
+
|
908
|
+
#if (NGX_PCRE)
|
909
|
+
|
910
|
+
void
|
911
|
+
ngx_http_script_regex_start_code(ngx_http_script_engine_t *e)
|
912
|
+
{
|
913
|
+
size_t len;
|
914
|
+
ngx_int_t rc;
|
915
|
+
ngx_uint_t n;
|
916
|
+
ngx_http_request_t *r;
|
917
|
+
ngx_http_script_engine_t le;
|
918
|
+
ngx_http_script_len_code_pt lcode;
|
919
|
+
ngx_http_script_regex_code_t *code;
|
920
|
+
|
921
|
+
code = (ngx_http_script_regex_code_t *) e->ip;
|
922
|
+
|
923
|
+
r = e->request;
|
924
|
+
|
925
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
926
|
+
"http script regex: \"%V\"", &code->name);
|
927
|
+
|
928
|
+
if (code->uri) {
|
929
|
+
e->line = r->uri;
|
930
|
+
} else {
|
931
|
+
e->sp--;
|
932
|
+
e->line.len = e->sp->len;
|
933
|
+
e->line.data = e->sp->data;
|
934
|
+
}
|
935
|
+
|
936
|
+
rc = ngx_http_regex_exec(r, code->regex, &e->line);
|
937
|
+
|
938
|
+
if (rc == NGX_DECLINED) {
|
939
|
+
if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
|
940
|
+
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
941
|
+
"\"%V\" does not match \"%V\"",
|
942
|
+
&code->name, &e->line);
|
943
|
+
}
|
944
|
+
|
945
|
+
r->ncaptures = 0;
|
946
|
+
|
947
|
+
if (code->test) {
|
948
|
+
if (code->negative_test) {
|
949
|
+
e->sp->len = 1;
|
950
|
+
e->sp->data = (u_char *) "1";
|
951
|
+
|
952
|
+
} else {
|
953
|
+
e->sp->len = 0;
|
954
|
+
e->sp->data = (u_char *) "";
|
955
|
+
}
|
956
|
+
|
957
|
+
e->sp++;
|
958
|
+
|
959
|
+
e->ip += sizeof(ngx_http_script_regex_code_t);
|
960
|
+
return;
|
961
|
+
}
|
962
|
+
|
963
|
+
e->ip += code->next;
|
964
|
+
return;
|
965
|
+
}
|
966
|
+
|
967
|
+
if (rc == NGX_ERROR) {
|
968
|
+
e->ip = ngx_http_script_exit;
|
969
|
+
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
970
|
+
return;
|
971
|
+
}
|
972
|
+
|
973
|
+
if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
|
974
|
+
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
975
|
+
"\"%V\" matches \"%V\"", &code->name, &e->line);
|
976
|
+
}
|
977
|
+
|
978
|
+
if (code->test) {
|
979
|
+
if (code->negative_test) {
|
980
|
+
e->sp->len = 0;
|
981
|
+
e->sp->data = (u_char *) "";
|
982
|
+
|
983
|
+
} else {
|
984
|
+
e->sp->len = 1;
|
985
|
+
e->sp->data = (u_char *) "1";
|
986
|
+
}
|
987
|
+
|
988
|
+
e->sp++;
|
989
|
+
|
990
|
+
e->ip += sizeof(ngx_http_script_regex_code_t);
|
991
|
+
return;
|
992
|
+
}
|
993
|
+
|
994
|
+
if (code->status) {
|
995
|
+
e->status = code->status;
|
996
|
+
|
997
|
+
if (!code->redirect) {
|
998
|
+
e->ip = ngx_http_script_exit;
|
999
|
+
return;
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
if (code->uri) {
|
1004
|
+
r->internal = 1;
|
1005
|
+
r->valid_unparsed_uri = 0;
|
1006
|
+
|
1007
|
+
if (code->break_cycle) {
|
1008
|
+
r->valid_location = 0;
|
1009
|
+
r->uri_changed = 0;
|
1010
|
+
|
1011
|
+
} else {
|
1012
|
+
r->uri_changed = 1;
|
1013
|
+
}
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
if (code->lengths == NULL) {
|
1017
|
+
e->buf.len = code->size;
|
1018
|
+
|
1019
|
+
if (code->uri) {
|
1020
|
+
if (r->ncaptures && (r->quoted_uri || r->plus_in_uri)) {
|
1021
|
+
e->buf.len += 2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len,
|
1022
|
+
NGX_ESCAPE_ARGS);
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
for (n = 2; n < r->ncaptures; n += 2) {
|
1027
|
+
e->buf.len += r->captures[n + 1] - r->captures[n];
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
} else {
|
1031
|
+
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
|
1032
|
+
|
1033
|
+
le.ip = code->lengths->elts;
|
1034
|
+
le.line = e->line;
|
1035
|
+
le.request = r;
|
1036
|
+
le.quote = code->redirect;
|
1037
|
+
|
1038
|
+
len = 0;
|
1039
|
+
|
1040
|
+
while (*(uintptr_t *) le.ip) {
|
1041
|
+
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
1042
|
+
len += lcode(&le);
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
e->buf.len = len;
|
1046
|
+
e->is_args = le.is_args;
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
if (code->add_args && r->args.len) {
|
1050
|
+
e->buf.len += r->args.len + 1;
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
e->buf.data = ngx_pnalloc(r->pool, e->buf.len);
|
1054
|
+
if (e->buf.data == NULL) {
|
1055
|
+
e->ip = ngx_http_script_exit;
|
1056
|
+
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1057
|
+
return;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
e->quote = code->redirect;
|
1061
|
+
|
1062
|
+
e->pos = e->buf.data;
|
1063
|
+
|
1064
|
+
e->ip += sizeof(ngx_http_script_regex_code_t);
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
|
1068
|
+
void
|
1069
|
+
ngx_http_script_regex_end_code(ngx_http_script_engine_t *e)
|
1070
|
+
{
|
1071
|
+
u_char *dst, *src;
|
1072
|
+
ngx_http_request_t *r;
|
1073
|
+
ngx_http_script_regex_end_code_t *code;
|
1074
|
+
|
1075
|
+
code = (ngx_http_script_regex_end_code_t *) e->ip;
|
1076
|
+
|
1077
|
+
r = e->request;
|
1078
|
+
|
1079
|
+
e->quote = 0;
|
1080
|
+
|
1081
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1082
|
+
"http script regex end");
|
1083
|
+
|
1084
|
+
if (code->redirect) {
|
1085
|
+
|
1086
|
+
dst = e->buf.data;
|
1087
|
+
src = e->buf.data;
|
1088
|
+
|
1089
|
+
ngx_unescape_uri(&dst, &src, e->pos - e->buf.data,
|
1090
|
+
NGX_UNESCAPE_REDIRECT);
|
1091
|
+
|
1092
|
+
if (src < e->pos) {
|
1093
|
+
dst = ngx_movemem(dst, src, e->pos - src);
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
e->pos = dst;
|
1097
|
+
|
1098
|
+
if (code->add_args && r->args.len) {
|
1099
|
+
*e->pos++ = (u_char) (code->args ? '&' : '?');
|
1100
|
+
e->pos = ngx_copy(e->pos, r->args.data, r->args.len);
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
e->buf.len = e->pos - e->buf.data;
|
1104
|
+
|
1105
|
+
if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
|
1106
|
+
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
1107
|
+
"rewritten redirect: \"%V\"", &e->buf);
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
ngx_http_clear_location(r);
|
1111
|
+
|
1112
|
+
r->headers_out.location = ngx_list_push(&r->headers_out.headers);
|
1113
|
+
if (r->headers_out.location == NULL) {
|
1114
|
+
e->ip = ngx_http_script_exit;
|
1115
|
+
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1116
|
+
return;
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
r->headers_out.location->hash = 1;
|
1120
|
+
ngx_str_set(&r->headers_out.location->key, "Location");
|
1121
|
+
r->headers_out.location->value = e->buf;
|
1122
|
+
|
1123
|
+
e->ip += sizeof(ngx_http_script_regex_end_code_t);
|
1124
|
+
return;
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
if (e->args) {
|
1128
|
+
e->buf.len = e->args - e->buf.data;
|
1129
|
+
|
1130
|
+
if (code->add_args && r->args.len) {
|
1131
|
+
*e->pos++ = '&';
|
1132
|
+
e->pos = ngx_copy(e->pos, r->args.data, r->args.len);
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
r->args.len = e->pos - e->args;
|
1136
|
+
r->args.data = e->args;
|
1137
|
+
|
1138
|
+
e->args = NULL;
|
1139
|
+
|
1140
|
+
} else {
|
1141
|
+
e->buf.len = e->pos - e->buf.data;
|
1142
|
+
|
1143
|
+
if (!code->add_args) {
|
1144
|
+
r->args.len = 0;
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
if (e->log || (r->connection->log->log_level & NGX_LOG_DEBUG_HTTP)) {
|
1149
|
+
ngx_log_error(NGX_LOG_NOTICE, r->connection->log, 0,
|
1150
|
+
"rewritten data: \"%V\", args: \"%V\"",
|
1151
|
+
&e->buf, &r->args);
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
if (code->uri) {
|
1155
|
+
r->uri = e->buf;
|
1156
|
+
|
1157
|
+
if (r->uri.len == 0) {
|
1158
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1159
|
+
"the rewritten URI has a zero length");
|
1160
|
+
e->ip = ngx_http_script_exit;
|
1161
|
+
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1162
|
+
return;
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
ngx_http_set_exten(r);
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
e->ip += sizeof(ngx_http_script_regex_end_code_t);
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
|
1172
|
+
static ngx_int_t
|
1173
|
+
ngx_http_script_add_capture_code(ngx_http_script_compile_t *sc, ngx_uint_t n)
|
1174
|
+
{
|
1175
|
+
ngx_http_script_copy_capture_code_t *code;
|
1176
|
+
|
1177
|
+
code = ngx_http_script_add_code(*sc->lengths,
|
1178
|
+
sizeof(ngx_http_script_copy_capture_code_t),
|
1179
|
+
NULL);
|
1180
|
+
if (code == NULL) {
|
1181
|
+
return NGX_ERROR;
|
1182
|
+
}
|
1183
|
+
|
1184
|
+
code->code = (ngx_http_script_code_pt)
|
1185
|
+
ngx_http_script_copy_capture_len_code;
|
1186
|
+
code->n = 2 * n;
|
1187
|
+
|
1188
|
+
|
1189
|
+
code = ngx_http_script_add_code(*sc->values,
|
1190
|
+
sizeof(ngx_http_script_copy_capture_code_t),
|
1191
|
+
&sc->main);
|
1192
|
+
if (code == NULL) {
|
1193
|
+
return NGX_ERROR;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
code->code = ngx_http_script_copy_capture_code;
|
1197
|
+
code->n = 2 * n;
|
1198
|
+
|
1199
|
+
if (sc->ncaptures < n) {
|
1200
|
+
sc->ncaptures = n;
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
return NGX_OK;
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
|
1207
|
+
size_t
|
1208
|
+
ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e)
|
1209
|
+
{
|
1210
|
+
int *cap;
|
1211
|
+
u_char *p;
|
1212
|
+
ngx_uint_t n;
|
1213
|
+
ngx_http_request_t *r;
|
1214
|
+
ngx_http_script_copy_capture_code_t *code;
|
1215
|
+
|
1216
|
+
r = e->request;
|
1217
|
+
|
1218
|
+
code = (ngx_http_script_copy_capture_code_t *) e->ip;
|
1219
|
+
|
1220
|
+
e->ip += sizeof(ngx_http_script_copy_capture_code_t);
|
1221
|
+
|
1222
|
+
n = code->n;
|
1223
|
+
|
1224
|
+
if (n < r->ncaptures) {
|
1225
|
+
|
1226
|
+
cap = r->captures;
|
1227
|
+
|
1228
|
+
if ((e->is_args || e->quote)
|
1229
|
+
&& (e->request->quoted_uri || e->request->plus_in_uri))
|
1230
|
+
{
|
1231
|
+
p = r->captures_data;
|
1232
|
+
|
1233
|
+
return cap[n + 1] - cap[n]
|
1234
|
+
+ 2 * ngx_escape_uri(NULL, &p[cap[n]], cap[n + 1] - cap[n],
|
1235
|
+
NGX_ESCAPE_ARGS);
|
1236
|
+
} else {
|
1237
|
+
return cap[n + 1] - cap[n];
|
1238
|
+
}
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
return 0;
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
|
1245
|
+
void
|
1246
|
+
ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e)
|
1247
|
+
{
|
1248
|
+
int *cap;
|
1249
|
+
u_char *p, *pos;
|
1250
|
+
ngx_uint_t n;
|
1251
|
+
ngx_http_request_t *r;
|
1252
|
+
ngx_http_script_copy_capture_code_t *code;
|
1253
|
+
|
1254
|
+
r = e->request;
|
1255
|
+
|
1256
|
+
code = (ngx_http_script_copy_capture_code_t *) e->ip;
|
1257
|
+
|
1258
|
+
e->ip += sizeof(ngx_http_script_copy_capture_code_t);
|
1259
|
+
|
1260
|
+
n = code->n;
|
1261
|
+
|
1262
|
+
pos = e->pos;
|
1263
|
+
|
1264
|
+
if (n < r->ncaptures) {
|
1265
|
+
|
1266
|
+
cap = r->captures;
|
1267
|
+
p = r->captures_data;
|
1268
|
+
|
1269
|
+
if ((e->is_args || e->quote)
|
1270
|
+
&& (e->request->quoted_uri || e->request->plus_in_uri))
|
1271
|
+
{
|
1272
|
+
e->pos = (u_char *) ngx_escape_uri(pos, &p[cap[n]],
|
1273
|
+
cap[n + 1] - cap[n],
|
1274
|
+
NGX_ESCAPE_ARGS);
|
1275
|
+
} else {
|
1276
|
+
e->pos = ngx_copy(pos, &p[cap[n]], cap[n + 1] - cap[n]);
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1281
|
+
"http script capture: \"%*s\"", e->pos - pos, pos);
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
#endif
|
1285
|
+
|
1286
|
+
|
1287
|
+
static ngx_int_t
|
1288
|
+
ngx_http_script_add_full_name_code(ngx_http_script_compile_t *sc)
|
1289
|
+
{
|
1290
|
+
ngx_http_script_full_name_code_t *code;
|
1291
|
+
|
1292
|
+
code = ngx_http_script_add_code(*sc->lengths,
|
1293
|
+
sizeof(ngx_http_script_full_name_code_t),
|
1294
|
+
NULL);
|
1295
|
+
if (code == NULL) {
|
1296
|
+
return NGX_ERROR;
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code;
|
1300
|
+
code->conf_prefix = sc->conf_prefix;
|
1301
|
+
|
1302
|
+
code = ngx_http_script_add_code(*sc->values,
|
1303
|
+
sizeof(ngx_http_script_full_name_code_t),
|
1304
|
+
&sc->main);
|
1305
|
+
if (code == NULL) {
|
1306
|
+
return NGX_ERROR;
|
1307
|
+
}
|
1308
|
+
|
1309
|
+
code->code = ngx_http_script_full_name_code;
|
1310
|
+
code->conf_prefix = sc->conf_prefix;
|
1311
|
+
|
1312
|
+
return NGX_OK;
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
|
1316
|
+
static size_t
|
1317
|
+
ngx_http_script_full_name_len_code(ngx_http_script_engine_t *e)
|
1318
|
+
{
|
1319
|
+
ngx_http_script_full_name_code_t *code;
|
1320
|
+
|
1321
|
+
code = (ngx_http_script_full_name_code_t *) e->ip;
|
1322
|
+
|
1323
|
+
e->ip += sizeof(ngx_http_script_full_name_code_t);
|
1324
|
+
|
1325
|
+
return code->conf_prefix ? ngx_cycle->conf_prefix.len:
|
1326
|
+
ngx_cycle->prefix.len;
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
|
1330
|
+
static void
|
1331
|
+
ngx_http_script_full_name_code(ngx_http_script_engine_t *e)
|
1332
|
+
{
|
1333
|
+
ngx_http_script_full_name_code_t *code;
|
1334
|
+
|
1335
|
+
ngx_str_t value;
|
1336
|
+
|
1337
|
+
code = (ngx_http_script_full_name_code_t *) e->ip;
|
1338
|
+
|
1339
|
+
value.data = e->buf.data;
|
1340
|
+
value.len = e->pos - e->buf.data;
|
1341
|
+
|
1342
|
+
if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &value, code->conf_prefix)
|
1343
|
+
!= NGX_OK)
|
1344
|
+
{
|
1345
|
+
e->ip = ngx_http_script_exit;
|
1346
|
+
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1347
|
+
return;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
e->buf = value;
|
1351
|
+
|
1352
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1353
|
+
"http script fullname: \"%V\"", &value);
|
1354
|
+
|
1355
|
+
e->ip += sizeof(ngx_http_script_full_name_code_t);
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
|
1359
|
+
void
|
1360
|
+
ngx_http_script_return_code(ngx_http_script_engine_t *e)
|
1361
|
+
{
|
1362
|
+
ngx_http_script_return_code_t *code;
|
1363
|
+
|
1364
|
+
code = (ngx_http_script_return_code_t *) e->ip;
|
1365
|
+
|
1366
|
+
if (code->status < NGX_HTTP_BAD_REQUEST
|
1367
|
+
|| code->text.value.len
|
1368
|
+
|| code->text.lengths)
|
1369
|
+
{
|
1370
|
+
e->status = ngx_http_send_response(e->request, code->status, NULL,
|
1371
|
+
&code->text);
|
1372
|
+
} else {
|
1373
|
+
e->status = code->status;
|
1374
|
+
}
|
1375
|
+
|
1376
|
+
e->ip = ngx_http_script_exit;
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
|
1380
|
+
void
|
1381
|
+
ngx_http_script_break_code(ngx_http_script_engine_t *e)
|
1382
|
+
{
|
1383
|
+
e->request->uri_changed = 0;
|
1384
|
+
|
1385
|
+
e->ip = ngx_http_script_exit;
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
|
1389
|
+
void
|
1390
|
+
ngx_http_script_if_code(ngx_http_script_engine_t *e)
|
1391
|
+
{
|
1392
|
+
ngx_http_script_if_code_t *code;
|
1393
|
+
|
1394
|
+
code = (ngx_http_script_if_code_t *) e->ip;
|
1395
|
+
|
1396
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1397
|
+
"http script if");
|
1398
|
+
|
1399
|
+
e->sp--;
|
1400
|
+
|
1401
|
+
if (e->sp->len && (e->sp->len !=1 || e->sp->data[0] != '0')) {
|
1402
|
+
if (code->loc_conf) {
|
1403
|
+
e->request->loc_conf = code->loc_conf;
|
1404
|
+
ngx_http_update_location_config(e->request);
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
e->ip += sizeof(ngx_http_script_if_code_t);
|
1408
|
+
return;
|
1409
|
+
}
|
1410
|
+
|
1411
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1412
|
+
"http script if: false");
|
1413
|
+
|
1414
|
+
e->ip += code->next;
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
|
1418
|
+
void
|
1419
|
+
ngx_http_script_equal_code(ngx_http_script_engine_t *e)
|
1420
|
+
{
|
1421
|
+
ngx_http_variable_value_t *val, *res;
|
1422
|
+
|
1423
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1424
|
+
"http script equal");
|
1425
|
+
|
1426
|
+
e->sp--;
|
1427
|
+
val = e->sp;
|
1428
|
+
res = e->sp - 1;
|
1429
|
+
|
1430
|
+
e->ip += sizeof(uintptr_t);
|
1431
|
+
|
1432
|
+
if (val->len == res->len
|
1433
|
+
&& ngx_strncmp(val->data, res->data, res->len) == 0)
|
1434
|
+
{
|
1435
|
+
*res = ngx_http_variable_true_value;
|
1436
|
+
return;
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1440
|
+
"http script equal: no");
|
1441
|
+
|
1442
|
+
*res = ngx_http_variable_null_value;
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
|
1446
|
+
void
|
1447
|
+
ngx_http_script_not_equal_code(ngx_http_script_engine_t *e)
|
1448
|
+
{
|
1449
|
+
ngx_http_variable_value_t *val, *res;
|
1450
|
+
|
1451
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1452
|
+
"http script not equal");
|
1453
|
+
|
1454
|
+
e->sp--;
|
1455
|
+
val = e->sp;
|
1456
|
+
res = e->sp - 1;
|
1457
|
+
|
1458
|
+
e->ip += sizeof(uintptr_t);
|
1459
|
+
|
1460
|
+
if (val->len == res->len
|
1461
|
+
&& ngx_strncmp(val->data, res->data, res->len) == 0)
|
1462
|
+
{
|
1463
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1464
|
+
"http script not equal: no");
|
1465
|
+
|
1466
|
+
*res = ngx_http_variable_null_value;
|
1467
|
+
return;
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
*res = ngx_http_variable_true_value;
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
|
1474
|
+
void
|
1475
|
+
ngx_http_script_file_code(ngx_http_script_engine_t *e)
|
1476
|
+
{
|
1477
|
+
ngx_str_t path;
|
1478
|
+
ngx_http_request_t *r;
|
1479
|
+
ngx_open_file_info_t of;
|
1480
|
+
ngx_http_core_loc_conf_t *clcf;
|
1481
|
+
ngx_http_variable_value_t *value;
|
1482
|
+
ngx_http_script_file_code_t *code;
|
1483
|
+
|
1484
|
+
value = e->sp - 1;
|
1485
|
+
|
1486
|
+
code = (ngx_http_script_file_code_t *) e->ip;
|
1487
|
+
e->ip += sizeof(ngx_http_script_file_code_t);
|
1488
|
+
|
1489
|
+
path.len = value->len - 1;
|
1490
|
+
path.data = value->data;
|
1491
|
+
|
1492
|
+
r = e->request;
|
1493
|
+
|
1494
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1495
|
+
"http script file op %p \"%V\"", code->op, &path);
|
1496
|
+
|
1497
|
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
1498
|
+
|
1499
|
+
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
1500
|
+
|
1501
|
+
of.read_ahead = clcf->read_ahead;
|
1502
|
+
of.directio = clcf->directio;
|
1503
|
+
of.valid = clcf->open_file_cache_valid;
|
1504
|
+
of.min_uses = clcf->open_file_cache_min_uses;
|
1505
|
+
of.test_only = 1;
|
1506
|
+
of.errors = clcf->open_file_cache_errors;
|
1507
|
+
of.events = clcf->open_file_cache_events;
|
1508
|
+
|
1509
|
+
if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
|
1510
|
+
!= NGX_OK)
|
1511
|
+
{
|
1512
|
+
if (of.err != NGX_ENOENT
|
1513
|
+
&& of.err != NGX_ENOTDIR
|
1514
|
+
&& of.err != NGX_ENAMETOOLONG)
|
1515
|
+
{
|
1516
|
+
ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
|
1517
|
+
"%s \"%s\" failed", of.failed, value->data);
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
switch (code->op) {
|
1521
|
+
|
1522
|
+
case ngx_http_script_file_plain:
|
1523
|
+
case ngx_http_script_file_dir:
|
1524
|
+
case ngx_http_script_file_exists:
|
1525
|
+
case ngx_http_script_file_exec:
|
1526
|
+
goto false_value;
|
1527
|
+
|
1528
|
+
case ngx_http_script_file_not_plain:
|
1529
|
+
case ngx_http_script_file_not_dir:
|
1530
|
+
case ngx_http_script_file_not_exists:
|
1531
|
+
case ngx_http_script_file_not_exec:
|
1532
|
+
goto true_value;
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
goto false_value;
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
switch (code->op) {
|
1539
|
+
case ngx_http_script_file_plain:
|
1540
|
+
if (of.is_file) {
|
1541
|
+
goto true_value;
|
1542
|
+
}
|
1543
|
+
goto false_value;
|
1544
|
+
|
1545
|
+
case ngx_http_script_file_not_plain:
|
1546
|
+
if (of.is_file) {
|
1547
|
+
goto false_value;
|
1548
|
+
}
|
1549
|
+
goto true_value;
|
1550
|
+
|
1551
|
+
case ngx_http_script_file_dir:
|
1552
|
+
if (of.is_dir) {
|
1553
|
+
goto true_value;
|
1554
|
+
}
|
1555
|
+
goto false_value;
|
1556
|
+
|
1557
|
+
case ngx_http_script_file_not_dir:
|
1558
|
+
if (of.is_dir) {
|
1559
|
+
goto false_value;
|
1560
|
+
}
|
1561
|
+
goto true_value;
|
1562
|
+
|
1563
|
+
case ngx_http_script_file_exists:
|
1564
|
+
if (of.is_file || of.is_dir || of.is_link) {
|
1565
|
+
goto true_value;
|
1566
|
+
}
|
1567
|
+
goto false_value;
|
1568
|
+
|
1569
|
+
case ngx_http_script_file_not_exists:
|
1570
|
+
if (of.is_file || of.is_dir || of.is_link) {
|
1571
|
+
goto false_value;
|
1572
|
+
}
|
1573
|
+
goto true_value;
|
1574
|
+
|
1575
|
+
case ngx_http_script_file_exec:
|
1576
|
+
if (of.is_exec) {
|
1577
|
+
goto true_value;
|
1578
|
+
}
|
1579
|
+
goto false_value;
|
1580
|
+
|
1581
|
+
case ngx_http_script_file_not_exec:
|
1582
|
+
if (of.is_exec) {
|
1583
|
+
goto false_value;
|
1584
|
+
}
|
1585
|
+
goto true_value;
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
false_value:
|
1589
|
+
|
1590
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1591
|
+
"http script file op false");
|
1592
|
+
|
1593
|
+
*value = ngx_http_variable_null_value;
|
1594
|
+
return;
|
1595
|
+
|
1596
|
+
true_value:
|
1597
|
+
|
1598
|
+
*value = ngx_http_variable_true_value;
|
1599
|
+
return;
|
1600
|
+
}
|
1601
|
+
|
1602
|
+
|
1603
|
+
void
|
1604
|
+
ngx_http_script_complex_value_code(ngx_http_script_engine_t *e)
|
1605
|
+
{
|
1606
|
+
size_t len;
|
1607
|
+
ngx_http_script_engine_t le;
|
1608
|
+
ngx_http_script_len_code_pt lcode;
|
1609
|
+
ngx_http_script_complex_value_code_t *code;
|
1610
|
+
|
1611
|
+
code = (ngx_http_script_complex_value_code_t *) e->ip;
|
1612
|
+
|
1613
|
+
e->ip += sizeof(ngx_http_script_complex_value_code_t);
|
1614
|
+
|
1615
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1616
|
+
"http script complex value");
|
1617
|
+
|
1618
|
+
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
|
1619
|
+
|
1620
|
+
le.ip = code->lengths->elts;
|
1621
|
+
le.line = e->line;
|
1622
|
+
le.request = e->request;
|
1623
|
+
le.quote = e->quote;
|
1624
|
+
|
1625
|
+
for (len = 0; *(uintptr_t *) le.ip; len += lcode(&le)) {
|
1626
|
+
lcode = *(ngx_http_script_len_code_pt *) le.ip;
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
e->buf.len = len;
|
1630
|
+
e->buf.data = ngx_pnalloc(e->request->pool, len);
|
1631
|
+
if (e->buf.data == NULL) {
|
1632
|
+
e->ip = ngx_http_script_exit;
|
1633
|
+
e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1634
|
+
return;
|
1635
|
+
}
|
1636
|
+
|
1637
|
+
e->pos = e->buf.data;
|
1638
|
+
|
1639
|
+
e->sp->len = e->buf.len;
|
1640
|
+
e->sp->data = e->buf.data;
|
1641
|
+
e->sp++;
|
1642
|
+
}
|
1643
|
+
|
1644
|
+
|
1645
|
+
void
|
1646
|
+
ngx_http_script_value_code(ngx_http_script_engine_t *e)
|
1647
|
+
{
|
1648
|
+
ngx_http_script_value_code_t *code;
|
1649
|
+
|
1650
|
+
code = (ngx_http_script_value_code_t *) e->ip;
|
1651
|
+
|
1652
|
+
e->ip += sizeof(ngx_http_script_value_code_t);
|
1653
|
+
|
1654
|
+
e->sp->len = code->text_len;
|
1655
|
+
e->sp->data = (u_char *) code->text_data;
|
1656
|
+
|
1657
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1658
|
+
"http script value: \"%v\"", e->sp);
|
1659
|
+
|
1660
|
+
e->sp++;
|
1661
|
+
}
|
1662
|
+
|
1663
|
+
|
1664
|
+
void
|
1665
|
+
ngx_http_script_set_var_code(ngx_http_script_engine_t *e)
|
1666
|
+
{
|
1667
|
+
ngx_http_request_t *r;
|
1668
|
+
ngx_http_script_var_code_t *code;
|
1669
|
+
|
1670
|
+
code = (ngx_http_script_var_code_t *) e->ip;
|
1671
|
+
|
1672
|
+
e->ip += sizeof(ngx_http_script_var_code_t);
|
1673
|
+
|
1674
|
+
r = e->request;
|
1675
|
+
|
1676
|
+
e->sp--;
|
1677
|
+
|
1678
|
+
r->variables[code->index].len = e->sp->len;
|
1679
|
+
r->variables[code->index].valid = 1;
|
1680
|
+
r->variables[code->index].no_cacheable = 0;
|
1681
|
+
r->variables[code->index].not_found = 0;
|
1682
|
+
r->variables[code->index].data = e->sp->data;
|
1683
|
+
|
1684
|
+
#if (NGX_DEBUG)
|
1685
|
+
{
|
1686
|
+
ngx_http_variable_t *v;
|
1687
|
+
ngx_http_core_main_conf_t *cmcf;
|
1688
|
+
|
1689
|
+
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
1690
|
+
|
1691
|
+
v = cmcf->variables.elts;
|
1692
|
+
|
1693
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1694
|
+
"http script set $%V", &v[code->index].name);
|
1695
|
+
}
|
1696
|
+
#endif
|
1697
|
+
}
|
1698
|
+
|
1699
|
+
|
1700
|
+
void
|
1701
|
+
ngx_http_script_var_set_handler_code(ngx_http_script_engine_t *e)
|
1702
|
+
{
|
1703
|
+
ngx_http_script_var_handler_code_t *code;
|
1704
|
+
|
1705
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1706
|
+
"http script set var handler");
|
1707
|
+
|
1708
|
+
code = (ngx_http_script_var_handler_code_t *) e->ip;
|
1709
|
+
|
1710
|
+
e->ip += sizeof(ngx_http_script_var_handler_code_t);
|
1711
|
+
|
1712
|
+
e->sp--;
|
1713
|
+
|
1714
|
+
code->handler(e->request, e->sp, code->data);
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
|
1718
|
+
void
|
1719
|
+
ngx_http_script_var_code(ngx_http_script_engine_t *e)
|
1720
|
+
{
|
1721
|
+
ngx_http_variable_value_t *value;
|
1722
|
+
ngx_http_script_var_code_t *code;
|
1723
|
+
|
1724
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1725
|
+
"http script var");
|
1726
|
+
|
1727
|
+
code = (ngx_http_script_var_code_t *) e->ip;
|
1728
|
+
|
1729
|
+
e->ip += sizeof(ngx_http_script_var_code_t);
|
1730
|
+
|
1731
|
+
value = ngx_http_get_flushed_variable(e->request, code->index);
|
1732
|
+
|
1733
|
+
if (value && !value->not_found) {
|
1734
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, e->request->connection->log, 0,
|
1735
|
+
"http script var: \"%v\"", value);
|
1736
|
+
|
1737
|
+
*e->sp = *value;
|
1738
|
+
e->sp++;
|
1739
|
+
|
1740
|
+
return;
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
*e->sp = ngx_http_variable_null_value;
|
1744
|
+
e->sp++;
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
|
1748
|
+
void
|
1749
|
+
ngx_http_script_nop_code(ngx_http_script_engine_t *e)
|
1750
|
+
{
|
1751
|
+
e->ip += sizeof(uintptr_t);
|
1752
|
+
}
|