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,242 @@
|
|
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
|
+
typedef struct {
|
14
|
+
ngx_chain_t *free;
|
15
|
+
ngx_chain_t *busy;
|
16
|
+
} ngx_http_chunked_filter_ctx_t;
|
17
|
+
|
18
|
+
|
19
|
+
static ngx_int_t ngx_http_chunked_filter_init(ngx_conf_t *cf);
|
20
|
+
|
21
|
+
|
22
|
+
static ngx_http_module_t ngx_http_chunked_filter_module_ctx = {
|
23
|
+
NULL, /* preconfiguration */
|
24
|
+
ngx_http_chunked_filter_init, /* postconfiguration */
|
25
|
+
|
26
|
+
NULL, /* create main configuration */
|
27
|
+
NULL, /* init main configuration */
|
28
|
+
|
29
|
+
NULL, /* create server configuration */
|
30
|
+
NULL, /* merge server configuration */
|
31
|
+
|
32
|
+
NULL, /* create location configuration */
|
33
|
+
NULL /* merge location configuration */
|
34
|
+
};
|
35
|
+
|
36
|
+
|
37
|
+
ngx_module_t ngx_http_chunked_filter_module = {
|
38
|
+
NGX_MODULE_V1,
|
39
|
+
&ngx_http_chunked_filter_module_ctx, /* module context */
|
40
|
+
NULL, /* module directives */
|
41
|
+
NGX_HTTP_MODULE, /* module type */
|
42
|
+
NULL, /* init master */
|
43
|
+
NULL, /* init module */
|
44
|
+
NULL, /* init process */
|
45
|
+
NULL, /* init thread */
|
46
|
+
NULL, /* exit thread */
|
47
|
+
NULL, /* exit process */
|
48
|
+
NULL, /* exit master */
|
49
|
+
NGX_MODULE_V1_PADDING
|
50
|
+
};
|
51
|
+
|
52
|
+
|
53
|
+
static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
|
54
|
+
static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
|
55
|
+
|
56
|
+
|
57
|
+
static ngx_int_t
|
58
|
+
ngx_http_chunked_header_filter(ngx_http_request_t *r)
|
59
|
+
{
|
60
|
+
ngx_http_core_loc_conf_t *clcf;
|
61
|
+
ngx_http_chunked_filter_ctx_t *ctx;
|
62
|
+
|
63
|
+
if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED
|
64
|
+
|| r->headers_out.status == NGX_HTTP_NO_CONTENT
|
65
|
+
|| r != r->main
|
66
|
+
|| (r->method & NGX_HTTP_HEAD))
|
67
|
+
{
|
68
|
+
return ngx_http_next_header_filter(r);
|
69
|
+
}
|
70
|
+
|
71
|
+
if (r->headers_out.content_length_n == -1) {
|
72
|
+
if (r->http_version < NGX_HTTP_VERSION_11) {
|
73
|
+
r->keepalive = 0;
|
74
|
+
|
75
|
+
} else {
|
76
|
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
77
|
+
|
78
|
+
if (clcf->chunked_transfer_encoding) {
|
79
|
+
r->chunked = 1;
|
80
|
+
|
81
|
+
ctx = ngx_pcalloc(r->pool,
|
82
|
+
sizeof(ngx_http_chunked_filter_ctx_t));
|
83
|
+
if (ctx == NULL) {
|
84
|
+
return NGX_ERROR;
|
85
|
+
}
|
86
|
+
|
87
|
+
ngx_http_set_ctx(r, ctx, ngx_http_chunked_filter_module);
|
88
|
+
|
89
|
+
} else {
|
90
|
+
r->keepalive = 0;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
return ngx_http_next_header_filter(r);
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
static ngx_int_t
|
100
|
+
ngx_http_chunked_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
101
|
+
{
|
102
|
+
u_char *chunk;
|
103
|
+
off_t size;
|
104
|
+
ngx_int_t rc;
|
105
|
+
ngx_buf_t *b;
|
106
|
+
ngx_chain_t *out, *cl, *tl, **ll;
|
107
|
+
ngx_http_chunked_filter_ctx_t *ctx;
|
108
|
+
|
109
|
+
if (in == NULL || !r->chunked || r->header_only) {
|
110
|
+
return ngx_http_next_body_filter(r, in);
|
111
|
+
}
|
112
|
+
|
113
|
+
ctx = ngx_http_get_module_ctx(r, ngx_http_chunked_filter_module);
|
114
|
+
|
115
|
+
out = NULL;
|
116
|
+
ll = &out;
|
117
|
+
|
118
|
+
size = 0;
|
119
|
+
cl = in;
|
120
|
+
|
121
|
+
for ( ;; ) {
|
122
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
123
|
+
"http chunk: %d", ngx_buf_size(cl->buf));
|
124
|
+
|
125
|
+
size += ngx_buf_size(cl->buf);
|
126
|
+
|
127
|
+
if (cl->buf->flush
|
128
|
+
|| cl->buf->sync
|
129
|
+
|| ngx_buf_in_memory(cl->buf)
|
130
|
+
|| cl->buf->in_file)
|
131
|
+
{
|
132
|
+
tl = ngx_alloc_chain_link(r->pool);
|
133
|
+
if (tl == NULL) {
|
134
|
+
return NGX_ERROR;
|
135
|
+
}
|
136
|
+
|
137
|
+
tl->buf = cl->buf;
|
138
|
+
*ll = tl;
|
139
|
+
ll = &tl->next;
|
140
|
+
}
|
141
|
+
|
142
|
+
if (cl->next == NULL) {
|
143
|
+
break;
|
144
|
+
}
|
145
|
+
|
146
|
+
cl = cl->next;
|
147
|
+
}
|
148
|
+
|
149
|
+
if (size) {
|
150
|
+
tl = ngx_chain_get_free_buf(r->pool, &ctx->free);
|
151
|
+
if (tl == NULL) {
|
152
|
+
return NGX_ERROR;
|
153
|
+
}
|
154
|
+
|
155
|
+
b = tl->buf;
|
156
|
+
chunk = b->start;
|
157
|
+
|
158
|
+
if (chunk == NULL) {
|
159
|
+
/* the "0000000000000000" is 64-bit hexadecimal string */
|
160
|
+
|
161
|
+
chunk = ngx_palloc(r->pool, sizeof("0000000000000000" CRLF) - 1);
|
162
|
+
if (chunk == NULL) {
|
163
|
+
return NGX_ERROR;
|
164
|
+
}
|
165
|
+
|
166
|
+
b->start = chunk;
|
167
|
+
b->end = chunk + sizeof("0000000000000000" CRLF) - 1;
|
168
|
+
}
|
169
|
+
|
170
|
+
b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module;
|
171
|
+
b->memory = 0;
|
172
|
+
b->temporary = 1;
|
173
|
+
b->pos = chunk;
|
174
|
+
b->last = ngx_sprintf(chunk, "%xO" CRLF, size);
|
175
|
+
|
176
|
+
tl->next = out;
|
177
|
+
out = tl;
|
178
|
+
}
|
179
|
+
|
180
|
+
if (cl->buf->last_buf) {
|
181
|
+
tl = ngx_chain_get_free_buf(r->pool, &ctx->free);
|
182
|
+
if (tl == NULL) {
|
183
|
+
return NGX_ERROR;
|
184
|
+
}
|
185
|
+
|
186
|
+
b = tl->buf;
|
187
|
+
|
188
|
+
b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module;
|
189
|
+
b->temporary = 0;
|
190
|
+
b->memory = 1;
|
191
|
+
b->last_buf = 1;
|
192
|
+
b->pos = (u_char *) CRLF "0" CRLF CRLF;
|
193
|
+
b->last = b->pos + 7;
|
194
|
+
|
195
|
+
cl->buf->last_buf = 0;
|
196
|
+
|
197
|
+
*ll = tl;
|
198
|
+
|
199
|
+
if (size == 0) {
|
200
|
+
b->pos += 2;
|
201
|
+
}
|
202
|
+
|
203
|
+
} else if (size > 0) {
|
204
|
+
tl = ngx_chain_get_free_buf(r->pool, &ctx->free);
|
205
|
+
if (tl == NULL) {
|
206
|
+
return NGX_ERROR;
|
207
|
+
}
|
208
|
+
|
209
|
+
b = tl->buf;
|
210
|
+
|
211
|
+
b->tag = (ngx_buf_tag_t) &ngx_http_chunked_filter_module;
|
212
|
+
b->temporary = 0;
|
213
|
+
b->memory = 1;
|
214
|
+
b->pos = (u_char *) CRLF;
|
215
|
+
b->last = b->pos + 2;
|
216
|
+
|
217
|
+
*ll = tl;
|
218
|
+
|
219
|
+
} else {
|
220
|
+
*ll = NULL;
|
221
|
+
}
|
222
|
+
|
223
|
+
rc = ngx_http_next_body_filter(r, out);
|
224
|
+
|
225
|
+
ngx_chain_update_chains(&ctx->free, &ctx->busy, &out,
|
226
|
+
(ngx_buf_tag_t) &ngx_http_chunked_filter_module);
|
227
|
+
|
228
|
+
return rc;
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
static ngx_int_t
|
233
|
+
ngx_http_chunked_filter_init(ngx_conf_t *cf)
|
234
|
+
{
|
235
|
+
ngx_http_next_header_filter = ngx_http_top_header_filter;
|
236
|
+
ngx_http_top_header_filter = ngx_http_chunked_header_filter;
|
237
|
+
|
238
|
+
ngx_http_next_body_filter = ngx_http_top_body_filter;
|
239
|
+
ngx_http_top_body_filter = ngx_http_chunked_body_filter;
|
240
|
+
|
241
|
+
return NGX_OK;
|
242
|
+
}
|
@@ -0,0 +1,1141 @@
|
|
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
|
+
#define NGX_HTTP_DAV_COPY_BLOCK 65536
|
14
|
+
|
15
|
+
#define NGX_HTTP_DAV_OFF 2
|
16
|
+
|
17
|
+
|
18
|
+
#define NGX_HTTP_DAV_NO_DEPTH -3
|
19
|
+
#define NGX_HTTP_DAV_INVALID_DEPTH -2
|
20
|
+
#define NGX_HTTP_DAV_INFINITY_DEPTH -1
|
21
|
+
|
22
|
+
|
23
|
+
typedef struct {
|
24
|
+
ngx_uint_t methods;
|
25
|
+
ngx_uint_t access;
|
26
|
+
ngx_uint_t min_delete_depth;
|
27
|
+
ngx_flag_t create_full_put_path;
|
28
|
+
} ngx_http_dav_loc_conf_t;
|
29
|
+
|
30
|
+
|
31
|
+
typedef struct {
|
32
|
+
ngx_str_t path;
|
33
|
+
size_t len;
|
34
|
+
} ngx_http_dav_copy_ctx_t;
|
35
|
+
|
36
|
+
|
37
|
+
static ngx_int_t ngx_http_dav_handler(ngx_http_request_t *r);
|
38
|
+
|
39
|
+
static void ngx_http_dav_put_handler(ngx_http_request_t *r);
|
40
|
+
|
41
|
+
static ngx_int_t ngx_http_dav_delete_handler(ngx_http_request_t *r);
|
42
|
+
static ngx_int_t ngx_http_dav_delete_path(ngx_http_request_t *r,
|
43
|
+
ngx_str_t *path, ngx_uint_t dir);
|
44
|
+
static ngx_int_t ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
|
45
|
+
static ngx_int_t ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path);
|
46
|
+
static ngx_int_t ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path);
|
47
|
+
|
48
|
+
static ngx_int_t ngx_http_dav_mkcol_handler(ngx_http_request_t *r,
|
49
|
+
ngx_http_dav_loc_conf_t *dlcf);
|
50
|
+
|
51
|
+
static ngx_int_t ngx_http_dav_copy_move_handler(ngx_http_request_t *r);
|
52
|
+
static ngx_int_t ngx_http_dav_copy_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path);
|
53
|
+
static ngx_int_t ngx_http_dav_copy_dir_time(ngx_tree_ctx_t *ctx,
|
54
|
+
ngx_str_t *path);
|
55
|
+
static ngx_int_t ngx_http_dav_copy_tree_file(ngx_tree_ctx_t *ctx,
|
56
|
+
ngx_str_t *path);
|
57
|
+
|
58
|
+
static ngx_int_t ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt);
|
59
|
+
static ngx_int_t ngx_http_dav_error(ngx_log_t *log, ngx_err_t err,
|
60
|
+
ngx_int_t not_found, char *failed, u_char *path);
|
61
|
+
static ngx_int_t ngx_http_dav_location(ngx_http_request_t *r, u_char *path);
|
62
|
+
static void *ngx_http_dav_create_loc_conf(ngx_conf_t *cf);
|
63
|
+
static char *ngx_http_dav_merge_loc_conf(ngx_conf_t *cf,
|
64
|
+
void *parent, void *child);
|
65
|
+
static ngx_int_t ngx_http_dav_init(ngx_conf_t *cf);
|
66
|
+
|
67
|
+
|
68
|
+
static ngx_conf_bitmask_t ngx_http_dav_methods_mask[] = {
|
69
|
+
{ ngx_string("off"), NGX_HTTP_DAV_OFF },
|
70
|
+
{ ngx_string("put"), NGX_HTTP_PUT },
|
71
|
+
{ ngx_string("delete"), NGX_HTTP_DELETE },
|
72
|
+
{ ngx_string("mkcol"), NGX_HTTP_MKCOL },
|
73
|
+
{ ngx_string("copy"), NGX_HTTP_COPY },
|
74
|
+
{ ngx_string("move"), NGX_HTTP_MOVE },
|
75
|
+
{ ngx_null_string, 0 }
|
76
|
+
};
|
77
|
+
|
78
|
+
|
79
|
+
static ngx_command_t ngx_http_dav_commands[] = {
|
80
|
+
|
81
|
+
{ ngx_string("dav_methods"),
|
82
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
83
|
+
ngx_conf_set_bitmask_slot,
|
84
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
85
|
+
offsetof(ngx_http_dav_loc_conf_t, methods),
|
86
|
+
&ngx_http_dav_methods_mask },
|
87
|
+
|
88
|
+
{ ngx_string("create_full_put_path"),
|
89
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
90
|
+
ngx_conf_set_flag_slot,
|
91
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
92
|
+
offsetof(ngx_http_dav_loc_conf_t, create_full_put_path),
|
93
|
+
NULL },
|
94
|
+
|
95
|
+
{ ngx_string("min_delete_depth"),
|
96
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
97
|
+
ngx_conf_set_num_slot,
|
98
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
99
|
+
offsetof(ngx_http_dav_loc_conf_t, min_delete_depth),
|
100
|
+
NULL },
|
101
|
+
|
102
|
+
{ ngx_string("dav_access"),
|
103
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
|
104
|
+
ngx_conf_set_access_slot,
|
105
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
106
|
+
offsetof(ngx_http_dav_loc_conf_t, access),
|
107
|
+
NULL },
|
108
|
+
|
109
|
+
ngx_null_command
|
110
|
+
};
|
111
|
+
|
112
|
+
|
113
|
+
static ngx_http_module_t ngx_http_dav_module_ctx = {
|
114
|
+
NULL, /* preconfiguration */
|
115
|
+
ngx_http_dav_init, /* postconfiguration */
|
116
|
+
|
117
|
+
NULL, /* create main configuration */
|
118
|
+
NULL, /* init main configuration */
|
119
|
+
|
120
|
+
NULL, /* create server configuration */
|
121
|
+
NULL, /* merge server configuration */
|
122
|
+
|
123
|
+
ngx_http_dav_create_loc_conf, /* create location configuration */
|
124
|
+
ngx_http_dav_merge_loc_conf /* merge location configuration */
|
125
|
+
};
|
126
|
+
|
127
|
+
|
128
|
+
ngx_module_t ngx_http_dav_module = {
|
129
|
+
NGX_MODULE_V1,
|
130
|
+
&ngx_http_dav_module_ctx, /* module context */
|
131
|
+
ngx_http_dav_commands, /* module directives */
|
132
|
+
NGX_HTTP_MODULE, /* module type */
|
133
|
+
NULL, /* init master */
|
134
|
+
NULL, /* init module */
|
135
|
+
NULL, /* init process */
|
136
|
+
NULL, /* init thread */
|
137
|
+
NULL, /* exit thread */
|
138
|
+
NULL, /* exit process */
|
139
|
+
NULL, /* exit master */
|
140
|
+
NGX_MODULE_V1_PADDING
|
141
|
+
};
|
142
|
+
|
143
|
+
|
144
|
+
static ngx_int_t
|
145
|
+
ngx_http_dav_handler(ngx_http_request_t *r)
|
146
|
+
{
|
147
|
+
ngx_int_t rc;
|
148
|
+
ngx_http_dav_loc_conf_t *dlcf;
|
149
|
+
|
150
|
+
dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
|
151
|
+
|
152
|
+
if (!(r->method & dlcf->methods)) {
|
153
|
+
return NGX_DECLINED;
|
154
|
+
}
|
155
|
+
|
156
|
+
switch (r->method) {
|
157
|
+
|
158
|
+
case NGX_HTTP_PUT:
|
159
|
+
|
160
|
+
if (r->uri.data[r->uri.len - 1] == '/') {
|
161
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
162
|
+
"cannot PUT to a collection");
|
163
|
+
return NGX_HTTP_CONFLICT;
|
164
|
+
}
|
165
|
+
|
166
|
+
r->request_body_in_file_only = 1;
|
167
|
+
r->request_body_in_persistent_file = 1;
|
168
|
+
r->request_body_in_clean_file = 1;
|
169
|
+
r->request_body_file_group_access = 1;
|
170
|
+
r->request_body_file_log_level = 0;
|
171
|
+
|
172
|
+
rc = ngx_http_read_client_request_body(r, ngx_http_dav_put_handler);
|
173
|
+
|
174
|
+
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
|
175
|
+
return rc;
|
176
|
+
}
|
177
|
+
|
178
|
+
return NGX_DONE;
|
179
|
+
|
180
|
+
case NGX_HTTP_DELETE:
|
181
|
+
|
182
|
+
return ngx_http_dav_delete_handler(r);
|
183
|
+
|
184
|
+
case NGX_HTTP_MKCOL:
|
185
|
+
|
186
|
+
return ngx_http_dav_mkcol_handler(r, dlcf);
|
187
|
+
|
188
|
+
case NGX_HTTP_COPY:
|
189
|
+
|
190
|
+
return ngx_http_dav_copy_move_handler(r);
|
191
|
+
|
192
|
+
case NGX_HTTP_MOVE:
|
193
|
+
|
194
|
+
return ngx_http_dav_copy_move_handler(r);
|
195
|
+
}
|
196
|
+
|
197
|
+
return NGX_DECLINED;
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
static void
|
202
|
+
ngx_http_dav_put_handler(ngx_http_request_t *r)
|
203
|
+
{
|
204
|
+
size_t root;
|
205
|
+
time_t date;
|
206
|
+
ngx_str_t *temp, path;
|
207
|
+
ngx_uint_t status;
|
208
|
+
ngx_file_info_t fi;
|
209
|
+
ngx_ext_rename_file_t ext;
|
210
|
+
ngx_http_dav_loc_conf_t *dlcf;
|
211
|
+
|
212
|
+
ngx_http_map_uri_to_path(r, &path, &root, 0);
|
213
|
+
|
214
|
+
path.len--;
|
215
|
+
|
216
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
217
|
+
"http put filename: \"%s\"", path.data);
|
218
|
+
|
219
|
+
temp = &r->request_body->temp_file->file.name;
|
220
|
+
|
221
|
+
if (ngx_file_info(path.data, &fi) == NGX_FILE_ERROR) {
|
222
|
+
status = NGX_HTTP_CREATED;
|
223
|
+
|
224
|
+
} else {
|
225
|
+
status = NGX_HTTP_NO_CONTENT;
|
226
|
+
|
227
|
+
if (ngx_is_dir(&fi)) {
|
228
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR,
|
229
|
+
"\"%s\" could not be created", path.data);
|
230
|
+
|
231
|
+
if (ngx_delete_file(temp->data) == NGX_FILE_ERROR) {
|
232
|
+
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
233
|
+
ngx_delete_file_n " \"%s\" failed",
|
234
|
+
temp->data);
|
235
|
+
}
|
236
|
+
|
237
|
+
ngx_http_finalize_request(r, NGX_HTTP_CONFLICT);
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
|
243
|
+
|
244
|
+
ext.access = dlcf->access;
|
245
|
+
ext.path_access = dlcf->access;
|
246
|
+
ext.time = -1;
|
247
|
+
ext.create_path = dlcf->create_full_put_path;
|
248
|
+
ext.delete_file = 1;
|
249
|
+
ext.log = r->connection->log;
|
250
|
+
|
251
|
+
if (r->headers_in.date) {
|
252
|
+
date = ngx_http_parse_time(r->headers_in.date->value.data,
|
253
|
+
r->headers_in.date->value.len);
|
254
|
+
|
255
|
+
if (date != NGX_ERROR) {
|
256
|
+
ext.time = date;
|
257
|
+
ext.fd = r->request_body->temp_file->file.fd;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
if (ngx_ext_rename_file(temp, &path, &ext) != NGX_OK) {
|
262
|
+
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
263
|
+
return;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (status == NGX_HTTP_CREATED) {
|
267
|
+
if (ngx_http_dav_location(r, path.data) != NGX_OK) {
|
268
|
+
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
269
|
+
return;
|
270
|
+
}
|
271
|
+
|
272
|
+
r->headers_out.content_length_n = 0;
|
273
|
+
}
|
274
|
+
|
275
|
+
r->headers_out.status = status;
|
276
|
+
r->header_only = 1;
|
277
|
+
|
278
|
+
ngx_http_finalize_request(r, ngx_http_send_header(r));
|
279
|
+
return;
|
280
|
+
}
|
281
|
+
|
282
|
+
|
283
|
+
static ngx_int_t
|
284
|
+
ngx_http_dav_delete_handler(ngx_http_request_t *r)
|
285
|
+
{
|
286
|
+
size_t root;
|
287
|
+
ngx_err_t err;
|
288
|
+
ngx_int_t rc, depth;
|
289
|
+
ngx_uint_t i, d, dir;
|
290
|
+
ngx_str_t path;
|
291
|
+
ngx_file_info_t fi;
|
292
|
+
ngx_http_dav_loc_conf_t *dlcf;
|
293
|
+
|
294
|
+
if (r->headers_in.content_length_n > 0) {
|
295
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
296
|
+
"DELETE with body is unsupported");
|
297
|
+
return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE;
|
298
|
+
}
|
299
|
+
|
300
|
+
dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
|
301
|
+
|
302
|
+
if (dlcf->min_delete_depth) {
|
303
|
+
d = 0;
|
304
|
+
|
305
|
+
for (i = 0; i < r->uri.len; /* void */) {
|
306
|
+
if (r->uri.data[i++] == '/') {
|
307
|
+
if (++d >= dlcf->min_delete_depth && i < r->uri.len) {
|
308
|
+
goto ok;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
314
|
+
"insufficient URI depth:%i to DELETE", d);
|
315
|
+
return NGX_HTTP_CONFLICT;
|
316
|
+
}
|
317
|
+
|
318
|
+
ok:
|
319
|
+
|
320
|
+
ngx_http_map_uri_to_path(r, &path, &root, 0);
|
321
|
+
|
322
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
323
|
+
"http delete filename: \"%s\"", path.data);
|
324
|
+
|
325
|
+
if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
|
326
|
+
err = ngx_errno;
|
327
|
+
|
328
|
+
rc = (err == NGX_ENOTDIR) ? NGX_HTTP_CONFLICT : NGX_HTTP_NOT_FOUND;
|
329
|
+
|
330
|
+
return ngx_http_dav_error(r->connection->log, err,
|
331
|
+
rc, ngx_link_info_n, path.data);
|
332
|
+
}
|
333
|
+
|
334
|
+
if (ngx_is_dir(&fi)) {
|
335
|
+
|
336
|
+
if (r->uri.data[r->uri.len - 1] != '/') {
|
337
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EISDIR,
|
338
|
+
"DELETE \"%s\" failed", path.data);
|
339
|
+
return NGX_HTTP_CONFLICT;
|
340
|
+
}
|
341
|
+
|
342
|
+
depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH);
|
343
|
+
|
344
|
+
if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
345
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
346
|
+
"\"Depth\" header must be infinity");
|
347
|
+
return NGX_HTTP_BAD_REQUEST;
|
348
|
+
}
|
349
|
+
|
350
|
+
path.len -= 2; /* omit "/\0" */
|
351
|
+
|
352
|
+
dir = 1;
|
353
|
+
|
354
|
+
} else {
|
355
|
+
|
356
|
+
/*
|
357
|
+
* we do not need to test (r->uri.data[r->uri.len - 1] == '/')
|
358
|
+
* because ngx_link_info("/file/") returned NGX_ENOTDIR above
|
359
|
+
*/
|
360
|
+
|
361
|
+
depth = ngx_http_dav_depth(r, 0);
|
362
|
+
|
363
|
+
if (depth != 0 && depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
364
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
365
|
+
"\"Depth\" header must be 0 or infinity");
|
366
|
+
return NGX_HTTP_BAD_REQUEST;
|
367
|
+
}
|
368
|
+
|
369
|
+
dir = 0;
|
370
|
+
}
|
371
|
+
|
372
|
+
rc = ngx_http_dav_delete_path(r, &path, dir);
|
373
|
+
|
374
|
+
if (rc == NGX_OK) {
|
375
|
+
return NGX_HTTP_NO_CONTENT;
|
376
|
+
}
|
377
|
+
|
378
|
+
return rc;
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
static ngx_int_t
|
383
|
+
ngx_http_dav_delete_path(ngx_http_request_t *r, ngx_str_t *path, ngx_uint_t dir)
|
384
|
+
{
|
385
|
+
char *failed;
|
386
|
+
ngx_tree_ctx_t tree;
|
387
|
+
|
388
|
+
if (dir) {
|
389
|
+
|
390
|
+
tree.init_handler = NULL;
|
391
|
+
tree.file_handler = ngx_http_dav_delete_file;
|
392
|
+
tree.pre_tree_handler = ngx_http_dav_noop;
|
393
|
+
tree.post_tree_handler = ngx_http_dav_delete_dir;
|
394
|
+
tree.spec_handler = ngx_http_dav_delete_file;
|
395
|
+
tree.data = NULL;
|
396
|
+
tree.alloc = 0;
|
397
|
+
tree.log = r->connection->log;
|
398
|
+
|
399
|
+
/* TODO: 207 */
|
400
|
+
|
401
|
+
if (ngx_walk_tree(&tree, path) != NGX_OK) {
|
402
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
403
|
+
}
|
404
|
+
|
405
|
+
if (ngx_delete_dir(path->data) != NGX_FILE_ERROR) {
|
406
|
+
return NGX_OK;
|
407
|
+
}
|
408
|
+
|
409
|
+
failed = ngx_delete_dir_n;
|
410
|
+
|
411
|
+
} else {
|
412
|
+
|
413
|
+
if (ngx_delete_file(path->data) != NGX_FILE_ERROR) {
|
414
|
+
return NGX_OK;
|
415
|
+
}
|
416
|
+
|
417
|
+
failed = ngx_delete_file_n;
|
418
|
+
}
|
419
|
+
|
420
|
+
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
421
|
+
NGX_HTTP_NOT_FOUND, failed, path->data);
|
422
|
+
}
|
423
|
+
|
424
|
+
|
425
|
+
static ngx_int_t
|
426
|
+
ngx_http_dav_delete_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path)
|
427
|
+
{
|
428
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
429
|
+
"http delete dir: \"%s\"", path->data);
|
430
|
+
|
431
|
+
if (ngx_delete_dir(path->data) == NGX_FILE_ERROR) {
|
432
|
+
|
433
|
+
/* TODO: add to 207 */
|
434
|
+
|
435
|
+
(void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_delete_dir_n,
|
436
|
+
path->data);
|
437
|
+
}
|
438
|
+
|
439
|
+
return NGX_OK;
|
440
|
+
}
|
441
|
+
|
442
|
+
|
443
|
+
static ngx_int_t
|
444
|
+
ngx_http_dav_delete_file(ngx_tree_ctx_t *ctx, ngx_str_t *path)
|
445
|
+
{
|
446
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
447
|
+
"http delete file: \"%s\"", path->data);
|
448
|
+
|
449
|
+
if (ngx_delete_file(path->data) == NGX_FILE_ERROR) {
|
450
|
+
|
451
|
+
/* TODO: add to 207 */
|
452
|
+
|
453
|
+
(void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_delete_file_n,
|
454
|
+
path->data);
|
455
|
+
}
|
456
|
+
|
457
|
+
return NGX_OK;
|
458
|
+
}
|
459
|
+
|
460
|
+
|
461
|
+
static ngx_int_t
|
462
|
+
ngx_http_dav_noop(ngx_tree_ctx_t *ctx, ngx_str_t *path)
|
463
|
+
{
|
464
|
+
return NGX_OK;
|
465
|
+
}
|
466
|
+
|
467
|
+
|
468
|
+
static ngx_int_t
|
469
|
+
ngx_http_dav_mkcol_handler(ngx_http_request_t *r, ngx_http_dav_loc_conf_t *dlcf)
|
470
|
+
{
|
471
|
+
u_char *p;
|
472
|
+
size_t root;
|
473
|
+
ngx_str_t path;
|
474
|
+
|
475
|
+
if (r->headers_in.content_length_n > 0) {
|
476
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
477
|
+
"MKCOL with body is unsupported");
|
478
|
+
return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE;
|
479
|
+
}
|
480
|
+
|
481
|
+
if (r->uri.data[r->uri.len - 1] != '/') {
|
482
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
483
|
+
"MKCOL can create a collection only");
|
484
|
+
return NGX_HTTP_CONFLICT;
|
485
|
+
}
|
486
|
+
|
487
|
+
p = ngx_http_map_uri_to_path(r, &path, &root, 0);
|
488
|
+
|
489
|
+
*(p - 1) = '\0';
|
490
|
+
r->uri.len--;
|
491
|
+
|
492
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
493
|
+
"http mkcol path: \"%s\"", path.data);
|
494
|
+
|
495
|
+
if (ngx_create_dir(path.data, ngx_dir_access(dlcf->access))
|
496
|
+
!= NGX_FILE_ERROR)
|
497
|
+
{
|
498
|
+
if (ngx_http_dav_location(r, path.data) != NGX_OK) {
|
499
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
500
|
+
}
|
501
|
+
|
502
|
+
return NGX_HTTP_CREATED;
|
503
|
+
}
|
504
|
+
|
505
|
+
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
506
|
+
NGX_HTTP_CONFLICT, ngx_create_dir_n, path.data);
|
507
|
+
}
|
508
|
+
|
509
|
+
|
510
|
+
static ngx_int_t
|
511
|
+
ngx_http_dav_copy_move_handler(ngx_http_request_t *r)
|
512
|
+
{
|
513
|
+
u_char *p, *host, *last, ch;
|
514
|
+
size_t len, root;
|
515
|
+
ngx_err_t err;
|
516
|
+
ngx_int_t rc, depth;
|
517
|
+
ngx_uint_t overwrite, slash, dir, flags;
|
518
|
+
ngx_str_t path, uri, duri, args;
|
519
|
+
ngx_tree_ctx_t tree;
|
520
|
+
ngx_copy_file_t cf;
|
521
|
+
ngx_file_info_t fi;
|
522
|
+
ngx_table_elt_t *dest, *over;
|
523
|
+
ngx_ext_rename_file_t ext;
|
524
|
+
ngx_http_dav_copy_ctx_t copy;
|
525
|
+
ngx_http_dav_loc_conf_t *dlcf;
|
526
|
+
|
527
|
+
if (r->headers_in.content_length_n > 0) {
|
528
|
+
return NGX_HTTP_UNSUPPORTED_MEDIA_TYPE;
|
529
|
+
}
|
530
|
+
|
531
|
+
dest = r->headers_in.destination;
|
532
|
+
|
533
|
+
if (dest == NULL) {
|
534
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
535
|
+
"client sent no \"Destination\" header");
|
536
|
+
return NGX_HTTP_BAD_REQUEST;
|
537
|
+
}
|
538
|
+
|
539
|
+
p = dest->value.data;
|
540
|
+
/* there is always '\0' even after empty header value */
|
541
|
+
if (p[0] == '/') {
|
542
|
+
last = p + dest->value.len;
|
543
|
+
goto destination_done;
|
544
|
+
}
|
545
|
+
|
546
|
+
len = r->headers_in.server.len;
|
547
|
+
|
548
|
+
if (len == 0) {
|
549
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
550
|
+
"client sent no \"Host\" header");
|
551
|
+
return NGX_HTTP_BAD_REQUEST;
|
552
|
+
}
|
553
|
+
|
554
|
+
#if (NGX_HTTP_SSL)
|
555
|
+
|
556
|
+
if (r->connection->ssl) {
|
557
|
+
if (ngx_strncmp(dest->value.data, "https://", sizeof("https://") - 1)
|
558
|
+
!= 0)
|
559
|
+
{
|
560
|
+
goto invalid_destination;
|
561
|
+
}
|
562
|
+
|
563
|
+
host = dest->value.data + sizeof("https://") - 1;
|
564
|
+
|
565
|
+
} else
|
566
|
+
#endif
|
567
|
+
{
|
568
|
+
if (ngx_strncmp(dest->value.data, "http://", sizeof("http://") - 1)
|
569
|
+
!= 0)
|
570
|
+
{
|
571
|
+
goto invalid_destination;
|
572
|
+
}
|
573
|
+
|
574
|
+
host = dest->value.data + sizeof("http://") - 1;
|
575
|
+
}
|
576
|
+
|
577
|
+
if (ngx_strncmp(host, r->headers_in.server.data, len) != 0) {
|
578
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
579
|
+
"\"Destination\" URI \"%V\" is handled by "
|
580
|
+
"different repository than the source URI",
|
581
|
+
&dest->value);
|
582
|
+
return NGX_HTTP_BAD_REQUEST;
|
583
|
+
}
|
584
|
+
|
585
|
+
last = dest->value.data + dest->value.len;
|
586
|
+
|
587
|
+
for (p = host + len; p < last; p++) {
|
588
|
+
if (*p == '/') {
|
589
|
+
goto destination_done;
|
590
|
+
}
|
591
|
+
}
|
592
|
+
|
593
|
+
invalid_destination:
|
594
|
+
|
595
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
596
|
+
"client sent invalid \"Destination\" header: \"%V\"",
|
597
|
+
&dest->value);
|
598
|
+
return NGX_HTTP_BAD_REQUEST;
|
599
|
+
|
600
|
+
destination_done:
|
601
|
+
|
602
|
+
duri.len = last - p;
|
603
|
+
duri.data = p;
|
604
|
+
flags = 0;
|
605
|
+
|
606
|
+
if (ngx_http_parse_unsafe_uri(r, &duri, &args, &flags) != NGX_OK) {
|
607
|
+
goto invalid_destination;
|
608
|
+
}
|
609
|
+
|
610
|
+
if ((r->uri.data[r->uri.len - 1] == '/' && *(last - 1) != '/')
|
611
|
+
|| (r->uri.data[r->uri.len - 1] != '/' && *(last - 1) == '/'))
|
612
|
+
{
|
613
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
614
|
+
"both URI \"%V\" and \"Destination\" URI \"%V\" "
|
615
|
+
"should be either collections or non-collections",
|
616
|
+
&r->uri, &dest->value);
|
617
|
+
return NGX_HTTP_CONFLICT;
|
618
|
+
}
|
619
|
+
|
620
|
+
depth = ngx_http_dav_depth(r, NGX_HTTP_DAV_INFINITY_DEPTH);
|
621
|
+
|
622
|
+
if (depth != NGX_HTTP_DAV_INFINITY_DEPTH) {
|
623
|
+
|
624
|
+
if (r->method == NGX_HTTP_COPY) {
|
625
|
+
if (depth != 0) {
|
626
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
627
|
+
"\"Depth\" header must be 0 or infinity");
|
628
|
+
return NGX_HTTP_BAD_REQUEST;
|
629
|
+
}
|
630
|
+
|
631
|
+
} else {
|
632
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
633
|
+
"\"Depth\" header must be infinity");
|
634
|
+
return NGX_HTTP_BAD_REQUEST;
|
635
|
+
}
|
636
|
+
}
|
637
|
+
|
638
|
+
over = r->headers_in.overwrite;
|
639
|
+
|
640
|
+
if (over) {
|
641
|
+
if (over->value.len == 1) {
|
642
|
+
ch = over->value.data[0];
|
643
|
+
|
644
|
+
if (ch == 'T' || ch == 't') {
|
645
|
+
overwrite = 1;
|
646
|
+
goto overwrite_done;
|
647
|
+
}
|
648
|
+
|
649
|
+
if (ch == 'F' || ch == 'f') {
|
650
|
+
overwrite = 0;
|
651
|
+
goto overwrite_done;
|
652
|
+
}
|
653
|
+
|
654
|
+
}
|
655
|
+
|
656
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
657
|
+
"client sent invalid \"Overwrite\" header: \"%V\"",
|
658
|
+
&over->value);
|
659
|
+
return NGX_HTTP_BAD_REQUEST;
|
660
|
+
}
|
661
|
+
|
662
|
+
overwrite = 1;
|
663
|
+
|
664
|
+
overwrite_done:
|
665
|
+
|
666
|
+
ngx_http_map_uri_to_path(r, &path, &root, 0);
|
667
|
+
|
668
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
669
|
+
"http copy from: \"%s\"", path.data);
|
670
|
+
|
671
|
+
uri = r->uri;
|
672
|
+
r->uri = duri;
|
673
|
+
|
674
|
+
ngx_http_map_uri_to_path(r, ©.path, &root, 0);
|
675
|
+
|
676
|
+
r->uri = uri;
|
677
|
+
|
678
|
+
copy.path.len--; /* omit "\0" */
|
679
|
+
|
680
|
+
if (copy.path.data[copy.path.len - 1] == '/') {
|
681
|
+
slash = 1;
|
682
|
+
copy.path.len--;
|
683
|
+
copy.path.data[copy.path.len] = '\0';
|
684
|
+
|
685
|
+
} else {
|
686
|
+
slash = 0;
|
687
|
+
}
|
688
|
+
|
689
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
690
|
+
"http copy to: \"%s\"", copy.path.data);
|
691
|
+
|
692
|
+
if (ngx_link_info(copy.path.data, &fi) == NGX_FILE_ERROR) {
|
693
|
+
err = ngx_errno;
|
694
|
+
|
695
|
+
if (err != NGX_ENOENT) {
|
696
|
+
return ngx_http_dav_error(r->connection->log, err,
|
697
|
+
NGX_HTTP_NOT_FOUND, ngx_link_info_n,
|
698
|
+
copy.path.data);
|
699
|
+
}
|
700
|
+
|
701
|
+
/* destination does not exist */
|
702
|
+
|
703
|
+
overwrite = 0;
|
704
|
+
dir = 0;
|
705
|
+
|
706
|
+
} else {
|
707
|
+
|
708
|
+
/* destination exists */
|
709
|
+
|
710
|
+
if (ngx_is_dir(&fi) && !slash) {
|
711
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
712
|
+
"\"%V\" could not be %Ved to collection \"%V\"",
|
713
|
+
&r->uri, &r->method_name, &dest->value);
|
714
|
+
return NGX_HTTP_CONFLICT;
|
715
|
+
}
|
716
|
+
|
717
|
+
if (!overwrite) {
|
718
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_EEXIST,
|
719
|
+
"\"%s\" could not be created", copy.path.data);
|
720
|
+
return NGX_HTTP_PRECONDITION_FAILED;
|
721
|
+
}
|
722
|
+
|
723
|
+
dir = ngx_is_dir(&fi);
|
724
|
+
}
|
725
|
+
|
726
|
+
if (ngx_link_info(path.data, &fi) == NGX_FILE_ERROR) {
|
727
|
+
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
728
|
+
NGX_HTTP_NOT_FOUND, ngx_link_info_n,
|
729
|
+
path.data);
|
730
|
+
}
|
731
|
+
|
732
|
+
if (ngx_is_dir(&fi)) {
|
733
|
+
|
734
|
+
if (r->uri.data[r->uri.len - 1] != '/') {
|
735
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
736
|
+
"\"%V\" is collection", &r->uri);
|
737
|
+
return NGX_HTTP_BAD_REQUEST;
|
738
|
+
}
|
739
|
+
|
740
|
+
if (overwrite) {
|
741
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
742
|
+
"http delete: \"%s\"", copy.path.data);
|
743
|
+
|
744
|
+
rc = ngx_http_dav_delete_path(r, ©.path, dir);
|
745
|
+
|
746
|
+
if (rc != NGX_OK) {
|
747
|
+
return rc;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
}
|
751
|
+
|
752
|
+
if (ngx_is_dir(&fi)) {
|
753
|
+
|
754
|
+
path.len -= 2; /* omit "/\0" */
|
755
|
+
|
756
|
+
if (r->method == NGX_HTTP_MOVE) {
|
757
|
+
if (ngx_rename_file(path.data, copy.path.data) != NGX_FILE_ERROR) {
|
758
|
+
return NGX_HTTP_CREATED;
|
759
|
+
}
|
760
|
+
}
|
761
|
+
|
762
|
+
if (ngx_create_dir(copy.path.data, ngx_file_access(&fi))
|
763
|
+
== NGX_FILE_ERROR)
|
764
|
+
{
|
765
|
+
return ngx_http_dav_error(r->connection->log, ngx_errno,
|
766
|
+
NGX_HTTP_NOT_FOUND,
|
767
|
+
ngx_create_dir_n, copy.path.data);
|
768
|
+
}
|
769
|
+
|
770
|
+
copy.len = path.len;
|
771
|
+
|
772
|
+
tree.init_handler = NULL;
|
773
|
+
tree.file_handler = ngx_http_dav_copy_tree_file;
|
774
|
+
tree.pre_tree_handler = ngx_http_dav_copy_dir;
|
775
|
+
tree.post_tree_handler = ngx_http_dav_copy_dir_time;
|
776
|
+
tree.spec_handler = ngx_http_dav_noop;
|
777
|
+
tree.data = ©
|
778
|
+
tree.alloc = 0;
|
779
|
+
tree.log = r->connection->log;
|
780
|
+
|
781
|
+
if (ngx_walk_tree(&tree, &path) == NGX_OK) {
|
782
|
+
|
783
|
+
if (r->method == NGX_HTTP_MOVE) {
|
784
|
+
rc = ngx_http_dav_delete_path(r, &path, 1);
|
785
|
+
|
786
|
+
if (rc != NGX_OK) {
|
787
|
+
return rc;
|
788
|
+
}
|
789
|
+
}
|
790
|
+
|
791
|
+
return NGX_HTTP_CREATED;
|
792
|
+
}
|
793
|
+
|
794
|
+
} else {
|
795
|
+
|
796
|
+
if (r->method == NGX_HTTP_MOVE) {
|
797
|
+
|
798
|
+
dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
|
799
|
+
|
800
|
+
ext.access = 0;
|
801
|
+
ext.path_access = dlcf->access;
|
802
|
+
ext.time = -1;
|
803
|
+
ext.create_path = 1;
|
804
|
+
ext.delete_file = 0;
|
805
|
+
ext.log = r->connection->log;
|
806
|
+
|
807
|
+
if (ngx_ext_rename_file(&path, ©.path, &ext) == NGX_OK) {
|
808
|
+
return NGX_HTTP_NO_CONTENT;
|
809
|
+
}
|
810
|
+
|
811
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
812
|
+
}
|
813
|
+
|
814
|
+
dlcf = ngx_http_get_module_loc_conf(r, ngx_http_dav_module);
|
815
|
+
|
816
|
+
cf.size = ngx_file_size(&fi);
|
817
|
+
cf.buf_size = 0;
|
818
|
+
cf.access = dlcf->access;
|
819
|
+
cf.time = ngx_file_mtime(&fi);
|
820
|
+
cf.log = r->connection->log;
|
821
|
+
|
822
|
+
if (ngx_copy_file(path.data, copy.path.data, &cf) == NGX_OK) {
|
823
|
+
return NGX_HTTP_NO_CONTENT;
|
824
|
+
}
|
825
|
+
}
|
826
|
+
|
827
|
+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
828
|
+
}
|
829
|
+
|
830
|
+
|
831
|
+
static ngx_int_t
|
832
|
+
ngx_http_dav_copy_dir(ngx_tree_ctx_t *ctx, ngx_str_t *path)
|
833
|
+
{
|
834
|
+
u_char *p, *dir;
|
835
|
+
size_t len;
|
836
|
+
ngx_http_dav_copy_ctx_t *copy;
|
837
|
+
|
838
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
839
|
+
"http copy dir: \"%s\"", path->data);
|
840
|
+
|
841
|
+
copy = ctx->data;
|
842
|
+
|
843
|
+
len = copy->path.len + path->len;
|
844
|
+
|
845
|
+
dir = ngx_alloc(len + 1, ctx->log);
|
846
|
+
if (dir == NULL) {
|
847
|
+
return NGX_ABORT;
|
848
|
+
}
|
849
|
+
|
850
|
+
p = ngx_cpymem(dir, copy->path.data, copy->path.len);
|
851
|
+
(void) ngx_cpystrn(p, path->data + copy->len, path->len - copy->len + 1);
|
852
|
+
|
853
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
854
|
+
"http copy dir to: \"%s\"", dir);
|
855
|
+
|
856
|
+
if (ngx_create_dir(dir, ngx_dir_access(ctx->access)) == NGX_FILE_ERROR) {
|
857
|
+
(void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_create_dir_n,
|
858
|
+
dir);
|
859
|
+
}
|
860
|
+
|
861
|
+
ngx_free(dir);
|
862
|
+
|
863
|
+
return NGX_OK;
|
864
|
+
}
|
865
|
+
|
866
|
+
|
867
|
+
static ngx_int_t
|
868
|
+
ngx_http_dav_copy_dir_time(ngx_tree_ctx_t *ctx, ngx_str_t *path)
|
869
|
+
{
|
870
|
+
u_char *p, *dir;
|
871
|
+
size_t len;
|
872
|
+
ngx_http_dav_copy_ctx_t *copy;
|
873
|
+
|
874
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
875
|
+
"http copy dir time: \"%s\"", path->data);
|
876
|
+
|
877
|
+
copy = ctx->data;
|
878
|
+
|
879
|
+
len = copy->path.len + path->len;
|
880
|
+
|
881
|
+
dir = ngx_alloc(len + 1, ctx->log);
|
882
|
+
if (dir == NULL) {
|
883
|
+
return NGX_ABORT;
|
884
|
+
}
|
885
|
+
|
886
|
+
p = ngx_cpymem(dir, copy->path.data, copy->path.len);
|
887
|
+
(void) ngx_cpystrn(p, path->data + copy->len, path->len - copy->len + 1);
|
888
|
+
|
889
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
890
|
+
"http copy dir time to: \"%s\"", dir);
|
891
|
+
|
892
|
+
#if (NGX_WIN32)
|
893
|
+
{
|
894
|
+
ngx_fd_t fd;
|
895
|
+
|
896
|
+
fd = ngx_open_file(dir, NGX_FILE_RDWR, NGX_FILE_OPEN, 0);
|
897
|
+
|
898
|
+
if (fd == NGX_INVALID_FILE) {
|
899
|
+
(void) ngx_http_dav_error(ctx->log, ngx_errno, 0, ngx_open_file_n, dir);
|
900
|
+
goto failed;
|
901
|
+
}
|
902
|
+
|
903
|
+
if (ngx_set_file_time(NULL, fd, ctx->mtime) != NGX_OK) {
|
904
|
+
ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno,
|
905
|
+
ngx_set_file_time_n " \"%s\" failed", dir);
|
906
|
+
}
|
907
|
+
|
908
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
909
|
+
ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno,
|
910
|
+
ngx_close_file_n " \"%s\" failed", dir);
|
911
|
+
}
|
912
|
+
}
|
913
|
+
|
914
|
+
failed:
|
915
|
+
|
916
|
+
#else
|
917
|
+
|
918
|
+
if (ngx_set_file_time(dir, 0, ctx->mtime) != NGX_OK) {
|
919
|
+
ngx_log_error(NGX_LOG_ALERT, ctx->log, ngx_errno,
|
920
|
+
ngx_set_file_time_n " \"%s\" failed", dir);
|
921
|
+
}
|
922
|
+
|
923
|
+
#endif
|
924
|
+
|
925
|
+
ngx_free(dir);
|
926
|
+
|
927
|
+
return NGX_OK;
|
928
|
+
}
|
929
|
+
|
930
|
+
|
931
|
+
static ngx_int_t
|
932
|
+
ngx_http_dav_copy_tree_file(ngx_tree_ctx_t *ctx, ngx_str_t *path)
|
933
|
+
{
|
934
|
+
u_char *p, *file;
|
935
|
+
size_t len;
|
936
|
+
ngx_copy_file_t cf;
|
937
|
+
ngx_http_dav_copy_ctx_t *copy;
|
938
|
+
|
939
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
940
|
+
"http copy file: \"%s\"", path->data);
|
941
|
+
|
942
|
+
copy = ctx->data;
|
943
|
+
|
944
|
+
len = copy->path.len + path->len;
|
945
|
+
|
946
|
+
file = ngx_alloc(len + 1, ctx->log);
|
947
|
+
if (file == NULL) {
|
948
|
+
return NGX_ABORT;
|
949
|
+
}
|
950
|
+
|
951
|
+
p = ngx_cpymem(file, copy->path.data, copy->path.len);
|
952
|
+
(void) ngx_cpystrn(p, path->data + copy->len, path->len - copy->len + 1);
|
953
|
+
|
954
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ctx->log, 0,
|
955
|
+
"http copy file to: \"%s\"", file);
|
956
|
+
|
957
|
+
cf.size = ctx->size;
|
958
|
+
cf.buf_size = 0;
|
959
|
+
cf.access = ctx->access;
|
960
|
+
cf.time = ctx->mtime;
|
961
|
+
cf.log = ctx->log;
|
962
|
+
|
963
|
+
(void) ngx_copy_file(path->data, file, &cf);
|
964
|
+
|
965
|
+
ngx_free(file);
|
966
|
+
|
967
|
+
return NGX_OK;
|
968
|
+
}
|
969
|
+
|
970
|
+
|
971
|
+
static ngx_int_t
|
972
|
+
ngx_http_dav_depth(ngx_http_request_t *r, ngx_int_t dflt)
|
973
|
+
{
|
974
|
+
ngx_table_elt_t *depth;
|
975
|
+
|
976
|
+
depth = r->headers_in.depth;
|
977
|
+
|
978
|
+
if (depth == NULL) {
|
979
|
+
return dflt;
|
980
|
+
}
|
981
|
+
|
982
|
+
if (depth->value.len == 1) {
|
983
|
+
|
984
|
+
if (depth->value.data[0] == '0') {
|
985
|
+
return 0;
|
986
|
+
}
|
987
|
+
|
988
|
+
if (depth->value.data[0] == '1') {
|
989
|
+
return 1;
|
990
|
+
}
|
991
|
+
|
992
|
+
} else {
|
993
|
+
|
994
|
+
if (depth->value.len == sizeof("infinity") - 1
|
995
|
+
&& ngx_strcmp(depth->value.data, "infinity") == 0)
|
996
|
+
{
|
997
|
+
return NGX_HTTP_DAV_INFINITY_DEPTH;
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
|
1001
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
1002
|
+
"client sent invalid \"Depth\" header: \"%V\"",
|
1003
|
+
&depth->value);
|
1004
|
+
|
1005
|
+
return NGX_HTTP_DAV_INVALID_DEPTH;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
|
1009
|
+
static ngx_int_t
|
1010
|
+
ngx_http_dav_error(ngx_log_t *log, ngx_err_t err, ngx_int_t not_found,
|
1011
|
+
char *failed, u_char *path)
|
1012
|
+
{
|
1013
|
+
ngx_int_t rc;
|
1014
|
+
ngx_uint_t level;
|
1015
|
+
|
1016
|
+
if (err == NGX_ENOENT || err == NGX_ENOTDIR || err == NGX_ENAMETOOLONG) {
|
1017
|
+
level = NGX_LOG_ERR;
|
1018
|
+
rc = not_found;
|
1019
|
+
|
1020
|
+
} else if (err == NGX_EACCES || err == NGX_EPERM) {
|
1021
|
+
level = NGX_LOG_ERR;
|
1022
|
+
rc = NGX_HTTP_FORBIDDEN;
|
1023
|
+
|
1024
|
+
} else if (err == NGX_EEXIST) {
|
1025
|
+
level = NGX_LOG_ERR;
|
1026
|
+
rc = NGX_HTTP_NOT_ALLOWED;
|
1027
|
+
|
1028
|
+
} else if (err == NGX_ENOSPC) {
|
1029
|
+
level = NGX_LOG_CRIT;
|
1030
|
+
rc = NGX_HTTP_INSUFFICIENT_STORAGE;
|
1031
|
+
|
1032
|
+
} else {
|
1033
|
+
level = NGX_LOG_CRIT;
|
1034
|
+
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
ngx_log_error(level, log, err, "%s \"%s\" failed", failed, path);
|
1038
|
+
|
1039
|
+
return rc;
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
|
1043
|
+
static ngx_int_t
|
1044
|
+
ngx_http_dav_location(ngx_http_request_t *r, u_char *path)
|
1045
|
+
{
|
1046
|
+
u_char *location;
|
1047
|
+
ngx_http_core_loc_conf_t *clcf;
|
1048
|
+
|
1049
|
+
r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
|
1050
|
+
if (r->headers_out.location == NULL) {
|
1051
|
+
return NGX_ERROR;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
1055
|
+
|
1056
|
+
if (!clcf->alias && clcf->root_lengths == NULL) {
|
1057
|
+
location = path + clcf->root.len;
|
1058
|
+
|
1059
|
+
} else {
|
1060
|
+
location = ngx_pnalloc(r->pool, r->uri.len);
|
1061
|
+
if (location == NULL) {
|
1062
|
+
return NGX_ERROR;
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
ngx_memcpy(location, r->uri.data, r->uri.len);
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
/*
|
1069
|
+
* we do not need to set the r->headers_out.location->hash and
|
1070
|
+
* r->headers_out.location->key fields
|
1071
|
+
*/
|
1072
|
+
|
1073
|
+
r->headers_out.location->value.len = r->uri.len;
|
1074
|
+
r->headers_out.location->value.data = location;
|
1075
|
+
|
1076
|
+
return NGX_OK;
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
|
1080
|
+
static void *
|
1081
|
+
ngx_http_dav_create_loc_conf(ngx_conf_t *cf)
|
1082
|
+
{
|
1083
|
+
ngx_http_dav_loc_conf_t *conf;
|
1084
|
+
|
1085
|
+
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_dav_loc_conf_t));
|
1086
|
+
if (conf == NULL) {
|
1087
|
+
return NULL;
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
/*
|
1091
|
+
* set by ngx_pcalloc():
|
1092
|
+
*
|
1093
|
+
* conf->methods = 0;
|
1094
|
+
*/
|
1095
|
+
|
1096
|
+
conf->min_delete_depth = NGX_CONF_UNSET_UINT;
|
1097
|
+
conf->access = NGX_CONF_UNSET_UINT;
|
1098
|
+
conf->create_full_put_path = NGX_CONF_UNSET;
|
1099
|
+
|
1100
|
+
return conf;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
|
1104
|
+
static char *
|
1105
|
+
ngx_http_dav_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
1106
|
+
{
|
1107
|
+
ngx_http_dav_loc_conf_t *prev = parent;
|
1108
|
+
ngx_http_dav_loc_conf_t *conf = child;
|
1109
|
+
|
1110
|
+
ngx_conf_merge_bitmask_value(conf->methods, prev->methods,
|
1111
|
+
(NGX_CONF_BITMASK_SET|NGX_HTTP_DAV_OFF));
|
1112
|
+
|
1113
|
+
ngx_conf_merge_uint_value(conf->min_delete_depth,
|
1114
|
+
prev->min_delete_depth, 0);
|
1115
|
+
|
1116
|
+
ngx_conf_merge_uint_value(conf->access, prev->access, 0600);
|
1117
|
+
|
1118
|
+
ngx_conf_merge_value(conf->create_full_put_path,
|
1119
|
+
prev->create_full_put_path, 0);
|
1120
|
+
|
1121
|
+
return NGX_CONF_OK;
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
|
1125
|
+
static ngx_int_t
|
1126
|
+
ngx_http_dav_init(ngx_conf_t *cf)
|
1127
|
+
{
|
1128
|
+
ngx_http_handler_pt *h;
|
1129
|
+
ngx_http_core_main_conf_t *cmcf;
|
1130
|
+
|
1131
|
+
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
1132
|
+
|
1133
|
+
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
1134
|
+
if (h == NULL) {
|
1135
|
+
return NGX_ERROR;
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
*h = ngx_http_dav_handler;
|
1139
|
+
|
1140
|
+
return NGX_OK;
|
1141
|
+
}
|