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,1734 @@
|
|
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 uint32_t usual[] = {
|
14
|
+
0xffffdbfe, /* 1111 1111 1111 1111 1101 1011 1111 1110 */
|
15
|
+
|
16
|
+
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
17
|
+
0x7fff37d6, /* 0111 1111 1111 1111 0011 0111 1101 0110 */
|
18
|
+
|
19
|
+
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
20
|
+
#if (NGX_WIN32)
|
21
|
+
0xefffffff, /* 1110 1111 1111 1111 1111 1111 1111 1111 */
|
22
|
+
#else
|
23
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
24
|
+
#endif
|
25
|
+
|
26
|
+
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
27
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
28
|
+
|
29
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
30
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
31
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
32
|
+
0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
33
|
+
};
|
34
|
+
|
35
|
+
|
36
|
+
#if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED)
|
37
|
+
|
38
|
+
#define ngx_str3_cmp(m, c0, c1, c2, c3) \
|
39
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0)
|
40
|
+
|
41
|
+
#define ngx_str3Ocmp(m, c0, c1, c2, c3) \
|
42
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0)
|
43
|
+
|
44
|
+
#define ngx_str4cmp(m, c0, c1, c2, c3) \
|
45
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0)
|
46
|
+
|
47
|
+
#define ngx_str5cmp(m, c0, c1, c2, c3, c4) \
|
48
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \
|
49
|
+
&& m[4] == c4
|
50
|
+
|
51
|
+
#define ngx_str6cmp(m, c0, c1, c2, c3, c4, c5) \
|
52
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \
|
53
|
+
&& (((uint32_t *) m)[1] & 0xffff) == ((c5 << 8) | c4)
|
54
|
+
|
55
|
+
#define ngx_str7_cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \
|
56
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \
|
57
|
+
&& ((uint32_t *) m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4)
|
58
|
+
|
59
|
+
#define ngx_str8cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \
|
60
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \
|
61
|
+
&& ((uint32_t *) m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4)
|
62
|
+
|
63
|
+
#define ngx_str9cmp(m, c0, c1, c2, c3, c4, c5, c6, c7, c8) \
|
64
|
+
*(uint32_t *) m == ((c3 << 24) | (c2 << 16) | (c1 << 8) | c0) \
|
65
|
+
&& ((uint32_t *) m)[1] == ((c7 << 24) | (c6 << 16) | (c5 << 8) | c4) \
|
66
|
+
&& m[8] == c8
|
67
|
+
|
68
|
+
#else /* !(NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED) */
|
69
|
+
|
70
|
+
#define ngx_str3_cmp(m, c0, c1, c2, c3) \
|
71
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2
|
72
|
+
|
73
|
+
#define ngx_str3Ocmp(m, c0, c1, c2, c3) \
|
74
|
+
m[0] == c0 && m[2] == c2 && m[3] == c3
|
75
|
+
|
76
|
+
#define ngx_str4cmp(m, c0, c1, c2, c3) \
|
77
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3
|
78
|
+
|
79
|
+
#define ngx_str5cmp(m, c0, c1, c2, c3, c4) \
|
80
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 && m[4] == c4
|
81
|
+
|
82
|
+
#define ngx_str6cmp(m, c0, c1, c2, c3, c4, c5) \
|
83
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \
|
84
|
+
&& m[4] == c4 && m[5] == c5
|
85
|
+
|
86
|
+
#define ngx_str7_cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \
|
87
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \
|
88
|
+
&& m[4] == c4 && m[5] == c5 && m[6] == c6
|
89
|
+
|
90
|
+
#define ngx_str8cmp(m, c0, c1, c2, c3, c4, c5, c6, c7) \
|
91
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \
|
92
|
+
&& m[4] == c4 && m[5] == c5 && m[6] == c6 && m[7] == c7
|
93
|
+
|
94
|
+
#define ngx_str9cmp(m, c0, c1, c2, c3, c4, c5, c6, c7, c8) \
|
95
|
+
m[0] == c0 && m[1] == c1 && m[2] == c2 && m[3] == c3 \
|
96
|
+
&& m[4] == c4 && m[5] == c5 && m[6] == c6 && m[7] == c7 && m[8] == c8
|
97
|
+
|
98
|
+
#endif
|
99
|
+
|
100
|
+
|
101
|
+
/* gcc, icc, msvc and others compile these switches as an jump table */
|
102
|
+
|
103
|
+
ngx_int_t
|
104
|
+
ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
105
|
+
{
|
106
|
+
u_char c, ch, *p, *m;
|
107
|
+
enum {
|
108
|
+
sw_start = 0,
|
109
|
+
sw_method,
|
110
|
+
sw_spaces_before_uri,
|
111
|
+
sw_schema,
|
112
|
+
sw_schema_slash,
|
113
|
+
sw_schema_slash_slash,
|
114
|
+
sw_host,
|
115
|
+
sw_port,
|
116
|
+
sw_host_http_09,
|
117
|
+
sw_after_slash_in_uri,
|
118
|
+
sw_check_uri,
|
119
|
+
sw_check_uri_http_09,
|
120
|
+
sw_uri,
|
121
|
+
sw_http_09,
|
122
|
+
sw_http_H,
|
123
|
+
sw_http_HT,
|
124
|
+
sw_http_HTT,
|
125
|
+
sw_http_HTTP,
|
126
|
+
sw_first_major_digit,
|
127
|
+
sw_major_digit,
|
128
|
+
sw_first_minor_digit,
|
129
|
+
sw_minor_digit,
|
130
|
+
sw_spaces_after_digit,
|
131
|
+
sw_almost_done
|
132
|
+
} state;
|
133
|
+
|
134
|
+
state = r->state;
|
135
|
+
|
136
|
+
for (p = b->pos; p < b->last; p++) {
|
137
|
+
ch = *p;
|
138
|
+
|
139
|
+
switch (state) {
|
140
|
+
|
141
|
+
/* HTTP methods: GET, HEAD, POST */
|
142
|
+
case sw_start:
|
143
|
+
r->request_start = p;
|
144
|
+
|
145
|
+
if (ch == CR || ch == LF) {
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
|
149
|
+
if ((ch < 'A' || ch > 'Z') && ch != '_') {
|
150
|
+
return NGX_HTTP_PARSE_INVALID_METHOD;
|
151
|
+
}
|
152
|
+
|
153
|
+
state = sw_method;
|
154
|
+
break;
|
155
|
+
|
156
|
+
case sw_method:
|
157
|
+
if (ch == ' ') {
|
158
|
+
r->method_end = p - 1;
|
159
|
+
m = r->request_start;
|
160
|
+
|
161
|
+
switch (p - m) {
|
162
|
+
|
163
|
+
case 3:
|
164
|
+
if (ngx_str3_cmp(m, 'G', 'E', 'T', ' ')) {
|
165
|
+
r->method = NGX_HTTP_GET;
|
166
|
+
break;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (ngx_str3_cmp(m, 'P', 'U', 'T', ' ')) {
|
170
|
+
r->method = NGX_HTTP_PUT;
|
171
|
+
break;
|
172
|
+
}
|
173
|
+
|
174
|
+
break;
|
175
|
+
|
176
|
+
case 4:
|
177
|
+
if (m[1] == 'O') {
|
178
|
+
|
179
|
+
if (ngx_str3Ocmp(m, 'P', 'O', 'S', 'T')) {
|
180
|
+
r->method = NGX_HTTP_POST;
|
181
|
+
break;
|
182
|
+
}
|
183
|
+
|
184
|
+
if (ngx_str3Ocmp(m, 'C', 'O', 'P', 'Y')) {
|
185
|
+
r->method = NGX_HTTP_COPY;
|
186
|
+
break;
|
187
|
+
}
|
188
|
+
|
189
|
+
if (ngx_str3Ocmp(m, 'M', 'O', 'V', 'E')) {
|
190
|
+
r->method = NGX_HTTP_MOVE;
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (ngx_str3Ocmp(m, 'L', 'O', 'C', 'K')) {
|
195
|
+
r->method = NGX_HTTP_LOCK;
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
|
199
|
+
} else {
|
200
|
+
|
201
|
+
if (ngx_str4cmp(m, 'H', 'E', 'A', 'D')) {
|
202
|
+
r->method = NGX_HTTP_HEAD;
|
203
|
+
break;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
break;
|
208
|
+
|
209
|
+
case 5:
|
210
|
+
if (ngx_str5cmp(m, 'M', 'K', 'C', 'O', 'L')) {
|
211
|
+
r->method = NGX_HTTP_MKCOL;
|
212
|
+
}
|
213
|
+
|
214
|
+
if (ngx_str5cmp(m, 'P', 'A', 'T', 'C', 'H')) {
|
215
|
+
r->method = NGX_HTTP_PATCH;
|
216
|
+
}
|
217
|
+
|
218
|
+
if (ngx_str5cmp(m, 'T', 'R', 'A', 'C', 'E')) {
|
219
|
+
r->method = NGX_HTTP_TRACE;
|
220
|
+
}
|
221
|
+
|
222
|
+
break;
|
223
|
+
|
224
|
+
case 6:
|
225
|
+
if (ngx_str6cmp(m, 'D', 'E', 'L', 'E', 'T', 'E')) {
|
226
|
+
r->method = NGX_HTTP_DELETE;
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
|
230
|
+
if (ngx_str6cmp(m, 'U', 'N', 'L', 'O', 'C', 'K')) {
|
231
|
+
r->method = NGX_HTTP_UNLOCK;
|
232
|
+
break;
|
233
|
+
}
|
234
|
+
|
235
|
+
break;
|
236
|
+
|
237
|
+
case 7:
|
238
|
+
if (ngx_str7_cmp(m, 'O', 'P', 'T', 'I', 'O', 'N', 'S', ' '))
|
239
|
+
{
|
240
|
+
r->method = NGX_HTTP_OPTIONS;
|
241
|
+
}
|
242
|
+
|
243
|
+
break;
|
244
|
+
|
245
|
+
case 8:
|
246
|
+
if (ngx_str8cmp(m, 'P', 'R', 'O', 'P', 'F', 'I', 'N', 'D'))
|
247
|
+
{
|
248
|
+
r->method = NGX_HTTP_PROPFIND;
|
249
|
+
}
|
250
|
+
|
251
|
+
break;
|
252
|
+
|
253
|
+
case 9:
|
254
|
+
if (ngx_str9cmp(m,
|
255
|
+
'P', 'R', 'O', 'P', 'P', 'A', 'T', 'C', 'H'))
|
256
|
+
{
|
257
|
+
r->method = NGX_HTTP_PROPPATCH;
|
258
|
+
}
|
259
|
+
|
260
|
+
break;
|
261
|
+
}
|
262
|
+
|
263
|
+
state = sw_spaces_before_uri;
|
264
|
+
break;
|
265
|
+
}
|
266
|
+
|
267
|
+
if ((ch < 'A' || ch > 'Z') && ch != '_') {
|
268
|
+
return NGX_HTTP_PARSE_INVALID_METHOD;
|
269
|
+
}
|
270
|
+
|
271
|
+
break;
|
272
|
+
|
273
|
+
/* space* before URI */
|
274
|
+
case sw_spaces_before_uri:
|
275
|
+
|
276
|
+
if (ch == '/') {
|
277
|
+
r->uri_start = p;
|
278
|
+
state = sw_after_slash_in_uri;
|
279
|
+
break;
|
280
|
+
}
|
281
|
+
|
282
|
+
c = (u_char) (ch | 0x20);
|
283
|
+
if (c >= 'a' && c <= 'z') {
|
284
|
+
r->schema_start = p;
|
285
|
+
state = sw_schema;
|
286
|
+
break;
|
287
|
+
}
|
288
|
+
|
289
|
+
switch (ch) {
|
290
|
+
case ' ':
|
291
|
+
break;
|
292
|
+
default:
|
293
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
294
|
+
}
|
295
|
+
break;
|
296
|
+
|
297
|
+
case sw_schema:
|
298
|
+
|
299
|
+
c = (u_char) (ch | 0x20);
|
300
|
+
if (c >= 'a' && c <= 'z') {
|
301
|
+
break;
|
302
|
+
}
|
303
|
+
|
304
|
+
switch (ch) {
|
305
|
+
case ':':
|
306
|
+
r->schema_end = p;
|
307
|
+
state = sw_schema_slash;
|
308
|
+
break;
|
309
|
+
default:
|
310
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
311
|
+
}
|
312
|
+
break;
|
313
|
+
|
314
|
+
case sw_schema_slash:
|
315
|
+
switch (ch) {
|
316
|
+
case '/':
|
317
|
+
state = sw_schema_slash_slash;
|
318
|
+
break;
|
319
|
+
default:
|
320
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
321
|
+
}
|
322
|
+
break;
|
323
|
+
|
324
|
+
case sw_schema_slash_slash:
|
325
|
+
switch (ch) {
|
326
|
+
case '/':
|
327
|
+
r->host_start = p + 1;
|
328
|
+
state = sw_host;
|
329
|
+
break;
|
330
|
+
default:
|
331
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
332
|
+
}
|
333
|
+
break;
|
334
|
+
|
335
|
+
case sw_host:
|
336
|
+
|
337
|
+
c = (u_char) (ch | 0x20);
|
338
|
+
if (c >= 'a' && c <= 'z') {
|
339
|
+
break;
|
340
|
+
}
|
341
|
+
|
342
|
+
if ((ch >= '0' && ch <= '9') || ch == '.' || ch == '-') {
|
343
|
+
break;
|
344
|
+
}
|
345
|
+
|
346
|
+
r->host_end = p;
|
347
|
+
|
348
|
+
switch (ch) {
|
349
|
+
case ':':
|
350
|
+
state = sw_port;
|
351
|
+
break;
|
352
|
+
case '/':
|
353
|
+
r->uri_start = p;
|
354
|
+
state = sw_after_slash_in_uri;
|
355
|
+
break;
|
356
|
+
case ' ':
|
357
|
+
/*
|
358
|
+
* use single "/" from request line to preserve pointers,
|
359
|
+
* if request line will be copied to large client buffer
|
360
|
+
*/
|
361
|
+
r->uri_start = r->schema_end + 1;
|
362
|
+
r->uri_end = r->schema_end + 2;
|
363
|
+
state = sw_host_http_09;
|
364
|
+
break;
|
365
|
+
default:
|
366
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
367
|
+
}
|
368
|
+
break;
|
369
|
+
|
370
|
+
case sw_port:
|
371
|
+
if (ch >= '0' && ch <= '9') {
|
372
|
+
break;
|
373
|
+
}
|
374
|
+
|
375
|
+
switch (ch) {
|
376
|
+
case '/':
|
377
|
+
r->port_end = p;
|
378
|
+
r->uri_start = p;
|
379
|
+
state = sw_after_slash_in_uri;
|
380
|
+
break;
|
381
|
+
case ' ':
|
382
|
+
r->port_end = p;
|
383
|
+
/*
|
384
|
+
* use single "/" from request line to preserve pointers,
|
385
|
+
* if request line will be copied to large client buffer
|
386
|
+
*/
|
387
|
+
r->uri_start = r->schema_end + 1;
|
388
|
+
r->uri_end = r->schema_end + 2;
|
389
|
+
state = sw_host_http_09;
|
390
|
+
break;
|
391
|
+
default:
|
392
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
393
|
+
}
|
394
|
+
break;
|
395
|
+
|
396
|
+
/* space+ after "http://host[:port] " */
|
397
|
+
case sw_host_http_09:
|
398
|
+
switch (ch) {
|
399
|
+
case ' ':
|
400
|
+
break;
|
401
|
+
case CR:
|
402
|
+
r->http_minor = 9;
|
403
|
+
state = sw_almost_done;
|
404
|
+
break;
|
405
|
+
case LF:
|
406
|
+
r->http_minor = 9;
|
407
|
+
goto done;
|
408
|
+
case 'H':
|
409
|
+
r->http_protocol.data = p;
|
410
|
+
state = sw_http_H;
|
411
|
+
break;
|
412
|
+
default:
|
413
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
414
|
+
}
|
415
|
+
break;
|
416
|
+
|
417
|
+
|
418
|
+
/* check "/.", "//", "%", and "\" (Win32) in URI */
|
419
|
+
case sw_after_slash_in_uri:
|
420
|
+
|
421
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
422
|
+
state = sw_check_uri;
|
423
|
+
break;
|
424
|
+
}
|
425
|
+
|
426
|
+
switch (ch) {
|
427
|
+
case ' ':
|
428
|
+
r->uri_end = p;
|
429
|
+
state = sw_check_uri_http_09;
|
430
|
+
break;
|
431
|
+
case CR:
|
432
|
+
r->uri_end = p;
|
433
|
+
r->http_minor = 9;
|
434
|
+
state = sw_almost_done;
|
435
|
+
break;
|
436
|
+
case LF:
|
437
|
+
r->uri_end = p;
|
438
|
+
r->http_minor = 9;
|
439
|
+
goto done;
|
440
|
+
case '.':
|
441
|
+
r->complex_uri = 1;
|
442
|
+
state = sw_uri;
|
443
|
+
break;
|
444
|
+
case '%':
|
445
|
+
r->quoted_uri = 1;
|
446
|
+
state = sw_uri;
|
447
|
+
break;
|
448
|
+
case '/':
|
449
|
+
r->complex_uri = 1;
|
450
|
+
state = sw_uri;
|
451
|
+
break;
|
452
|
+
#if (NGX_WIN32)
|
453
|
+
case '\\':
|
454
|
+
r->complex_uri = 1;
|
455
|
+
state = sw_uri;
|
456
|
+
break;
|
457
|
+
#endif
|
458
|
+
case '?':
|
459
|
+
r->args_start = p + 1;
|
460
|
+
state = sw_uri;
|
461
|
+
break;
|
462
|
+
case '#':
|
463
|
+
r->complex_uri = 1;
|
464
|
+
state = sw_uri;
|
465
|
+
break;
|
466
|
+
case '+':
|
467
|
+
r->plus_in_uri = 1;
|
468
|
+
break;
|
469
|
+
case '\0':
|
470
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
471
|
+
default:
|
472
|
+
state = sw_check_uri;
|
473
|
+
break;
|
474
|
+
}
|
475
|
+
break;
|
476
|
+
|
477
|
+
/* check "/", "%" and "\" (Win32) in URI */
|
478
|
+
case sw_check_uri:
|
479
|
+
|
480
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
481
|
+
break;
|
482
|
+
}
|
483
|
+
|
484
|
+
switch (ch) {
|
485
|
+
case '/':
|
486
|
+
r->uri_ext = NULL;
|
487
|
+
state = sw_after_slash_in_uri;
|
488
|
+
break;
|
489
|
+
case '.':
|
490
|
+
r->uri_ext = p + 1;
|
491
|
+
break;
|
492
|
+
case ' ':
|
493
|
+
r->uri_end = p;
|
494
|
+
state = sw_check_uri_http_09;
|
495
|
+
break;
|
496
|
+
case CR:
|
497
|
+
r->uri_end = p;
|
498
|
+
r->http_minor = 9;
|
499
|
+
state = sw_almost_done;
|
500
|
+
break;
|
501
|
+
case LF:
|
502
|
+
r->uri_end = p;
|
503
|
+
r->http_minor = 9;
|
504
|
+
goto done;
|
505
|
+
#if (NGX_WIN32)
|
506
|
+
case '\\':
|
507
|
+
r->complex_uri = 1;
|
508
|
+
state = sw_after_slash_in_uri;
|
509
|
+
break;
|
510
|
+
#endif
|
511
|
+
case '%':
|
512
|
+
r->quoted_uri = 1;
|
513
|
+
state = sw_uri;
|
514
|
+
break;
|
515
|
+
case '?':
|
516
|
+
r->args_start = p + 1;
|
517
|
+
state = sw_uri;
|
518
|
+
break;
|
519
|
+
case '#':
|
520
|
+
r->complex_uri = 1;
|
521
|
+
state = sw_uri;
|
522
|
+
break;
|
523
|
+
case '+':
|
524
|
+
r->plus_in_uri = 1;
|
525
|
+
break;
|
526
|
+
case '\0':
|
527
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
528
|
+
}
|
529
|
+
break;
|
530
|
+
|
531
|
+
/* space+ after URI */
|
532
|
+
case sw_check_uri_http_09:
|
533
|
+
switch (ch) {
|
534
|
+
case ' ':
|
535
|
+
break;
|
536
|
+
case CR:
|
537
|
+
r->http_minor = 9;
|
538
|
+
state = sw_almost_done;
|
539
|
+
break;
|
540
|
+
case LF:
|
541
|
+
r->http_minor = 9;
|
542
|
+
goto done;
|
543
|
+
case 'H':
|
544
|
+
r->http_protocol.data = p;
|
545
|
+
state = sw_http_H;
|
546
|
+
break;
|
547
|
+
default:
|
548
|
+
r->space_in_uri = 1;
|
549
|
+
state = sw_check_uri;
|
550
|
+
break;
|
551
|
+
}
|
552
|
+
break;
|
553
|
+
|
554
|
+
|
555
|
+
/* URI */
|
556
|
+
case sw_uri:
|
557
|
+
|
558
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
559
|
+
break;
|
560
|
+
}
|
561
|
+
|
562
|
+
switch (ch) {
|
563
|
+
case ' ':
|
564
|
+
r->uri_end = p;
|
565
|
+
state = sw_http_09;
|
566
|
+
break;
|
567
|
+
case CR:
|
568
|
+
r->uri_end = p;
|
569
|
+
r->http_minor = 9;
|
570
|
+
state = sw_almost_done;
|
571
|
+
break;
|
572
|
+
case LF:
|
573
|
+
r->uri_end = p;
|
574
|
+
r->http_minor = 9;
|
575
|
+
goto done;
|
576
|
+
case '#':
|
577
|
+
r->complex_uri = 1;
|
578
|
+
break;
|
579
|
+
case '\0':
|
580
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
581
|
+
}
|
582
|
+
break;
|
583
|
+
|
584
|
+
/* space+ after URI */
|
585
|
+
case sw_http_09:
|
586
|
+
switch (ch) {
|
587
|
+
case ' ':
|
588
|
+
break;
|
589
|
+
case CR:
|
590
|
+
r->http_minor = 9;
|
591
|
+
state = sw_almost_done;
|
592
|
+
break;
|
593
|
+
case LF:
|
594
|
+
r->http_minor = 9;
|
595
|
+
goto done;
|
596
|
+
case 'H':
|
597
|
+
r->http_protocol.data = p;
|
598
|
+
state = sw_http_H;
|
599
|
+
break;
|
600
|
+
default:
|
601
|
+
r->space_in_uri = 1;
|
602
|
+
state = sw_uri;
|
603
|
+
break;
|
604
|
+
}
|
605
|
+
break;
|
606
|
+
|
607
|
+
case sw_http_H:
|
608
|
+
switch (ch) {
|
609
|
+
case 'T':
|
610
|
+
state = sw_http_HT;
|
611
|
+
break;
|
612
|
+
default:
|
613
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
614
|
+
}
|
615
|
+
break;
|
616
|
+
|
617
|
+
case sw_http_HT:
|
618
|
+
switch (ch) {
|
619
|
+
case 'T':
|
620
|
+
state = sw_http_HTT;
|
621
|
+
break;
|
622
|
+
default:
|
623
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
624
|
+
}
|
625
|
+
break;
|
626
|
+
|
627
|
+
case sw_http_HTT:
|
628
|
+
switch (ch) {
|
629
|
+
case 'P':
|
630
|
+
state = sw_http_HTTP;
|
631
|
+
break;
|
632
|
+
default:
|
633
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
634
|
+
}
|
635
|
+
break;
|
636
|
+
|
637
|
+
case sw_http_HTTP:
|
638
|
+
switch (ch) {
|
639
|
+
case '/':
|
640
|
+
state = sw_first_major_digit;
|
641
|
+
break;
|
642
|
+
default:
|
643
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
644
|
+
}
|
645
|
+
break;
|
646
|
+
|
647
|
+
/* first digit of major HTTP version */
|
648
|
+
case sw_first_major_digit:
|
649
|
+
if (ch < '1' || ch > '9') {
|
650
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
651
|
+
}
|
652
|
+
|
653
|
+
r->http_major = ch - '0';
|
654
|
+
state = sw_major_digit;
|
655
|
+
break;
|
656
|
+
|
657
|
+
/* major HTTP version or dot */
|
658
|
+
case sw_major_digit:
|
659
|
+
if (ch == '.') {
|
660
|
+
state = sw_first_minor_digit;
|
661
|
+
break;
|
662
|
+
}
|
663
|
+
|
664
|
+
if (ch < '0' || ch > '9') {
|
665
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
666
|
+
}
|
667
|
+
|
668
|
+
r->http_major = r->http_major * 10 + ch - '0';
|
669
|
+
break;
|
670
|
+
|
671
|
+
/* first digit of minor HTTP version */
|
672
|
+
case sw_first_minor_digit:
|
673
|
+
if (ch < '0' || ch > '9') {
|
674
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
675
|
+
}
|
676
|
+
|
677
|
+
r->http_minor = ch - '0';
|
678
|
+
state = sw_minor_digit;
|
679
|
+
break;
|
680
|
+
|
681
|
+
/* minor HTTP version or end of request line */
|
682
|
+
case sw_minor_digit:
|
683
|
+
if (ch == CR) {
|
684
|
+
state = sw_almost_done;
|
685
|
+
break;
|
686
|
+
}
|
687
|
+
|
688
|
+
if (ch == LF) {
|
689
|
+
goto done;
|
690
|
+
}
|
691
|
+
|
692
|
+
if (ch == ' ') {
|
693
|
+
state = sw_spaces_after_digit;
|
694
|
+
break;
|
695
|
+
}
|
696
|
+
|
697
|
+
if (ch < '0' || ch > '9') {
|
698
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
699
|
+
}
|
700
|
+
|
701
|
+
r->http_minor = r->http_minor * 10 + ch - '0';
|
702
|
+
break;
|
703
|
+
|
704
|
+
case sw_spaces_after_digit:
|
705
|
+
switch (ch) {
|
706
|
+
case ' ':
|
707
|
+
break;
|
708
|
+
case CR:
|
709
|
+
state = sw_almost_done;
|
710
|
+
break;
|
711
|
+
case LF:
|
712
|
+
goto done;
|
713
|
+
default:
|
714
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
715
|
+
}
|
716
|
+
break;
|
717
|
+
|
718
|
+
/* end of request line */
|
719
|
+
case sw_almost_done:
|
720
|
+
r->request_end = p - 1;
|
721
|
+
switch (ch) {
|
722
|
+
case LF:
|
723
|
+
goto done;
|
724
|
+
default:
|
725
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
726
|
+
}
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
b->pos = p;
|
731
|
+
r->state = state;
|
732
|
+
|
733
|
+
return NGX_AGAIN;
|
734
|
+
|
735
|
+
done:
|
736
|
+
|
737
|
+
b->pos = p + 1;
|
738
|
+
|
739
|
+
if (r->request_end == NULL) {
|
740
|
+
r->request_end = p;
|
741
|
+
}
|
742
|
+
|
743
|
+
r->http_version = r->http_major * 1000 + r->http_minor;
|
744
|
+
r->state = sw_start;
|
745
|
+
|
746
|
+
if (r->http_version == 9 && r->method != NGX_HTTP_GET) {
|
747
|
+
return NGX_HTTP_PARSE_INVALID_09_METHOD;
|
748
|
+
}
|
749
|
+
|
750
|
+
return NGX_OK;
|
751
|
+
}
|
752
|
+
|
753
|
+
|
754
|
+
ngx_int_t
|
755
|
+
ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b,
|
756
|
+
ngx_uint_t allow_underscores)
|
757
|
+
{
|
758
|
+
u_char c, ch, *p;
|
759
|
+
ngx_uint_t hash, i;
|
760
|
+
enum {
|
761
|
+
sw_start = 0,
|
762
|
+
sw_name,
|
763
|
+
sw_space_before_value,
|
764
|
+
sw_value,
|
765
|
+
sw_space_after_value,
|
766
|
+
sw_ignore_line,
|
767
|
+
sw_almost_done,
|
768
|
+
sw_header_almost_done
|
769
|
+
} state;
|
770
|
+
|
771
|
+
/* the last '\0' is not needed because string is zero terminated */
|
772
|
+
|
773
|
+
static u_char lowcase[] =
|
774
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
775
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0" "0123456789\0\0\0\0\0\0"
|
776
|
+
"\0abcdefghijklmnopqrstuvwxyz\0\0\0\0\0"
|
777
|
+
"\0abcdefghijklmnopqrstuvwxyz\0\0\0\0\0"
|
778
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
779
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
780
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
781
|
+
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
782
|
+
|
783
|
+
state = r->state;
|
784
|
+
hash = r->header_hash;
|
785
|
+
i = r->lowcase_index;
|
786
|
+
|
787
|
+
for (p = b->pos; p < b->last; p++) {
|
788
|
+
ch = *p;
|
789
|
+
|
790
|
+
switch (state) {
|
791
|
+
|
792
|
+
/* first char */
|
793
|
+
case sw_start:
|
794
|
+
r->header_name_start = p;
|
795
|
+
r->invalid_header = 0;
|
796
|
+
|
797
|
+
switch (ch) {
|
798
|
+
case CR:
|
799
|
+
r->header_end = p;
|
800
|
+
state = sw_header_almost_done;
|
801
|
+
break;
|
802
|
+
case LF:
|
803
|
+
r->header_end = p;
|
804
|
+
goto header_done;
|
805
|
+
default:
|
806
|
+
state = sw_name;
|
807
|
+
|
808
|
+
c = lowcase[ch];
|
809
|
+
|
810
|
+
if (c) {
|
811
|
+
hash = ngx_hash(0, c);
|
812
|
+
r->lowcase_header[0] = c;
|
813
|
+
i = 1;
|
814
|
+
break;
|
815
|
+
}
|
816
|
+
|
817
|
+
if (ch == '\0') {
|
818
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
819
|
+
}
|
820
|
+
|
821
|
+
r->invalid_header = 1;
|
822
|
+
|
823
|
+
break;
|
824
|
+
|
825
|
+
}
|
826
|
+
break;
|
827
|
+
|
828
|
+
/* header name */
|
829
|
+
case sw_name:
|
830
|
+
c = lowcase[ch];
|
831
|
+
|
832
|
+
if (c) {
|
833
|
+
hash = ngx_hash(hash, c);
|
834
|
+
r->lowcase_header[i++] = c;
|
835
|
+
i &= (NGX_HTTP_LC_HEADER_LEN - 1);
|
836
|
+
break;
|
837
|
+
}
|
838
|
+
|
839
|
+
if (ch == '_') {
|
840
|
+
if (allow_underscores) {
|
841
|
+
hash = ngx_hash(hash, ch);
|
842
|
+
r->lowcase_header[i++] = ch;
|
843
|
+
i &= (NGX_HTTP_LC_HEADER_LEN - 1);
|
844
|
+
|
845
|
+
} else {
|
846
|
+
r->invalid_header = 1;
|
847
|
+
}
|
848
|
+
|
849
|
+
break;
|
850
|
+
}
|
851
|
+
|
852
|
+
if (ch == ':') {
|
853
|
+
r->header_name_end = p;
|
854
|
+
state = sw_space_before_value;
|
855
|
+
break;
|
856
|
+
}
|
857
|
+
|
858
|
+
if (ch == CR) {
|
859
|
+
r->header_name_end = p;
|
860
|
+
r->header_start = p;
|
861
|
+
r->header_end = p;
|
862
|
+
state = sw_almost_done;
|
863
|
+
break;
|
864
|
+
}
|
865
|
+
|
866
|
+
if (ch == LF) {
|
867
|
+
r->header_name_end = p;
|
868
|
+
r->header_start = p;
|
869
|
+
r->header_end = p;
|
870
|
+
goto done;
|
871
|
+
}
|
872
|
+
|
873
|
+
/* IIS may send the duplicate "HTTP/1.1 ..." lines */
|
874
|
+
if (ch == '/'
|
875
|
+
&& r->upstream
|
876
|
+
&& p - r->header_name_start == 4
|
877
|
+
&& ngx_strncmp(r->header_name_start, "HTTP", 4) == 0)
|
878
|
+
{
|
879
|
+
state = sw_ignore_line;
|
880
|
+
break;
|
881
|
+
}
|
882
|
+
|
883
|
+
if (ch == '\0') {
|
884
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
885
|
+
}
|
886
|
+
|
887
|
+
r->invalid_header = 1;
|
888
|
+
|
889
|
+
break;
|
890
|
+
|
891
|
+
/* space* before header value */
|
892
|
+
case sw_space_before_value:
|
893
|
+
switch (ch) {
|
894
|
+
case ' ':
|
895
|
+
break;
|
896
|
+
case CR:
|
897
|
+
r->header_start = p;
|
898
|
+
r->header_end = p;
|
899
|
+
state = sw_almost_done;
|
900
|
+
break;
|
901
|
+
case LF:
|
902
|
+
r->header_start = p;
|
903
|
+
r->header_end = p;
|
904
|
+
goto done;
|
905
|
+
case '\0':
|
906
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
907
|
+
default:
|
908
|
+
r->header_start = p;
|
909
|
+
state = sw_value;
|
910
|
+
break;
|
911
|
+
}
|
912
|
+
break;
|
913
|
+
|
914
|
+
/* header value */
|
915
|
+
case sw_value:
|
916
|
+
switch (ch) {
|
917
|
+
case ' ':
|
918
|
+
r->header_end = p;
|
919
|
+
state = sw_space_after_value;
|
920
|
+
break;
|
921
|
+
case CR:
|
922
|
+
r->header_end = p;
|
923
|
+
state = sw_almost_done;
|
924
|
+
break;
|
925
|
+
case LF:
|
926
|
+
r->header_end = p;
|
927
|
+
goto done;
|
928
|
+
case '\0':
|
929
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
930
|
+
}
|
931
|
+
break;
|
932
|
+
|
933
|
+
/* space* before end of header line */
|
934
|
+
case sw_space_after_value:
|
935
|
+
switch (ch) {
|
936
|
+
case ' ':
|
937
|
+
break;
|
938
|
+
case CR:
|
939
|
+
state = sw_almost_done;
|
940
|
+
break;
|
941
|
+
case LF:
|
942
|
+
goto done;
|
943
|
+
case '\0':
|
944
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
945
|
+
default:
|
946
|
+
state = sw_value;
|
947
|
+
break;
|
948
|
+
}
|
949
|
+
break;
|
950
|
+
|
951
|
+
/* ignore header line */
|
952
|
+
case sw_ignore_line:
|
953
|
+
switch (ch) {
|
954
|
+
case LF:
|
955
|
+
state = sw_start;
|
956
|
+
break;
|
957
|
+
default:
|
958
|
+
break;
|
959
|
+
}
|
960
|
+
break;
|
961
|
+
|
962
|
+
/* end of header line */
|
963
|
+
case sw_almost_done:
|
964
|
+
switch (ch) {
|
965
|
+
case LF:
|
966
|
+
goto done;
|
967
|
+
case CR:
|
968
|
+
break;
|
969
|
+
default:
|
970
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
971
|
+
}
|
972
|
+
break;
|
973
|
+
|
974
|
+
/* end of header */
|
975
|
+
case sw_header_almost_done:
|
976
|
+
switch (ch) {
|
977
|
+
case LF:
|
978
|
+
goto header_done;
|
979
|
+
default:
|
980
|
+
return NGX_HTTP_PARSE_INVALID_HEADER;
|
981
|
+
}
|
982
|
+
}
|
983
|
+
}
|
984
|
+
|
985
|
+
b->pos = p;
|
986
|
+
r->state = state;
|
987
|
+
r->header_hash = hash;
|
988
|
+
r->lowcase_index = i;
|
989
|
+
|
990
|
+
return NGX_AGAIN;
|
991
|
+
|
992
|
+
done:
|
993
|
+
|
994
|
+
b->pos = p + 1;
|
995
|
+
r->state = sw_start;
|
996
|
+
r->header_hash = hash;
|
997
|
+
r->lowcase_index = i;
|
998
|
+
|
999
|
+
return NGX_OK;
|
1000
|
+
|
1001
|
+
header_done:
|
1002
|
+
|
1003
|
+
b->pos = p + 1;
|
1004
|
+
r->state = sw_start;
|
1005
|
+
|
1006
|
+
return NGX_HTTP_PARSE_HEADER_DONE;
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
|
1010
|
+
ngx_int_t
|
1011
|
+
ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
|
1012
|
+
{
|
1013
|
+
u_char c, ch, decoded, *p, *u;
|
1014
|
+
enum {
|
1015
|
+
sw_usual = 0,
|
1016
|
+
sw_slash,
|
1017
|
+
sw_dot,
|
1018
|
+
sw_dot_dot,
|
1019
|
+
sw_quoted,
|
1020
|
+
sw_quoted_second
|
1021
|
+
} state, quoted_state;
|
1022
|
+
|
1023
|
+
#if (NGX_SUPPRESS_WARN)
|
1024
|
+
decoded = '\0';
|
1025
|
+
quoted_state = sw_usual;
|
1026
|
+
#endif
|
1027
|
+
|
1028
|
+
state = sw_usual;
|
1029
|
+
p = r->uri_start;
|
1030
|
+
u = r->uri.data;
|
1031
|
+
r->uri_ext = NULL;
|
1032
|
+
r->args_start = NULL;
|
1033
|
+
|
1034
|
+
ch = *p++;
|
1035
|
+
|
1036
|
+
while (p <= r->uri_end) {
|
1037
|
+
|
1038
|
+
/*
|
1039
|
+
* we use "ch = *p++" inside the cycle, but this operation is safe,
|
1040
|
+
* because after the URI there is always at least one charcter:
|
1041
|
+
* the line feed
|
1042
|
+
*/
|
1043
|
+
|
1044
|
+
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
1045
|
+
"s:%d in:'%Xd:%c', out:'%c'", state, ch, ch, *u);
|
1046
|
+
|
1047
|
+
switch (state) {
|
1048
|
+
|
1049
|
+
case sw_usual:
|
1050
|
+
|
1051
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
1052
|
+
*u++ = ch;
|
1053
|
+
ch = *p++;
|
1054
|
+
break;
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
switch(ch) {
|
1058
|
+
#if (NGX_WIN32)
|
1059
|
+
case '\\':
|
1060
|
+
r->uri_ext = NULL;
|
1061
|
+
|
1062
|
+
if (p == r->uri_start + r->uri.len) {
|
1063
|
+
|
1064
|
+
/*
|
1065
|
+
* we omit the last "\" to cause redirect because
|
1066
|
+
* the browsers do not treat "\" as "/" in relative URL path
|
1067
|
+
*/
|
1068
|
+
|
1069
|
+
break;
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
state = sw_slash;
|
1073
|
+
*u++ = '/';
|
1074
|
+
break;
|
1075
|
+
#endif
|
1076
|
+
case '/':
|
1077
|
+
r->uri_ext = NULL;
|
1078
|
+
state = sw_slash;
|
1079
|
+
*u++ = ch;
|
1080
|
+
break;
|
1081
|
+
case '%':
|
1082
|
+
quoted_state = state;
|
1083
|
+
state = sw_quoted;
|
1084
|
+
break;
|
1085
|
+
case '?':
|
1086
|
+
r->args_start = p;
|
1087
|
+
goto args;
|
1088
|
+
case '#':
|
1089
|
+
goto done;
|
1090
|
+
case '.':
|
1091
|
+
r->uri_ext = u + 1;
|
1092
|
+
*u++ = ch;
|
1093
|
+
break;
|
1094
|
+
case '+':
|
1095
|
+
r->plus_in_uri = 1;
|
1096
|
+
default:
|
1097
|
+
*u++ = ch;
|
1098
|
+
break;
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
ch = *p++;
|
1102
|
+
break;
|
1103
|
+
|
1104
|
+
case sw_slash:
|
1105
|
+
|
1106
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
1107
|
+
state = sw_usual;
|
1108
|
+
*u++ = ch;
|
1109
|
+
ch = *p++;
|
1110
|
+
break;
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
switch(ch) {
|
1114
|
+
#if (NGX_WIN32)
|
1115
|
+
case '\\':
|
1116
|
+
break;
|
1117
|
+
#endif
|
1118
|
+
case '/':
|
1119
|
+
if (!merge_slashes) {
|
1120
|
+
*u++ = ch;
|
1121
|
+
}
|
1122
|
+
break;
|
1123
|
+
case '.':
|
1124
|
+
state = sw_dot;
|
1125
|
+
*u++ = ch;
|
1126
|
+
break;
|
1127
|
+
case '%':
|
1128
|
+
quoted_state = state;
|
1129
|
+
state = sw_quoted;
|
1130
|
+
break;
|
1131
|
+
case '?':
|
1132
|
+
r->args_start = p;
|
1133
|
+
goto args;
|
1134
|
+
case '#':
|
1135
|
+
goto done;
|
1136
|
+
case '+':
|
1137
|
+
r->plus_in_uri = 1;
|
1138
|
+
default:
|
1139
|
+
state = sw_usual;
|
1140
|
+
*u++ = ch;
|
1141
|
+
break;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
ch = *p++;
|
1145
|
+
break;
|
1146
|
+
|
1147
|
+
case sw_dot:
|
1148
|
+
|
1149
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
1150
|
+
state = sw_usual;
|
1151
|
+
*u++ = ch;
|
1152
|
+
ch = *p++;
|
1153
|
+
break;
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
switch(ch) {
|
1157
|
+
#if (NGX_WIN32)
|
1158
|
+
case '\\':
|
1159
|
+
#endif
|
1160
|
+
case '/':
|
1161
|
+
state = sw_slash;
|
1162
|
+
u--;
|
1163
|
+
break;
|
1164
|
+
case '.':
|
1165
|
+
state = sw_dot_dot;
|
1166
|
+
*u++ = ch;
|
1167
|
+
break;
|
1168
|
+
case '%':
|
1169
|
+
quoted_state = state;
|
1170
|
+
state = sw_quoted;
|
1171
|
+
break;
|
1172
|
+
case '?':
|
1173
|
+
r->args_start = p;
|
1174
|
+
goto args;
|
1175
|
+
case '#':
|
1176
|
+
goto done;
|
1177
|
+
case '+':
|
1178
|
+
r->plus_in_uri = 1;
|
1179
|
+
default:
|
1180
|
+
state = sw_usual;
|
1181
|
+
*u++ = ch;
|
1182
|
+
break;
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
ch = *p++;
|
1186
|
+
break;
|
1187
|
+
|
1188
|
+
case sw_dot_dot:
|
1189
|
+
|
1190
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
1191
|
+
state = sw_usual;
|
1192
|
+
*u++ = ch;
|
1193
|
+
ch = *p++;
|
1194
|
+
break;
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
switch(ch) {
|
1198
|
+
#if (NGX_WIN32)
|
1199
|
+
case '\\':
|
1200
|
+
#endif
|
1201
|
+
case '/':
|
1202
|
+
state = sw_slash;
|
1203
|
+
u -= 5;
|
1204
|
+
for ( ;; ) {
|
1205
|
+
if (u < r->uri.data) {
|
1206
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
1207
|
+
}
|
1208
|
+
if (*u == '/') {
|
1209
|
+
u++;
|
1210
|
+
break;
|
1211
|
+
}
|
1212
|
+
u--;
|
1213
|
+
}
|
1214
|
+
break;
|
1215
|
+
case '%':
|
1216
|
+
quoted_state = state;
|
1217
|
+
state = sw_quoted;
|
1218
|
+
break;
|
1219
|
+
case '?':
|
1220
|
+
r->args_start = p;
|
1221
|
+
goto args;
|
1222
|
+
case '#':
|
1223
|
+
goto done;
|
1224
|
+
case '+':
|
1225
|
+
r->plus_in_uri = 1;
|
1226
|
+
default:
|
1227
|
+
state = sw_usual;
|
1228
|
+
*u++ = ch;
|
1229
|
+
break;
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
ch = *p++;
|
1233
|
+
break;
|
1234
|
+
|
1235
|
+
case sw_quoted:
|
1236
|
+
r->quoted_uri = 1;
|
1237
|
+
|
1238
|
+
if (ch >= '0' && ch <= '9') {
|
1239
|
+
decoded = (u_char) (ch - '0');
|
1240
|
+
state = sw_quoted_second;
|
1241
|
+
ch = *p++;
|
1242
|
+
break;
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
c = (u_char) (ch | 0x20);
|
1246
|
+
if (c >= 'a' && c <= 'f') {
|
1247
|
+
decoded = (u_char) (c - 'a' + 10);
|
1248
|
+
state = sw_quoted_second;
|
1249
|
+
ch = *p++;
|
1250
|
+
break;
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
1254
|
+
|
1255
|
+
case sw_quoted_second:
|
1256
|
+
if (ch >= '0' && ch <= '9') {
|
1257
|
+
ch = (u_char) ((decoded << 4) + ch - '0');
|
1258
|
+
|
1259
|
+
if (ch == '%' || ch == '#') {
|
1260
|
+
state = sw_usual;
|
1261
|
+
*u++ = ch;
|
1262
|
+
ch = *p++;
|
1263
|
+
break;
|
1264
|
+
|
1265
|
+
} else if (ch == '\0') {
|
1266
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
state = quoted_state;
|
1270
|
+
break;
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
c = (u_char) (ch | 0x20);
|
1274
|
+
if (c >= 'a' && c <= 'f') {
|
1275
|
+
ch = (u_char) ((decoded << 4) + c - 'a' + 10);
|
1276
|
+
|
1277
|
+
if (ch == '?') {
|
1278
|
+
state = sw_usual;
|
1279
|
+
*u++ = ch;
|
1280
|
+
ch = *p++;
|
1281
|
+
break;
|
1282
|
+
|
1283
|
+
} else if (ch == '+') {
|
1284
|
+
r->plus_in_uri = 1;
|
1285
|
+
}
|
1286
|
+
|
1287
|
+
state = quoted_state;
|
1288
|
+
break;
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
return NGX_HTTP_PARSE_INVALID_REQUEST;
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
done:
|
1296
|
+
|
1297
|
+
r->uri.len = u - r->uri.data;
|
1298
|
+
|
1299
|
+
if (r->uri_ext) {
|
1300
|
+
r->exten.len = u - r->uri_ext;
|
1301
|
+
r->exten.data = r->uri_ext;
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
r->uri_ext = NULL;
|
1305
|
+
|
1306
|
+
return NGX_OK;
|
1307
|
+
|
1308
|
+
args:
|
1309
|
+
|
1310
|
+
while (p < r->uri_end) {
|
1311
|
+
if (*p++ != '#') {
|
1312
|
+
continue;
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
r->args.len = p - 1 - r->args_start;
|
1316
|
+
r->args.data = r->args_start;
|
1317
|
+
r->args_start = NULL;
|
1318
|
+
|
1319
|
+
break;
|
1320
|
+
}
|
1321
|
+
|
1322
|
+
r->uri.len = u - r->uri.data;
|
1323
|
+
|
1324
|
+
if (r->uri_ext) {
|
1325
|
+
r->exten.len = u - r->uri_ext;
|
1326
|
+
r->exten.data = r->uri_ext;
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
r->uri_ext = NULL;
|
1330
|
+
|
1331
|
+
return NGX_OK;
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
|
1335
|
+
ngx_int_t
|
1336
|
+
ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b,
|
1337
|
+
ngx_http_status_t *status)
|
1338
|
+
{
|
1339
|
+
u_char ch;
|
1340
|
+
u_char *p;
|
1341
|
+
enum {
|
1342
|
+
sw_start = 0,
|
1343
|
+
sw_H,
|
1344
|
+
sw_HT,
|
1345
|
+
sw_HTT,
|
1346
|
+
sw_HTTP,
|
1347
|
+
sw_first_major_digit,
|
1348
|
+
sw_major_digit,
|
1349
|
+
sw_first_minor_digit,
|
1350
|
+
sw_minor_digit,
|
1351
|
+
sw_status,
|
1352
|
+
sw_space_after_status,
|
1353
|
+
sw_status_text,
|
1354
|
+
sw_almost_done
|
1355
|
+
} state;
|
1356
|
+
|
1357
|
+
state = r->state;
|
1358
|
+
|
1359
|
+
for (p = b->pos; p < b->last; p++) {
|
1360
|
+
ch = *p;
|
1361
|
+
|
1362
|
+
switch (state) {
|
1363
|
+
|
1364
|
+
/* "HTTP/" */
|
1365
|
+
case sw_start:
|
1366
|
+
switch (ch) {
|
1367
|
+
case 'H':
|
1368
|
+
state = sw_H;
|
1369
|
+
break;
|
1370
|
+
default:
|
1371
|
+
return NGX_ERROR;
|
1372
|
+
}
|
1373
|
+
break;
|
1374
|
+
|
1375
|
+
case sw_H:
|
1376
|
+
switch (ch) {
|
1377
|
+
case 'T':
|
1378
|
+
state = sw_HT;
|
1379
|
+
break;
|
1380
|
+
default:
|
1381
|
+
return NGX_ERROR;
|
1382
|
+
}
|
1383
|
+
break;
|
1384
|
+
|
1385
|
+
case sw_HT:
|
1386
|
+
switch (ch) {
|
1387
|
+
case 'T':
|
1388
|
+
state = sw_HTT;
|
1389
|
+
break;
|
1390
|
+
default:
|
1391
|
+
return NGX_ERROR;
|
1392
|
+
}
|
1393
|
+
break;
|
1394
|
+
|
1395
|
+
case sw_HTT:
|
1396
|
+
switch (ch) {
|
1397
|
+
case 'P':
|
1398
|
+
state = sw_HTTP;
|
1399
|
+
break;
|
1400
|
+
default:
|
1401
|
+
return NGX_ERROR;
|
1402
|
+
}
|
1403
|
+
break;
|
1404
|
+
|
1405
|
+
case sw_HTTP:
|
1406
|
+
switch (ch) {
|
1407
|
+
case '/':
|
1408
|
+
state = sw_first_major_digit;
|
1409
|
+
break;
|
1410
|
+
default:
|
1411
|
+
return NGX_ERROR;
|
1412
|
+
}
|
1413
|
+
break;
|
1414
|
+
|
1415
|
+
/* the first digit of major HTTP version */
|
1416
|
+
case sw_first_major_digit:
|
1417
|
+
if (ch < '1' || ch > '9') {
|
1418
|
+
return NGX_ERROR;
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
state = sw_major_digit;
|
1422
|
+
break;
|
1423
|
+
|
1424
|
+
/* the major HTTP version or dot */
|
1425
|
+
case sw_major_digit:
|
1426
|
+
if (ch == '.') {
|
1427
|
+
state = sw_first_minor_digit;
|
1428
|
+
break;
|
1429
|
+
}
|
1430
|
+
|
1431
|
+
if (ch < '0' || ch > '9') {
|
1432
|
+
return NGX_ERROR;
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
break;
|
1436
|
+
|
1437
|
+
/* the first digit of minor HTTP version */
|
1438
|
+
case sw_first_minor_digit:
|
1439
|
+
if (ch < '0' || ch > '9') {
|
1440
|
+
return NGX_ERROR;
|
1441
|
+
}
|
1442
|
+
|
1443
|
+
state = sw_minor_digit;
|
1444
|
+
break;
|
1445
|
+
|
1446
|
+
/* the minor HTTP version or the end of the request line */
|
1447
|
+
case sw_minor_digit:
|
1448
|
+
if (ch == ' ') {
|
1449
|
+
state = sw_status;
|
1450
|
+
break;
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
if (ch < '0' || ch > '9') {
|
1454
|
+
return NGX_ERROR;
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
break;
|
1458
|
+
|
1459
|
+
/* HTTP status code */
|
1460
|
+
case sw_status:
|
1461
|
+
if (ch == ' ') {
|
1462
|
+
break;
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
if (ch < '0' || ch > '9') {
|
1466
|
+
return NGX_ERROR;
|
1467
|
+
}
|
1468
|
+
|
1469
|
+
status->code = status->code * 10 + ch - '0';
|
1470
|
+
|
1471
|
+
if (++status->count == 3) {
|
1472
|
+
state = sw_space_after_status;
|
1473
|
+
status->start = p - 2;
|
1474
|
+
}
|
1475
|
+
|
1476
|
+
break;
|
1477
|
+
|
1478
|
+
/* space or end of line */
|
1479
|
+
case sw_space_after_status:
|
1480
|
+
switch (ch) {
|
1481
|
+
case ' ':
|
1482
|
+
state = sw_status_text;
|
1483
|
+
break;
|
1484
|
+
case '.': /* IIS may send 403.1, 403.2, etc */
|
1485
|
+
state = sw_status_text;
|
1486
|
+
break;
|
1487
|
+
case CR:
|
1488
|
+
state = sw_almost_done;
|
1489
|
+
break;
|
1490
|
+
case LF:
|
1491
|
+
goto done;
|
1492
|
+
default:
|
1493
|
+
return NGX_ERROR;
|
1494
|
+
}
|
1495
|
+
break;
|
1496
|
+
|
1497
|
+
/* any text until end of line */
|
1498
|
+
case sw_status_text:
|
1499
|
+
switch (ch) {
|
1500
|
+
case CR:
|
1501
|
+
state = sw_almost_done;
|
1502
|
+
|
1503
|
+
break;
|
1504
|
+
case LF:
|
1505
|
+
goto done;
|
1506
|
+
}
|
1507
|
+
break;
|
1508
|
+
|
1509
|
+
/* end of status line */
|
1510
|
+
case sw_almost_done:
|
1511
|
+
status->end = p - 1;
|
1512
|
+
switch (ch) {
|
1513
|
+
case LF:
|
1514
|
+
goto done;
|
1515
|
+
default:
|
1516
|
+
return NGX_ERROR;
|
1517
|
+
}
|
1518
|
+
}
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
b->pos = p;
|
1522
|
+
r->state = state;
|
1523
|
+
|
1524
|
+
return NGX_AGAIN;
|
1525
|
+
|
1526
|
+
done:
|
1527
|
+
|
1528
|
+
b->pos = p + 1;
|
1529
|
+
|
1530
|
+
if (status->end == NULL) {
|
1531
|
+
status->end = p;
|
1532
|
+
}
|
1533
|
+
|
1534
|
+
r->state = sw_start;
|
1535
|
+
|
1536
|
+
return NGX_OK;
|
1537
|
+
}
|
1538
|
+
|
1539
|
+
|
1540
|
+
ngx_int_t
|
1541
|
+
ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
|
1542
|
+
ngx_str_t *args, ngx_uint_t *flags)
|
1543
|
+
{
|
1544
|
+
u_char ch, *p;
|
1545
|
+
size_t len;
|
1546
|
+
|
1547
|
+
len = uri->len;
|
1548
|
+
p = uri->data;
|
1549
|
+
|
1550
|
+
if (len == 0 || p[0] == '?') {
|
1551
|
+
goto unsafe;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
if (p[0] == '.' && len == 3 && p[1] == '.' && (ngx_path_separator(p[2]))) {
|
1555
|
+
goto unsafe;
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
for ( /* void */ ; len; len--) {
|
1559
|
+
|
1560
|
+
ch = *p++;
|
1561
|
+
|
1562
|
+
if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
|
1563
|
+
continue;
|
1564
|
+
}
|
1565
|
+
|
1566
|
+
if (ch == '?') {
|
1567
|
+
args->len = len - 1;
|
1568
|
+
args->data = p;
|
1569
|
+
uri->len -= len;
|
1570
|
+
|
1571
|
+
return NGX_OK;
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
if (ch == '\0') {
|
1575
|
+
goto unsafe;
|
1576
|
+
}
|
1577
|
+
|
1578
|
+
if (ngx_path_separator(ch) && len > 2) {
|
1579
|
+
|
1580
|
+
/* detect "/../" */
|
1581
|
+
|
1582
|
+
if (p[0] == '.' && p[1] == '.' && ngx_path_separator(p[2])) {
|
1583
|
+
goto unsafe;
|
1584
|
+
}
|
1585
|
+
}
|
1586
|
+
}
|
1587
|
+
|
1588
|
+
return NGX_OK;
|
1589
|
+
|
1590
|
+
unsafe:
|
1591
|
+
|
1592
|
+
if (*flags & NGX_HTTP_LOG_UNSAFE) {
|
1593
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1594
|
+
"unsafe URI \"%V\" was detected", uri);
|
1595
|
+
}
|
1596
|
+
|
1597
|
+
return NGX_ERROR;
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
|
1601
|
+
ngx_int_t
|
1602
|
+
ngx_http_parse_multi_header_lines(ngx_array_t *headers, ngx_str_t *name,
|
1603
|
+
ngx_str_t *value)
|
1604
|
+
{
|
1605
|
+
ngx_uint_t i;
|
1606
|
+
u_char *start, *last, *end, ch;
|
1607
|
+
ngx_table_elt_t **h;
|
1608
|
+
|
1609
|
+
h = headers->elts;
|
1610
|
+
|
1611
|
+
for (i = 0; i < headers->nelts; i++) {
|
1612
|
+
|
1613
|
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, headers->pool->log, 0,
|
1614
|
+
"parse header: \"%V: %V\"", &h[i]->key, &h[i]->value);
|
1615
|
+
|
1616
|
+
if (name->len > h[i]->value.len) {
|
1617
|
+
continue;
|
1618
|
+
}
|
1619
|
+
|
1620
|
+
start = h[i]->value.data;
|
1621
|
+
end = h[i]->value.data + h[i]->value.len;
|
1622
|
+
|
1623
|
+
while (start < end) {
|
1624
|
+
|
1625
|
+
if (ngx_strncasecmp(start, name->data, name->len) != 0) {
|
1626
|
+
goto skip;
|
1627
|
+
}
|
1628
|
+
|
1629
|
+
for (start += name->len; start < end && *start == ' '; start++) {
|
1630
|
+
/* void */
|
1631
|
+
}
|
1632
|
+
|
1633
|
+
if (value == NULL) {
|
1634
|
+
if (start == end || *start == ',') {
|
1635
|
+
return i;
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
goto skip;
|
1639
|
+
}
|
1640
|
+
|
1641
|
+
if (start == end || *start++ != '=') {
|
1642
|
+
/* the invalid header value */
|
1643
|
+
goto skip;
|
1644
|
+
}
|
1645
|
+
|
1646
|
+
while (start < end && *start == ' ') { start++; }
|
1647
|
+
|
1648
|
+
for (last = start; last < end && *last != ';'; last++) {
|
1649
|
+
/* void */
|
1650
|
+
}
|
1651
|
+
|
1652
|
+
value->len = last - start;
|
1653
|
+
value->data = start;
|
1654
|
+
|
1655
|
+
return i;
|
1656
|
+
|
1657
|
+
skip:
|
1658
|
+
|
1659
|
+
while (start < end) {
|
1660
|
+
ch = *start++;
|
1661
|
+
if (ch == ';' || ch == ',') {
|
1662
|
+
break;
|
1663
|
+
}
|
1664
|
+
}
|
1665
|
+
|
1666
|
+
while (start < end && *start == ' ') { start++; }
|
1667
|
+
}
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
return NGX_DECLINED;
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
|
1674
|
+
ngx_int_t
|
1675
|
+
ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
|
1676
|
+
{
|
1677
|
+
u_char *p, *last;
|
1678
|
+
|
1679
|
+
if (r->args.len == 0) {
|
1680
|
+
return NGX_DECLINED;
|
1681
|
+
}
|
1682
|
+
|
1683
|
+
p = r->args.data;
|
1684
|
+
last = p + r->args.len;
|
1685
|
+
|
1686
|
+
for ( /* void */ ; p < last; p++) {
|
1687
|
+
|
1688
|
+
/* we need '=' after name, so drop one char from last */
|
1689
|
+
|
1690
|
+
p = ngx_strlcasestrn(p, last - 1, name, len - 1);
|
1691
|
+
|
1692
|
+
if (p == NULL) {
|
1693
|
+
return NGX_DECLINED;
|
1694
|
+
}
|
1695
|
+
|
1696
|
+
if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') {
|
1697
|
+
|
1698
|
+
value->data = p + len + 1;
|
1699
|
+
|
1700
|
+
p = ngx_strlchr(p, last, '&');
|
1701
|
+
|
1702
|
+
if (p == NULL) {
|
1703
|
+
p = r->args.data + r->args.len;
|
1704
|
+
}
|
1705
|
+
|
1706
|
+
value->len = p - value->data;
|
1707
|
+
|
1708
|
+
return NGX_OK;
|
1709
|
+
}
|
1710
|
+
}
|
1711
|
+
|
1712
|
+
return NGX_DECLINED;
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
|
1716
|
+
void
|
1717
|
+
ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args)
|
1718
|
+
{
|
1719
|
+
u_char *p, *last;
|
1720
|
+
|
1721
|
+
last = uri->data + uri->len;
|
1722
|
+
|
1723
|
+
p = ngx_strlchr(uri->data, last, '?');
|
1724
|
+
|
1725
|
+
if (p) {
|
1726
|
+
uri->len = p - uri->data;
|
1727
|
+
p++;
|
1728
|
+
args->len = last - p;
|
1729
|
+
args->data = p;
|
1730
|
+
|
1731
|
+
} else {
|
1732
|
+
args->len = 0;
|
1733
|
+
}
|
1734
|
+
}
|