passenger 4.0.59 → 4.0.60

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (579) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +15 -0
  5. data/bin/passenger-install-apache2-module +2 -1
  6. data/bin/passenger-install-nginx-module +8 -2
  7. data/ext/apache2/Hooks.cpp +21 -2
  8. data/ext/apache2/MergeDirConfig.cpp +40 -40
  9. data/ext/common/ApplicationPool2/Group.h +14 -10
  10. data/ext/common/ApplicationPool2/Implementation.cpp +13 -7
  11. data/ext/common/ApplicationPool2/SmartSpawner.h +4 -1
  12. data/ext/common/Constants.h +1 -1
  13. data/ext/nginx/ContentHandler.c +17 -1
  14. data/lib/phusion_passenger.rb +4 -5
  15. data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +4 -3
  16. data/lib/phusion_passenger/platform_info/openssl.rb +61 -0
  17. data/lib/phusion_passenger/standalone/runtime_installer.rb +27 -22
  18. data/packaging/debian/LICENSE.md +19 -0
  19. data/packaging/debian/README.md +320 -0
  20. data/packaging/debian/Vagrantfile +25 -0
  21. data/packaging/debian/build +210 -0
  22. data/packaging/debian/debian_specs/nginx/changelog +1989 -0
  23. data/packaging/debian/debian_specs/nginx/compat.erb +5 -0
  24. data/packaging/debian/debian_specs/nginx/conf/fastcgi.conf +25 -0
  25. data/packaging/debian/debian_specs/nginx/conf/fastcgi_params +24 -0
  26. data/packaging/debian/debian_specs/nginx/conf/koi-utf +109 -0
  27. data/packaging/debian/debian_specs/nginx/conf/koi-win +103 -0
  28. data/packaging/debian/debian_specs/nginx/conf/mime.types +89 -0
  29. data/packaging/debian/debian_specs/nginx/conf/nginx.conf.erb +97 -0
  30. data/packaging/debian/debian_specs/nginx/conf/proxy_params +4 -0
  31. data/packaging/debian/debian_specs/nginx/conf/scgi_params +16 -0
  32. data/packaging/debian/debian_specs/nginx/conf/sites-available/default.erb +93 -0
  33. data/packaging/debian/debian_specs/nginx/conf/snippets/fastcgi-php.conf +13 -0
  34. data/packaging/debian/debian_specs/nginx/conf/snippets/snakeoil.conf +5 -0
  35. data/packaging/debian/debian_specs/nginx/conf/uwsgi_params +16 -0
  36. data/packaging/debian/debian_specs/nginx/conf/win-utf +125 -0
  37. data/packaging/debian/debian_specs/nginx/control.erb +226 -0
  38. data/packaging/debian/debian_specs/nginx/copyright +196 -0
  39. data/packaging/debian/debian_specs/nginx/debian-full.lintian-overrides +1 -0
  40. data/packaging/debian/debian_specs/nginx/gbp.conf +2 -0
  41. data/packaging/debian/debian_specs/nginx/help/docs/fcgiwrap +14 -0
  42. data/packaging/debian/debian_specs/nginx/help/docs/php +119 -0
  43. data/packaging/debian/debian_specs/nginx/help/docs/support-irc +28 -0
  44. data/packaging/debian/debian_specs/nginx/help/docs/upstream +51 -0
  45. data/packaging/debian/debian_specs/nginx/help/examples/drupal +114 -0
  46. data/packaging/debian/debian_specs/nginx/help/examples/http +59 -0
  47. data/packaging/debian/debian_specs/nginx/help/examples/mail +30 -0
  48. data/packaging/debian/debian_specs/nginx/help/examples/mailman +59 -0
  49. data/packaging/debian/debian_specs/nginx/help/examples/nginx.conf +34 -0
  50. data/packaging/debian/debian_specs/nginx/help/examples/nginx_modsite +162 -0
  51. data/packaging/debian/debian_specs/nginx/help/examples/virtual_hosts +155 -0
  52. data/packaging/debian/debian_specs/nginx/help/examples/wordpress +74 -0
  53. data/packaging/debian/debian_specs/nginx/helpers.rb +41 -0
  54. data/packaging/debian/debian_specs/nginx/index-debian.html.in +32 -0
  55. data/packaging/debian/debian_specs/nginx/index-ubuntu.html.in +32 -0
  56. data/packaging/debian/debian_specs/nginx/index.html.erb +10 -0
  57. data/packaging/debian/debian_specs/nginx/modules/README.Modules-versions +65 -0
  58. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/README.markdown +510 -0
  59. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/config +5 -0
  60. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/doc/HttpHeadersMoreModule.wiki +395 -0
  61. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ddebug.h +119 -0
  62. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.c +348 -0
  63. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_filter_module.h +80 -0
  64. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.c +826 -0
  65. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_in.h +26 -0
  66. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.c +716 -0
  67. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_headers_out.h +26 -0
  68. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.c +380 -0
  69. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/src/ngx_http_headers_more_util.h +52 -0
  70. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/util/build.sh +32 -0
  71. data/packaging/debian/debian_specs/nginx/modules/headers-more-nginx-module/valgrind.suppress +215 -0
  72. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ChangeLog +35 -0
  73. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/LICENSE +25 -0
  74. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/README.md +93 -0
  75. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/config +4 -0
  76. data/packaging/debian/debian_specs/nginx/modules/nginx-auth-pam/ngx_http_auth_pam_module.c +462 -0
  77. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/CHANGES +66 -0
  78. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/LICENSE +26 -0
  79. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/README.md +171 -0
  80. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/TODO.md +7 -0
  81. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/config +21 -0
  82. data/packaging/debian/debian_specs/nginx/modules/nginx-cache-purge/ngx_cache_purge_module.c +1803 -0
  83. data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/README +29 -0
  84. data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/config +9 -0
  85. data/packaging/debian/debian_specs/nginx/modules/nginx-dav-ext-module/ngx_http_dav_ext_module.c +824 -0
  86. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README +139 -0
  87. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/README_AUTO_LIB +395 -0
  88. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/TODO +1 -0
  89. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/array +10 -0
  90. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/actions/palloc +8 -0
  91. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/build +597 -0
  92. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_replacements +5 -0
  93. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/action_types +12 -0
  94. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_args +22 -0
  95. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_locs +25 -0
  96. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/conf_macros +35 -0
  97. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/contexts +22 -0
  98. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/header_files +3 -0
  99. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/headers +4 -0
  100. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/module_dependencies +5 -0
  101. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/modules_optional +15 -0
  102. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/data/prefixes +2 -0
  103. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/array.h +7 -0
  104. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_cmd_basic.h +43 -0
  105. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/conf_merge.h +78 -0
  106. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/src/palloc.h +6 -0
  107. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/auto/text/autogen +12 -0
  108. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/config +49 -0
  109. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/action_macros +63 -0
  110. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/core/conf_cmds +62 -0
  111. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/modules/set_var +124 -0
  112. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/patches/more_logging_info +48 -0
  113. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/docs/upstream/list +45 -0
  114. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/README +12 -0
  115. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/config +4 -0
  116. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/examples/http/set_var/ngx_http_set_var_examples_module.c +136 -0
  117. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/ngx_auto_lib_core +797 -0
  118. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/CHANGES +17 -0
  119. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/notes/LICENSE +24 -0
  120. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_array.h +113 -0
  121. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_basic.h +2203 -0
  122. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_cmd_extra.h +5423 -0
  123. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_conf_merge.h +227 -0
  124. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.c +72 -0
  125. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_config.h +98 -0
  126. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_includes.h +66 -0
  127. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/objs/ndk_palloc.h +112 -0
  128. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/auto_config +16 -0
  129. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/expose_rewrite_functions +291 -0
  130. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/patches/rewrite_phase_handler +19 -0
  131. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/md5.h +117 -0
  132. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/murmurhash2.c +77 -0
  133. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/hash/sha.h +200 -0
  134. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.c +155 -0
  135. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk.h +58 -0
  136. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.c +43 -0
  137. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_buf.h +5 -0
  138. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.c +129 -0
  139. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_path.h +30 -0
  140. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.c +192 -0
  141. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_complex_value.h +21 -0
  142. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.c +396 -0
  143. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_conf_file.h +44 -0
  144. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.c +72 -0
  145. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_debug.h +171 -0
  146. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.c +57 -0
  147. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_encoding.h +12 -0
  148. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.c +82 -0
  149. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_hash.h +45 -0
  150. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.c +138 -0
  151. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http.h +3 -0
  152. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_http_headers.h +35 -0
  153. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.c +3 -0
  154. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_log.h +165 -0
  155. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_parse.h +67 -0
  156. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.c +583 -0
  157. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_path.h +22 -0
  158. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.c +20 -0
  159. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_process.h +12 -0
  160. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.c +215 -0
  161. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_regex.h +7 -0
  162. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.c +103 -0
  163. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_rewrite.h +26 -0
  164. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.c +602 -0
  165. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_set_var.h +44 -0
  166. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.c +434 -0
  167. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string.h +37 -0
  168. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_string_util.h +14 -0
  169. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.c +205 -0
  170. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_upstream_list.h +27 -0
  171. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.c +45 -0
  172. data/packaging/debian/debian_specs/nginx/modules/nginx-development-kit/src/ndk_uri.h +6 -0
  173. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/LICENSE +25 -0
  174. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/README.markdown +1850 -0
  175. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/config +5 -0
  176. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/doc/HttpEchoModule.wiki +1558 -0
  177. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ddebug.h +109 -0
  178. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.c +344 -0
  179. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_echo.h +25 -0
  180. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.c +282 -0
  181. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_filter.h +15 -0
  182. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.c +183 -0
  183. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_foreach.h +16 -0
  184. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.c +429 -0
  185. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_handler.h +18 -0
  186. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.c +178 -0
  187. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_location.h +13 -0
  188. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.c +667 -0
  189. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_module.h +137 -0
  190. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.c +452 -0
  191. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_request_info.h +31 -0
  192. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.c +208 -0
  193. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_sleep.h +16 -0
  194. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.c +788 -0
  195. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_subrequest.h +19 -0
  196. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.c +96 -0
  197. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_timer.h +13 -0
  198. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.c +298 -0
  199. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_util.h +58 -0
  200. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.c +110 -0
  201. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/src/ngx_http_echo_var.h +9 -0
  202. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/build.sh +45 -0
  203. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/releng +8 -0
  204. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/util/wiki2pod.pl +131 -0
  205. data/packaging/debian/debian_specs/nginx/modules/nginx-echo/valgrind.suppress +38 -0
  206. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/LICENCE +24 -0
  207. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/README +206 -0
  208. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/changelog.txt +54 -0
  209. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/config +26 -0
  210. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/protocol.txt +191 -0
  211. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.c +59 -0
  212. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_defs.h +73 -0
  213. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.c +783 -0
  214. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module.h +31 -0
  215. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_module_setup.c +361 -0
  216. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/ngx_http_push_types.h +120 -0
  217. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.c +1180 -0
  218. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/memory/store.h +1 -0
  219. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.c +146 -0
  220. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_module_ipc.h +5 -0
  221. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_http_push_store.h +51 -0
  222. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.c +178 -0
  223. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/ngx_rwlock.h +5 -0
  224. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.c +246 -0
  225. data/packaging/debian/debian_specs/nginx/modules/nginx-http-push/src/store/rbtree_util.h +9 -0
  226. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/Changes +51 -0
  227. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/README.markdown +6954 -0
  228. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/config +363 -0
  229. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/doc/HttpLuaModule.wiki +5898 -0
  230. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/dtrace/ngx_lua_provider.d +61 -0
  231. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/Makefile +3 -0
  232. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/lib/RecvUntil.pm +138 -0
  233. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/misc/recv-until-pm/t/sanity.t +140 -0
  234. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/api/ngx_http_lua_api.h +52 -0
  235. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ddebug.h +82 -0
  236. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.c +377 -0
  237. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_accessby.h +22 -0
  238. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_api.c +77 -0
  239. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.c +537 -0
  240. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_args.h +20 -0
  241. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.c +632 -0
  242. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_bodyfilterby.h +31 -0
  243. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.c +296 -0
  244. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_cache.h +24 -0
  245. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.c +175 -0
  246. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_capturefilter.h +20 -0
  247. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.c +887 -0
  248. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_clfactory.h +22 -0
  249. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_common.h +478 -0
  250. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.c +67 -0
  251. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_config.h +19 -0
  252. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.c +148 -0
  253. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_consts.h +20 -0
  254. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.c +369 -0
  255. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_contentby.h +26 -0
  256. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.c +483 -0
  257. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_control.h +20 -0
  258. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.c +379 -0
  259. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_coroutine.h +23 -0
  260. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.c +216 -0
  261. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ctx.h +23 -0
  262. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.c +1081 -0
  263. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_directive.h +56 -0
  264. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.c +58 -0
  265. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_exception.h +33 -0
  266. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.c +302 -0
  267. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headerfilterby.h +29 -0
  268. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.c +1370 -0
  269. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers.h +22 -0
  270. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.c +782 -0
  271. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_in.h +22 -0
  272. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.c +625 -0
  273. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_headers_out.h +23 -0
  274. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.c +42 -0
  275. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initby.h +23 -0
  276. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.c +320 -0
  277. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_initworkerby.h +25 -0
  278. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.c +300 -0
  279. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_log.h +20 -0
  280. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.c +227 -0
  281. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_logby.h +22 -0
  282. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.c +252 -0
  283. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_misc.h +20 -0
  284. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_module.c +924 -0
  285. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.c +184 -0
  286. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_ndk.h +21 -0
  287. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.c +794 -0
  288. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_output.h +28 -0
  289. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.c +106 -0
  290. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_pcrefix.h +23 -0
  291. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.c +94 -0
  292. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_phase.h +13 -0
  293. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_probe.h +85 -0
  294. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.c +2468 -0
  295. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_regex.h +22 -0
  296. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.c +1169 -0
  297. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_body.h +20 -0
  298. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.c +252 -0
  299. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_req_method.h +19 -0
  300. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.c +351 -0
  301. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_rewriteby.h +22 -0
  302. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.c +538 -0
  303. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_script.h +86 -0
  304. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.c +216 -0
  305. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_setby.h +15 -0
  306. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.c +1844 -0
  307. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_shdict.h +52 -0
  308. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.c +191 -0
  309. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_sleep.h +20 -0
  310. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.c +5314 -0
  311. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_tcp.h +156 -0
  312. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.c +1624 -0
  313. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_socket_udp.h +56 -0
  314. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.c +704 -0
  315. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_string.h +20 -0
  316. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.c +1741 -0
  317. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_subrequest.h +46 -0
  318. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.c +278 -0
  319. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_time.h +21 -0
  320. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.c +661 -0
  321. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_timer.h +20 -0
  322. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.c +110 -0
  323. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uri.h +20 -0
  324. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.c +283 -0
  325. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_uthread.h +36 -0
  326. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.c +3972 -0
  327. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_util.h +423 -0
  328. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.c +499 -0
  329. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_variable.h +20 -0
  330. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.c +64 -0
  331. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/src/ngx_http_lua_worker.h +17 -0
  332. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/tapset/ngx_lua.stp +5 -0
  333. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build.sh +39 -0
  334. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/build2.sh +55 -0
  335. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/fix-comments +27 -0
  336. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/gdbinit +415 -0
  337. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/ngx-links +62 -0
  338. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/reindex +64 -0
  339. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/releng +8 -0
  340. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/retab +8 -0
  341. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/revim +102 -0
  342. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/run_test.sh +10 -0
  343. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/util/update-readme.sh +4 -0
  344. data/packaging/debian/debian_specs/nginx/modules/nginx-lua/valgrind.suppress +144 -0
  345. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/CHANGES +107 -0
  346. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/LICENSE +25 -0
  347. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/Makefile +8 -0
  348. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/README +329 -0
  349. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/config +3 -0
  350. data/packaging/debian/debian_specs/nginx/modules/nginx-upload-progress/ngx_http_uploadprogress_module.c +1774 -0
  351. data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/README +53 -0
  352. data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/config +3 -0
  353. data/packaging/debian/debian_specs/nginx/modules/nginx-upstream-fair/ngx_http_upstream_fair_module.c +1356 -0
  354. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/CHANGELOG.md +37 -0
  355. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/HACKING.md +24 -0
  356. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/LICENSE +20 -0
  357. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/README.rst +182 -0
  358. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/config +8 -0
  359. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/nginx-0.6-support.patch +23 -0
  360. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/ngx_http_fancyindex_module.c +1305 -0
  361. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.awk +52 -0
  362. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.h +103 -0
  363. data/packaging/debian/debian_specs/nginx/modules/ngx-fancyindex/template.html +102 -0
  364. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/CHANGES +37 -0
  365. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/README +141 -0
  366. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/config +3 -0
  367. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.google_code_home_page.wiki +120 -0
  368. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.html +199 -0
  369. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/doc/README.wiki +123 -0
  370. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/ngx_http_subs_filter_module.c +1298 -0
  371. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/README +275 -0
  372. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/AutoInstall.pm +820 -0
  373. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install.pm +470 -0
  374. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/AutoInstall.pm +82 -0
  375. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Base.pm +83 -0
  376. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Can.pm +81 -0
  377. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Fetch.pm +93 -0
  378. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Include.pm +34 -0
  379. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Makefile.pm +415 -0
  380. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Metadata.pm +716 -0
  381. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/TestBase.pm +29 -0
  382. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/Win32.pm +64 -0
  383. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Module/Install/WriteAll.pm +63 -0
  384. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Spiffy.pm +539 -0
  385. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base.pm +682 -0
  386. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Base/Filter.pm +341 -0
  387. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder.pm +1413 -0
  388. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/Builder/Module.pm +81 -0
  389. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/inc/Test/More.pm +735 -0
  390. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx.pm +315 -0
  391. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/LWP.pm +524 -0
  392. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Socket.pm +1749 -0
  393. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/lib/Test/Nginx/Util.pm +874 -0
  394. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs.t +136 -0
  395. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_capture.t +32 -0
  396. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_fix_string.t +32 -0
  397. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_regex.t +108 -0
  398. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/t/subs_types.t +59 -0
  399. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/test/test.sh +5 -0
  400. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/update-readme.sh +7 -0
  401. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2google_code_homepage.pl +29 -0
  402. data/packaging/debian/debian_specs/nginx/modules/ngx_http_substitutions_filter_module/util/wiki2pod.pl +129 -0
  403. data/packaging/debian/debian_specs/nginx/nginx-common.NEWS +135 -0
  404. data/packaging/debian/debian_specs/nginx/nginx-common.README.Debian +45 -0
  405. data/packaging/debian/debian_specs/nginx/nginx-common.dirs.erb +32 -0
  406. data/packaging/debian/debian_specs/nginx/nginx-common.install +3 -0
  407. data/packaging/debian/debian_specs/nginx/nginx-common.lintian-overrides +2 -0
  408. data/packaging/debian/debian_specs/nginx/nginx-common.manpages +1 -0
  409. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.default +10 -0
  410. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.init.erb +214 -0
  411. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.logrotate +18 -0
  412. data/packaging/debian/debian_specs/nginx/nginx-common.nginx.service.erb +37 -0
  413. data/packaging/debian/debian_specs/nginx/nginx-common.postinst.erb +66 -0
  414. data/packaging/debian/debian_specs/nginx/nginx-common.postrm.erb +46 -0
  415. data/packaging/debian/debian_specs/nginx/nginx-common.preinst +47 -0
  416. data/packaging/debian/debian_specs/nginx/nginx-common.prerm.erb +28 -0
  417. data/packaging/debian/debian_specs/nginx/nginx-doc.docs +2 -0
  418. data/packaging/debian/debian_specs/nginx/nginx-doc.examples +1 -0
  419. data/packaging/debian/debian_specs/nginx/nginx-extras.install.erb +17 -0
  420. data/packaging/debian/debian_specs/nginx/nginx-extras.lintian-overrides +1 -0
  421. data/packaging/debian/debian_specs/nginx/nginx-extras.postinst.erb +44 -0
  422. data/packaging/debian/debian_specs/nginx/nginx-extras.prerm +22 -0
  423. data/packaging/debian/debian_specs/nginx/nginx.1 +47 -0
  424. data/packaging/debian/debian_specs/nginx/patches/perl-use-dpkg-buildflags.patch +23 -0
  425. data/packaging/debian/debian_specs/nginx/patches/series +1 -0
  426. data/packaging/debian/debian_specs/nginx/rules.erb +185 -0
  427. data/packaging/debian/debian_specs/nginx/source/format +1 -0
  428. data/packaging/debian/debian_specs/nginx/tests/control +4 -0
  429. data/packaging/debian/debian_specs/nginx/ufw/nginx +14 -0
  430. data/packaging/debian/debian_specs/nginx/upstream/signing-key.asc +34 -0
  431. data/packaging/debian/debian_specs/nginx/watch +3 -0
  432. data/packaging/debian/debian_specs/passenger/README.Debian +12 -0
  433. data/packaging/debian/debian_specs/passenger/changelog +316 -0
  434. data/packaging/debian/debian_specs/passenger/compat +1 -0
  435. data/packaging/debian/debian_specs/passenger/control.erb +123 -0
  436. data/packaging/debian/debian_specs/passenger/copyright +385 -0
  437. data/packaging/debian/debian_specs/passenger/helpers.rb +24 -0
  438. data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.install +3 -0
  439. data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.postinst +36 -0
  440. data/packaging/debian/debian_specs/passenger/libapache2-mod-passenger.prerm +15 -0
  441. data/packaging/debian/debian_specs/passenger/locations.ini.erb +14 -0
  442. data/packaging/debian/debian_specs/passenger/passenger-dev.install.erb +3 -0
  443. data/packaging/debian/debian_specs/passenger/passenger-doc.install.erb +2 -0
  444. data/packaging/debian/debian_specs/passenger/passenger.conf +6 -0
  445. data/packaging/debian/debian_specs/passenger/passenger.docs +4 -0
  446. data/packaging/debian/debian_specs/passenger/passenger.install.erb +16 -0
  447. data/packaging/debian/debian_specs/passenger/passenger.load +3 -0
  448. data/packaging/debian/debian_specs/passenger/passenger.manpages +3 -0
  449. data/packaging/debian/debian_specs/passenger/passenger_free_ruby.c +29 -0
  450. data/packaging/debian/debian_specs/passenger/passenger_ruby_utils.c +54 -0
  451. data/packaging/debian/debian_specs/passenger/passenger_system_ruby.c.erb +37 -0
  452. data/packaging/debian/debian_specs/passenger/patches/series +0 -0
  453. data/packaging/debian/debian_specs/passenger/rules.erb +84 -0
  454. data/packaging/debian/debian_specs/passenger/source/format +1 -0
  455. data/packaging/debian/debian_specs/passenger_enterprise/README.Debian +12 -0
  456. data/packaging/debian/debian_specs/passenger_enterprise/changelog +316 -0
  457. data/packaging/debian/debian_specs/passenger_enterprise/compat +1 -0
  458. data/packaging/debian/debian_specs/passenger_enterprise/control.erb +123 -0
  459. data/packaging/debian/debian_specs/passenger_enterprise/copyright +385 -0
  460. data/packaging/debian/debian_specs/passenger_enterprise/helpers.rb +2 -0
  461. data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.install +3 -0
  462. data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.postinst +36 -0
  463. data/packaging/debian/debian_specs/passenger_enterprise/libapache2-mod-passenger-enterprise.prerm +15 -0
  464. data/packaging/debian/debian_specs/passenger_enterprise/locations.ini.erb +14 -0
  465. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-dev.install.erb +3 -0
  466. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise-doc.install.erb +2 -0
  467. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.docs +4 -0
  468. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.install.erb +14 -0
  469. data/packaging/debian/debian_specs/passenger_enterprise/passenger-enterprise.manpages +3 -0
  470. data/packaging/debian/debian_specs/passenger_enterprise/passenger.conf +6 -0
  471. data/packaging/debian/debian_specs/passenger_enterprise/passenger.load +3 -0
  472. data/packaging/debian/debian_specs/passenger_enterprise/passenger_free_ruby.c.erb +1 -0
  473. data/packaging/debian/debian_specs/passenger_enterprise/passenger_ruby_utils.c.erb +1 -0
  474. data/packaging/debian/debian_specs/passenger_enterprise/passenger_system_ruby.c.erb +1 -0
  475. data/packaging/debian/debian_specs/passenger_enterprise/patches/series +0 -0
  476. data/packaging/debian/debian_specs/passenger_enterprise/rules.erb +84 -0
  477. data/packaging/debian/debian_specs/passenger_enterprise/source/format +1 -0
  478. data/packaging/debian/docker_images/Makefile +38 -0
  479. data/packaging/debian/docker_images/buildbox/CONTAINER_VERSION.txt +0 -0
  480. data/packaging/debian/docker_images/buildbox/Dockerfile +3 -0
  481. data/packaging/debian/docker_images/buildbox/Gemfile +9 -0
  482. data/packaging/debian/docker_images/buildbox/Gemfile.lock +42 -0
  483. data/packaging/debian/docker_images/buildbox/install.sh +85 -0
  484. data/packaging/debian/docker_images/buildbox/pbuilderrc +4 -0
  485. data/packaging/debian/docker_images/buildbox/sudoers.conf +6 -0
  486. data/packaging/debian/docker_images/setup-buildbox-docker-image +7 -0
  487. data/packaging/debian/docker_images/setup-testbox-docker-image-debian-6 +7 -0
  488. data/packaging/debian/docker_images/setup-testbox-docker-image-debian-7 +7 -0
  489. data/packaging/debian/docker_images/setup-testbox-docker-image-debian-8 +7 -0
  490. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-12.04 +7 -0
  491. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-14.04 +7 -0
  492. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.04 +7 -0
  493. data/packaging/debian/docker_images/setup-testbox-docker-image-ubuntu-15.10 +7 -0
  494. data/packaging/debian/docker_images/testbox-debian-6/Dockerfile +3 -0
  495. data/packaging/debian/docker_images/testbox-debian-6/Gemfile +2 -0
  496. data/packaging/debian/docker_images/testbox-debian-6/Gemfile.lock +23 -0
  497. data/packaging/debian/docker_images/testbox-debian-6/argparse.py +2374 -0
  498. data/packaging/debian/docker_images/testbox-debian-6/install.sh +78 -0
  499. data/packaging/debian/docker_images/testbox-debian-7/Dockerfile +3 -0
  500. data/packaging/debian/docker_images/testbox-debian-7/Gemfile +2 -0
  501. data/packaging/debian/docker_images/testbox-debian-7/Gemfile.lock +23 -0
  502. data/packaging/debian/docker_images/testbox-debian-7/install.sh +71 -0
  503. data/packaging/debian/docker_images/testbox-debian-8/Dockerfile +3 -0
  504. data/packaging/debian/docker_images/testbox-debian-8/Gemfile +2 -0
  505. data/packaging/debian/docker_images/testbox-debian-8/Gemfile.lock +23 -0
  506. data/packaging/debian/docker_images/testbox-debian-8/install.sh +70 -0
  507. data/packaging/debian/docker_images/testbox-ubuntu-12.04/Dockerfile +3 -0
  508. data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile +2 -0
  509. data/packaging/debian/docker_images/testbox-ubuntu-12.04/Gemfile.lock +23 -0
  510. data/packaging/debian/docker_images/testbox-ubuntu-12.04/install.sh +69 -0
  511. data/packaging/debian/docker_images/testbox-ubuntu-14.04/Dockerfile +3 -0
  512. data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile +2 -0
  513. data/packaging/debian/docker_images/testbox-ubuntu-14.04/Gemfile.lock +23 -0
  514. data/packaging/debian/docker_images/testbox-ubuntu-14.04/install.sh +69 -0
  515. data/packaging/debian/docker_images/testbox-ubuntu-15.04/Dockerfile +3 -0
  516. data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile +2 -0
  517. data/packaging/debian/docker_images/testbox-ubuntu-15.04/Gemfile.lock +23 -0
  518. data/packaging/debian/docker_images/testbox-ubuntu-15.04/install.sh +69 -0
  519. data/packaging/debian/docker_images/testbox-ubuntu-15.10/Dockerfile +3 -0
  520. data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile +2 -0
  521. data/packaging/debian/docker_images/testbox-ubuntu-15.10/Gemfile.lock +23 -0
  522. data/packaging/debian/docker_images/testbox-ubuntu-15.10/install.sh +69 -0
  523. data/packaging/debian/internal/build/Rakefile +235 -0
  524. data/packaging/debian/internal/build/build-passenger-orig-tarball.sh +76 -0
  525. data/packaging/debian/internal/build/build-source-package.rb +121 -0
  526. data/packaging/debian/internal/build/download-nginx-orig-tarball.sh +17 -0
  527. data/packaging/debian/internal/build/rakefile_support.rb +96 -0
  528. data/packaging/debian/internal/build/setup-environment-essentials.sh +15 -0
  529. data/packaging/debian/internal/build/setup-environment.sh +29 -0
  530. data/packaging/debian/internal/lib/distro_info.rb +82 -0
  531. data/packaging/debian/internal/lib/distro_info.sh +303 -0
  532. data/packaging/debian/internal/lib/distro_info.sh.erb +65 -0
  533. data/packaging/debian/internal/lib/library.sh +83 -0
  534. data/packaging/debian/internal/lib/preprocessor.rb +173 -0
  535. data/packaging/debian/internal/lib/tracking.rb +95 -0
  536. data/packaging/debian/internal/lib/tracking_category.rb +45 -0
  537. data/packaging/debian/internal/lib/tracking_database.rb +132 -0
  538. data/packaging/debian/internal/lib/tracking_task.rb +148 -0
  539. data/packaging/debian/internal/lib/utils.rb +78 -0
  540. data/packaging/debian/internal/publish/Rakefile +97 -0
  541. data/packaging/debian/internal/publish/oss-binaries.phusionpassenger.com-fingerprint.txt +1 -0
  542. data/packaging/debian/internal/publish/packagecloud_fingerprint.txt +1 -0
  543. data/packaging/debian/internal/publish/passenger_website_fingerprint.txt +1 -0
  544. data/packaging/debian/internal/publish/preinit.sh +7 -0
  545. data/packaging/debian/internal/publish/rakefile_support.rb +183 -0
  546. data/packaging/debian/internal/scripts/gpg_noninteractive/gpg +11 -0
  547. data/packaging/debian/internal/scripts/initccache.sh +35 -0
  548. data/packaging/debian/internal/scripts/inituidgid.sh +19 -0
  549. data/packaging/debian/internal/scripts/my_init +340 -0
  550. data/packaging/debian/internal/scripts/pin_certificates +34 -0
  551. data/packaging/debian/internal/scripts/regen_distro_info_script.sh +3 -0
  552. data/packaging/debian/internal/scripts/setup-vagrant.sh +12 -0
  553. data/packaging/debian/internal/scripts/setuser +31 -0
  554. data/packaging/debian/internal/shell/initpbuilder.sh +3 -0
  555. data/packaging/debian/internal/shell/preinit.sh +28 -0
  556. data/packaging/debian/internal/shell/sudoers.conf +1 -0
  557. data/packaging/debian/internal/test/apache/apache-24.conf +5 -0
  558. data/packaging/debian/internal/test/apache/apache-pre-24.conf +4 -0
  559. data/packaging/debian/internal/test/apache/vhost.conf +17 -0
  560. data/packaging/debian/internal/test/misc/config.json +15 -0
  561. data/packaging/debian/internal/test/misc/hosts.conf +4 -0
  562. data/packaging/debian/internal/test/misc/init.sh +25 -0
  563. data/packaging/debian/internal/test/misc/nodejs_test_app.js +6 -0
  564. data/packaging/debian/internal/test/misc/python_test_app.py +3 -0
  565. data/packaging/debian/internal/test/misc/ruby_test_app.rb +5 -0
  566. data/packaging/debian/internal/test/misc/test_support.rb +61 -0
  567. data/packaging/debian/internal/test/nginx/vhost.conf +23 -0
  568. data/packaging/debian/internal/test/system_web_server_test.rb +126 -0
  569. data/packaging/debian/internal/test/test.sh +141 -0
  570. data/packaging/debian/jenkins/publish/clear_caches.rb +48 -0
  571. data/packaging/debian/jenkins/publish/publish.sh +69 -0
  572. data/packaging/debian/jenkins/test/test.sh +63 -0
  573. data/packaging/debian/passenger_apt_automation.sublime-project +14 -0
  574. data/packaging/debian/publish +172 -0
  575. data/packaging/debian/shell +116 -0
  576. data/packaging/debian/test +142 -0
  577. metadata +563 -3
  578. metadata.gz.asc +7 -7
  579. data/resources/oss-binaries.phusionpassenger.com.crt +0 -208
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (C) 2007 Brice FIGUREAU
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions
6
+ * are met:
7
+ * 1. Redistributions of source code must retain the above copyright
8
+ * notice, this list of conditions and the following disclaimer.
9
+ * 2. Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ *
13
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
+ * SUCH DAMAGE.
24
+ *
25
+ */
@@ -0,0 +1,8 @@
1
+ dist: CHANGES README LICENSE config ngx_http_uploadprogress_module.c
2
+ tar czvf ../nginx_uploadprogress_module-0.7.tar.gz \
3
+ ../nginx_uploadprogress_module/CHANGES \
4
+ ../nginx_uploadprogress_module/README \
5
+ ../nginx_uploadprogress_module/LICENSE \
6
+ ../nginx_uploadprogress_module/config \
7
+ ../nginx_uploadprogress_module/ngx_http_uploadprogress_module.c
8
+
@@ -0,0 +1,329 @@
1
+ Nginx Upload Progress Module
2
+ ============================
3
+
4
+ Introduction
5
+ ============
6
+
7
+ nginx_uploadprogress_module is an implementation of an upload progress system, that monitors
8
+ RFC1867 POST upload as they are transmitted to upstream servers.
9
+
10
+ It works by tracking the uploads proxied by Nginx to upstream servers without
11
+ analysing the uploaded content and offers a web API to report upload progress in Javscript, Json or any
12
+ other format (through the help of templates).
13
+
14
+ It works because Nginx acts as an accelerator of an upstream server, storing uploaded POST content
15
+ on disk, before transmitting it to the upstream server. Each individual POST upload request
16
+ should contain a progress unique identifier.
17
+
18
+ This module is Copyright (c) 2007-2012 Brice Figureau, and is licensed under the BSD license (see LICENSE).
19
+ * rbtree and shm_zone code is based on Igor Sysoev limit_zone Nginx module.
20
+ * expire header code is based on Igor Sysoev header_filter Nginx module.
21
+
22
+ The JSON idea and the mechanism idea are based on Lighttpd mod_uploadprogress:
23
+ http://blog.lighttpd.net/articles/2006/08/01/mod_uploadprogress-is-back
24
+
25
+
26
+ WARNING:
27
+ * when compiled with --with-debug, this module will produce high number of log messages.
28
+
29
+ INCOMPATIBLE CHANGES
30
+ ====================
31
+
32
+ v0.9.0:
33
+
34
+ JSONP is now the default output of the progress probes. If you rely on this module serving
35
+ the deprecated java output use:
36
+ upload_progress_java_output
37
+ in the progress probe location.
38
+
39
+
40
+ Installation
41
+ ============
42
+
43
+ nginx_uploadprogress_module has been tested with Nginx 0.6.x, 0.7.x, 0.8.x and 1.0.x.
44
+
45
+ Download the Nginx sources from http://nginx.net/ and unpack it.
46
+
47
+ To build Nginx, change to the directory which contains the Nginx
48
+ sources, and run the configuration script making sure to add the path
49
+ to the nginx_uploadprogress_module sources using the --add-module option: ::
50
+
51
+ $ ./configure --add-module=/path/to/nginx_uploadprogress_module/
52
+
53
+ Now you can build and install the software:
54
+
55
+ $ make
56
+
57
+ and as root:
58
+
59
+ $ make install
60
+
61
+
62
+ Configuration
63
+ =============
64
+
65
+ Each upload request should be assigned a unique identifier. This unique identifier will be used
66
+ to store the request and reference it to report.
67
+ This identifier can be transmitted either as a GET argument or as an HTTP header whose name is X-Progress-ID.
68
+
69
+ upload_progress
70
+ +++++++++++++++
71
+ :Syntax: upload_progress <zone_name> <zone_size>
72
+ :Default: none
73
+ :Context: http
74
+ :Description:
75
+ This directive enables the upload progress module and reserve <zone_size> bytes to the <zone_name> which
76
+ will be used to store the per-connection tracking information.
77
+
78
+ track_uploads
79
+ +++++++++++++
80
+ :Syntax: track_uploads <zone_name> <timeout>
81
+ :Default: none
82
+ :Context: location
83
+ :Description:
84
+ This directive enables tracking uploads for the current location. Each POST landing in this location will register
85
+ the request in the <zone_name> upload progress tracker.
86
+ Since Nginx doesn't support yet RFC 1867 upload, the location must be a proxy_pass or fastcgi location.
87
+ The POST _must_ have a query parameter called X-Progress-ID (or an HTTP header of the same name) whose value is the
88
+ unique identifier used to get progress information. If the POST has no such information, the upload will not be tracked.
89
+ The tracked connections are kept at most <timeout> seconds after they have been finished to be able to serve
90
+ useful information to upload progress probes.
91
+ WARNING: this directive must be the last directive of the location. It must be in a proxy_pass or
92
+ fastcgi_pass location.
93
+
94
+ report_uploads
95
+ ++++++++++++++
96
+ :Syntax: report_uploads <zone_name>
97
+ :Default: none
98
+ :Context: location
99
+ :Description:
100
+ This directive allows a location to report the upload progress that is tracked by track_uploads for <zone_name>.
101
+ The returned document is a Javascript text with the possible 4 results by default:
102
+ * the upload request hasn't been registered yet or is unknown:
103
+ new Object({ 'state' : 'starting' })
104
+
105
+ * the upload request has ended:
106
+ new Object({ 'state' : 'done' })
107
+
108
+ * the upload request generated an HTTP error
109
+ new Object({ 'state' : 'error', 'status' : <error code> })
110
+ one error code that can be of use to track for the client is 413 (request entity too large).
111
+
112
+ * the upload request is in progress:
113
+ new Object({ 'state' : 'uploading', 'received' : <size_received>, 'size' : <total_size>})
114
+
115
+ It is possible to return pure json instead of this javascript (see upload_progress_json_output).
116
+ It is also possible to configure completely the response format with the directive:
117
+ upload_progress_template
118
+
119
+ The HTTP request to this location must have a X-Progress-ID parameter or HTTP header containing a valid
120
+ unique identifier of an in progress upload.
121
+
122
+ upload_progress_content_type
123
+ ++++++++++++++++++++++++++++
124
+ :Syntax: upload_progress_content_type <content_type>
125
+ :Default: text/javascript
126
+ :Context: location
127
+ :Description:
128
+ This directive allows to change the upload progress probe response content-type.
129
+
130
+ upload_progress_header
131
+ ++++++++++++++++++++++
132
+ :Syntax: upload_progress_header <progress-id>
133
+ :Default: X-Progress-ID
134
+ :Context: location
135
+ :Description:
136
+ This directive allows to change the header name of the progress ID.
137
+
138
+ upload_progress_jsonp_parameter
139
+ ++++++++++++++++++++++
140
+ :Syntax: upload_progress_jsonp_parameter <callback_parameter>
141
+ :Default: callback
142
+ :Context: location
143
+ :Description:
144
+ This directive allows to change the name of the GET parameter with the jsonp callback name.
145
+
146
+ upload_progress_java_output
147
+ +++++++++++++++++++++++++++
148
+ :Syntax: upload_progress_java_output
149
+ :Default: N/A
150
+ :Context: location
151
+ :Description:
152
+ This directive sets everything to output as eval() javascript compatible code.
153
+
154
+ upload_progress_json_output
155
+ +++++++++++++++++++++++++++
156
+ :Syntax: upload_progress_json_output
157
+ :Default: N/A
158
+ :Context: location
159
+ :Description:
160
+ This directive sets everything to output as pure json.
161
+
162
+ upload_progress_jsonp_output
163
+ ++++++++++++++++++++++++++++
164
+ :Syntax: upload_progress_jsonp_output
165
+ :Default: N/A
166
+ :Context: location
167
+ :Description:
168
+ This directive sets everything to output as jsonp (like json output, but with callback).
169
+
170
+ upload_progress_template
171
+ ++++++++++++++++++++++++
172
+ :Syntax: upload_progress_template <state> <template>
173
+ :Default: none
174
+ :Context: location
175
+ :Description:
176
+ This directive can be used to install a progress response template.
177
+ The available list of state is:
178
+ * starting
179
+ * uploading
180
+ * error
181
+ * done
182
+
183
+ Nginx will replace the value of the following variables with their respective
184
+ value for the upload:
185
+ * $uploadprogress_length: total size of the upload
186
+ * $uploadprogress_received: what the server has received so far
187
+ * $uploadprogress_status: error code in case of HTTP error
188
+ * $uploadprogress_callback: jsonp callback name if provided as a GET query parameter with name 'callback'
189
+
190
+ For instance to return XML (instead of the default Javascript or json):
191
+
192
+ upload_progress_content_type 'text/xml';
193
+ upload_progress_template starting '<upload><state>starting</state></upload>';
194
+ upload_progress_template uploading '<upload><state>uploading</state><size>$uploadprogress_length</size><uploaded>$uploadprogress_received</uploaded></upload>';
195
+ upload_progress_template done '<upload><state>done</state></upload>';
196
+ upload_progress_template error '<upload><state>error</state><code>$uploadprogress_status</code></upload>';
197
+
198
+ Example of jsonp response:
199
+
200
+ upload_progress_template starting "$uploadprogress_callback({ \"state\" : \"starting\"});";
201
+ upload_progress_template error "$uploadprogress_callback({ \"state\" : \"error\", \"status\" : $uploadprogress_status });";
202
+ upload_progress_template done "$uploadprogress_callback({ \"state\" : \"done\"});";
203
+ upload_progress_template uploading "$uploadprogress_callback({ \"state\" : \"uploading\", \"received\" : $uploadprogress_received, \"size\" : $uploadprogress_length });";
204
+
205
+ Configuration Example:
206
+ +++++++++++++++++++++
207
+
208
+ http {
209
+
210
+ # reserve 1MB under the name 'proxied' to track uploads
211
+ upload_progress proxied 1m;
212
+
213
+ server {
214
+ listen 127.0.0.1 default;
215
+ server_name _ *;
216
+
217
+ root /path/to/root;
218
+
219
+ location / {
220
+ # proxy to upstream server
221
+ proxy_pass http://127.0.0.1;
222
+ proxy_redirect default;
223
+
224
+ # track uploads in the 'proxied' zone
225
+ # remember connections for 30s after they finished
226
+ track_uploads proxied 30s;
227
+ }
228
+
229
+ location ^~ /progress {
230
+ # report uploads tracked in the 'proxied' zone
231
+ report_uploads proxied;
232
+ }
233
+ }
234
+
235
+
236
+ Usage Example
237
+ =============
238
+
239
+ (based on Lighttd mod_uploadprogress module example):
240
+
241
+ First we need a upload form:
242
+
243
+ <form id="upload" enctype="multipart/form-data"
244
+ action="/upload.php" method="post"
245
+ onsubmit="openProgressBar(); return true;">
246
+ <input type="hidden" name="MAX_FILE_SIZE" value="30000000" />
247
+ <input name="userfile" type="file" label="fileupload" />
248
+ <input type="submit" value="Send File" />
249
+ </form>
250
+
251
+ And a progress bar to visualize the progress:
252
+
253
+ <div>
254
+ <div id="progress" style="width: 400px; border: 1px solid black">
255
+ <div id="progressbar"
256
+ style="width: 1px; background-color: black; border: 1px solid white">
257
+ &nbsp;
258
+ </div>
259
+ </div>
260
+ <div id="tp">(progress)</div>
261
+ </div>
262
+
263
+ Then we need to generate the Unique Identifier and launch the upload on submit
264
+ action. This also will start the ajax progress report mechanism.
265
+
266
+ interval = null;
267
+
268
+ function openProgressBar() {
269
+ /* generate random progress-id */
270
+ uuid = "";
271
+ for (i = 0; i < 32; i++) {
272
+ uuid += Math.floor(Math.random() * 16).toString(16);
273
+ }
274
+ /* patch the form-action tag to include the progress-id */
275
+ document.getElementById("upload").action="/upload.php?X-Progress-ID=" + uuid;
276
+
277
+ /* call the progress-updater every 1000ms */
278
+ interval = window.setInterval(
279
+ function () {
280
+ fetch(uuid);
281
+ },
282
+ 1000
283
+ );
284
+ }
285
+
286
+ function fetch(uuid) {
287
+ req = new XMLHttpRequest();
288
+ req.open("GET", "/progress", 1);
289
+ req.setRequestHeader("X-Progress-ID", uuid);
290
+ req.onreadystatechange = function () {
291
+ if (req.readyState == 4) {
292
+ if (req.status == 200) {
293
+ /* poor-man JSON parser */
294
+ var upload = eval(req.responseText);
295
+
296
+ document.getElementById('tp').innerHTML = upload.state;
297
+
298
+ /* change the width if the inner progress-bar */
299
+ if (upload.state == 'done' || upload.state == 'uploading') {
300
+ bar = document.getElementById('progressbar');
301
+ w = 400 * upload.received / upload.size;
302
+ bar.style.width = w + 'px';
303
+ }
304
+ /* we are done, stop the interval */
305
+ if (upload.state == 'done') {
306
+ window.clearTimeout(interval);
307
+ }
308
+ }
309
+ }
310
+ }
311
+ req.send(null);
312
+ }
313
+
314
+ Companion Software
315
+ ==================
316
+
317
+ This software can also work with Valery Kholodkov' Nginx Upload Module:
318
+ http://www.grid.net.ru/nginx/upload.en.html
319
+
320
+ You can also use the following javascript libraries client side:
321
+ http://drogomir.com/blog/2008/6/30/upload-progress-script-with-safari-support
322
+
323
+ Note that when using jQuery AJAX for progress monitoring, such as:
324
+ https://github.com/drogus/jquery-upload-progress
325
+ you should be sure to set a upload_progress template parameter:
326
+ upload_progress_json_output
327
+ or
328
+ upload_progress_jsonp_output
329
+ depending on your jQuery AJAX dataType setting.
@@ -0,0 +1,3 @@
1
+ ngx_addon_name=ngx_http_uploadprogress_module
2
+ HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES ngx_http_uploadprogress_module"
3
+ NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_uploadprogress_module.c"
@@ -0,0 +1,1774 @@
1
+
2
+ /*
3
+ * Copyright (C) 2007 Brice Figureau
4
+ * shm_zone and rbtree code Copyright (c) 2002-2007 Igor Sysoev
5
+ */
6
+
7
+ #include <ngx_config.h>
8
+ #include <ngx_core.h>
9
+ #include <ngx_http.h>
10
+
11
+ #define TIMER_FREQUENCY 15 * 1000
12
+
13
+ typedef enum {
14
+ uploadprogress_state_starting = 0,
15
+ uploadprogress_state_error = 1,
16
+ uploadprogress_state_done = 2,
17
+ uploadprogress_state_uploading = 3,
18
+ uploadprogress_state_none
19
+ } ngx_http_uploadprogress_state_t;
20
+
21
+ typedef struct {
22
+ ngx_str_t name;
23
+ ngx_http_uploadprogress_state_t idx;
24
+ } ngx_http_uploadprogress_state_map_t;
25
+
26
+ typedef struct ngx_http_uploadprogress_node_s ngx_http_uploadprogress_node_t;
27
+
28
+ struct ngx_http_uploadprogress_node_s {
29
+ ngx_rbtree_node_t node;
30
+ ngx_uint_t err_status;
31
+ off_t rest;
32
+ off_t length;
33
+ ngx_uint_t done;
34
+ time_t timeout;
35
+ struct ngx_http_uploadprogress_node_s *prev;
36
+ struct ngx_http_uploadprogress_node_s *next;
37
+ u_char len;
38
+ u_char data[1];
39
+ };
40
+
41
+ typedef struct {
42
+ ngx_shm_zone_t *shm_zone;
43
+ ngx_rbtree_node_t *node;
44
+ ngx_http_request_t *r;
45
+ time_t timeout;
46
+ } ngx_http_uploadprogress_cleanup_t;
47
+
48
+ typedef struct {
49
+ ngx_rbtree_t *rbtree;
50
+ ngx_http_uploadprogress_node_t list_head;
51
+ ngx_http_uploadprogress_node_t list_tail;
52
+ } ngx_http_uploadprogress_ctx_t;
53
+
54
+ typedef struct {
55
+ ngx_array_t *values;
56
+ ngx_array_t *lengths;
57
+ } ngx_http_uploadprogress_template_t;
58
+
59
+ typedef struct {
60
+ ngx_shm_zone_t *shm_zone;
61
+ time_t timeout;
62
+ ngx_event_t cleanup;
63
+ ngx_http_handler_pt handler;
64
+ u_char track;
65
+ ngx_str_t content_type;
66
+ ngx_array_t templates;
67
+ ngx_str_t header;
68
+ ngx_str_t jsonp_parameter;
69
+ } ngx_http_uploadprogress_conf_t;
70
+
71
+ typedef struct {
72
+ ngx_http_event_handler_pt read_event_handler;
73
+ } ngx_http_uploadprogress_module_ctx_t;
74
+
75
+ static ngx_int_t ngx_http_reportuploads_handler(ngx_http_request_t *r);
76
+ static void ngx_http_uploadprogress_cleanup(void *data);
77
+ static char *ngx_http_report_uploads(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
78
+ static ngx_int_t ngx_http_uploadprogress_init_zone(ngx_shm_zone_t * shm_zone, void *data);
79
+ static ngx_int_t ngx_http_uploadprogress_init(ngx_conf_t * cf);
80
+ static void *ngx_http_uploadprogress_create_loc_conf(ngx_conf_t *cf);
81
+ static char *ngx_http_uploadprogress_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child);
82
+ static ngx_int_t ngx_http_uploadprogress_init_variables_and_templates(ngx_conf_t *cf);
83
+
84
+ static ngx_int_t ngx_http_uploadprogress_received_variable(ngx_http_request_t *r,
85
+ ngx_http_variable_value_t *v, uintptr_t data);
86
+ static ngx_int_t ngx_http_uploadprogress_offset_variable(ngx_http_request_t *r,
87
+ ngx_http_variable_value_t *v, uintptr_t data);
88
+ static ngx_int_t ngx_http_uploadprogress_status_variable(ngx_http_request_t *r,
89
+ ngx_http_variable_value_t *v, uintptr_t data);
90
+ static ngx_int_t ngx_http_uploadprogress_callback_variable(ngx_http_request_t *r,
91
+ ngx_http_variable_value_t *v, uintptr_t data);
92
+ static char* ngx_http_upload_progress_set_template(ngx_conf_t * cf, ngx_http_uploadprogress_template_t *t, ngx_str_t *source);
93
+ static char *ngx_http_track_uploads(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
94
+ static char *ngx_http_report_uploads(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
95
+ static char *ngx_http_upload_progress(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
96
+ static char* ngx_http_upload_progress_template(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
97
+ static char* ngx_http_upload_progress_java_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
98
+ static char* ngx_http_upload_progress_json_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
99
+ static char* ngx_http_upload_progress_jsonp_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf);
100
+ static void ngx_clean_old_connections(ngx_event_t * ev);
101
+ static ngx_int_t ngx_http_uploadprogress_content_handler(ngx_http_request_t *r);
102
+
103
+ static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
104
+
105
+ static ngx_command_t ngx_http_uploadprogress_commands[] = {
106
+
107
+ {ngx_string("upload_progress"),
108
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE2,
109
+ ngx_http_upload_progress,
110
+ 0,
111
+ 0,
112
+ NULL},
113
+
114
+ {ngx_string("track_uploads"),
115
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE2,
116
+ ngx_http_track_uploads,
117
+ NGX_HTTP_LOC_CONF_OFFSET,
118
+ 0,
119
+ NULL},
120
+
121
+ {ngx_string("report_uploads"),
122
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
123
+ ngx_http_report_uploads,
124
+ NGX_HTTP_LOC_CONF_OFFSET,
125
+ 0,
126
+ NULL},
127
+
128
+ {ngx_string("upload_progress_content_type"),
129
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
130
+ ngx_conf_set_str_slot,
131
+ NGX_HTTP_LOC_CONF_OFFSET,
132
+ offsetof(ngx_http_uploadprogress_conf_t, content_type),
133
+ NULL},
134
+
135
+ {ngx_string("upload_progress_template"),
136
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE2,
137
+ ngx_http_upload_progress_template,
138
+ NGX_HTTP_LOC_CONF_OFFSET,
139
+ offsetof(ngx_http_uploadprogress_conf_t, templates),
140
+ NULL},
141
+
142
+ {ngx_string("upload_progress_java_output"),
143
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_NOARGS,
144
+ ngx_http_upload_progress_java_output,
145
+ NGX_HTTP_LOC_CONF_OFFSET,
146
+ 0,
147
+ NULL},
148
+
149
+ {ngx_string("upload_progress_json_output"),
150
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_NOARGS,
151
+ ngx_http_upload_progress_json_output,
152
+ NGX_HTTP_LOC_CONF_OFFSET,
153
+ 0,
154
+ NULL},
155
+
156
+ {ngx_string("upload_progress_jsonp_output"),
157
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_NOARGS,
158
+ ngx_http_upload_progress_jsonp_output,
159
+ NGX_HTTP_LOC_CONF_OFFSET,
160
+ 0,
161
+ NULL},
162
+
163
+ {ngx_string("upload_progress_header"),
164
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
165
+ ngx_conf_set_str_slot,
166
+ NGX_HTTP_LOC_CONF_OFFSET,
167
+ offsetof(ngx_http_uploadprogress_conf_t, header),
168
+ NULL},
169
+
170
+ {ngx_string("upload_progress_jsonp_parameter"),
171
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
172
+ ngx_conf_set_str_slot,
173
+ NGX_HTTP_LOC_CONF_OFFSET,
174
+ offsetof(ngx_http_uploadprogress_conf_t, jsonp_parameter),
175
+ NULL},
176
+
177
+ ngx_null_command
178
+ };
179
+
180
+ static ngx_http_variable_t ngx_http_uploadprogress_variables[] = {
181
+
182
+ { ngx_string("uploadprogress_received"), NULL, ngx_http_uploadprogress_received_variable,
183
+ (uintptr_t) offsetof(ngx_http_uploadprogress_node_t, rest),
184
+ NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
185
+
186
+ { ngx_string("uploadprogress_remaining"), NULL, ngx_http_uploadprogress_offset_variable,
187
+ (uintptr_t) offsetof(ngx_http_uploadprogress_node_t, rest),
188
+ NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
189
+
190
+ { ngx_string("uploadprogress_length"), NULL, ngx_http_uploadprogress_offset_variable,
191
+ (uintptr_t) offsetof(ngx_http_uploadprogress_node_t, length),
192
+ NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
193
+
194
+ { ngx_string("uploadprogress_status"), NULL, ngx_http_uploadprogress_status_variable,
195
+ (uintptr_t) offsetof(ngx_http_uploadprogress_node_t, err_status),
196
+ NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
197
+
198
+ { ngx_string("uploadprogress_callback"), NULL, ngx_http_uploadprogress_callback_variable,
199
+ (uintptr_t) NULL,
200
+ NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 },
201
+
202
+ { ngx_null_string, NULL, NULL, 0, 0, 0 }
203
+ };
204
+
205
+ static ngx_http_module_t ngx_http_uploadprogress_module_ctx = {
206
+ ngx_http_uploadprogress_init_variables_and_templates, /* preconfiguration */
207
+ ngx_http_uploadprogress_init, /* postconfiguration */
208
+
209
+ NULL, /* create main configuration */
210
+ NULL, /* init main configuration */
211
+
212
+ NULL, /* create server configuration */
213
+ NULL, /* merge server configuration */
214
+
215
+ ngx_http_uploadprogress_create_loc_conf, /* create location configuration */
216
+ ngx_http_uploadprogress_merge_loc_conf /* merge location configuration */
217
+ };
218
+
219
+
220
+ ngx_module_t ngx_http_uploadprogress_module = {
221
+ NGX_MODULE_V1,
222
+ &ngx_http_uploadprogress_module_ctx, /* module context */
223
+ ngx_http_uploadprogress_commands, /* module directives */
224
+ NGX_HTTP_MODULE, /* module type */
225
+ NULL, /* init master */
226
+ NULL, /* init module */
227
+ NULL, /* init process */
228
+ NULL, /* init thread */
229
+ NULL, /* exit thread */
230
+ NULL, /* exit process */
231
+ NULL, /* exit master */
232
+ NGX_MODULE_V1_PADDING
233
+ };
234
+
235
+ static ngx_http_uploadprogress_state_map_t ngx_http_uploadprogress_state_map[] = {
236
+ {ngx_string("starting"), uploadprogress_state_starting},
237
+ {ngx_string("error"), uploadprogress_state_error},
238
+ {ngx_string("done"), uploadprogress_state_done},
239
+ {ngx_string("uploading"), uploadprogress_state_uploading},
240
+ {ngx_null_string, uploadprogress_state_none},
241
+ };
242
+
243
+ static ngx_str_t ngx_http_uploadprogress_java_defaults[] = {
244
+ ngx_string("new Object({ 'state' : 'starting' })\r\n"),
245
+ ngx_string("new Object({ 'state' : 'error', 'status' : $uploadprogress_status })\r\n"),
246
+ ngx_string("new Object({ 'state' : 'done' })\r\n"),
247
+ ngx_string("new Object({ 'state' : 'uploading', 'received' : $uploadprogress_received, 'size' : $uploadprogress_length })\r\n")
248
+ };
249
+
250
+ static ngx_str_t ngx_http_uploadprogress_json_defaults[] = {
251
+ ngx_string("{ \"state\" : \"starting\" }\r\n"),
252
+ ngx_string("{ \"state\" : \"error\", \"status\" : $uploadprogress_status }\r\n"),
253
+ ngx_string("{ \"state\" : \"done\" }\r\n"),
254
+ ngx_string("{ \"state\" : \"uploading\", \"received\" : $uploadprogress_received, \"size\" : $uploadprogress_length }\r\n")
255
+ };
256
+
257
+ static ngx_str_t ngx_http_uploadprogress_jsonp_defaults[] = {
258
+ ngx_string("$uploadprogress_callback({ \"state\" : \"starting\" });\r\n"),
259
+ ngx_string("$uploadprogress_callback({ \"state\" : \"error\", \"status\" : $uploadprogress_status });\r\n"),
260
+ ngx_string("$uploadprogress_callback({ \"state\" : \"done\" });\r\n"),
261
+ ngx_string("$uploadprogress_callback({ \"state\" : \"uploading\", \"received\" : $uploadprogress_received, \"size\" : $uploadprogress_length });\r\n")
262
+ };
263
+
264
+
265
+ static ngx_array_t ngx_http_uploadprogress_global_templates;
266
+
267
+ static ngx_str_t*
268
+ get_tracking_id(ngx_http_request_t * r)
269
+ {
270
+ u_char *p, *start_p;
271
+ ngx_uint_t i;
272
+ ngx_list_part_t *part;
273
+ ngx_table_elt_t *header;
274
+ ngx_str_t *ret, args;
275
+ ngx_http_uploadprogress_conf_t *upcf;
276
+
277
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
278
+
279
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: get_tracking_id");
280
+
281
+ part = &r->headers_in.headers.part;
282
+ header = part->elts;
283
+
284
+ for (i = 0; /* void */ ; i++) {
285
+
286
+ if (i >= part->nelts) {
287
+ if (part->next == NULL) {
288
+ break;
289
+ }
290
+
291
+ part = part->next;
292
+ header = part->elts;
293
+ i = 0;
294
+ }
295
+
296
+ if (header[i].key.len == upcf->header.len
297
+ && ngx_strncasecmp(header[i].key.data, upcf->header.data,
298
+ header[i].key.len) == 0) {
299
+ ret = ngx_calloc(sizeof(ngx_str_t), r->connection->log );
300
+ ret->data = header[i].value.data;
301
+ ret->len = header[i].value.len;
302
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
303
+ "upload-progress: get_tracking_id found header: %V", ret);
304
+ return ret;
305
+ }
306
+ }
307
+
308
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
309
+ "upload-progress: get_tracking_id no header found");
310
+
311
+ /* not found, check as a request arg */
312
+ /* it is possible the request args have not been yet created (or already released) */
313
+ /* so let's try harder first from the request line */
314
+ args.len = r->args.len;
315
+ args.data = r->args.data;
316
+
317
+ if (args.len && args.data) {
318
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
319
+ "upload-progress: get_tracking_id no header found, args found");
320
+ i = 0;
321
+ p = args.data;
322
+ do {
323
+ ngx_uint_t len = args.len - (p - args.data);
324
+ if (len >= (upcf->header.len + 1) && ngx_strncasecmp(p, upcf->header.data, upcf->header.len) == 0
325
+ && p[upcf->header.len] == '=') {
326
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
327
+ "upload-progress: get_tracking_id found args: %s",p);
328
+ i = 1;
329
+ break;
330
+ }
331
+ if (len<=0)
332
+ break;
333
+ }
334
+ while(p++);
335
+
336
+ if (i) {
337
+ start_p = p += upcf->header.len + 1;
338
+ while (p < args.data + args.len) {
339
+ if (*((p++) + 1) == '&') {
340
+ break;
341
+ }
342
+ }
343
+
344
+ ret = ngx_calloc(sizeof(ngx_str_t), r->connection->log);
345
+ ret->data = start_p;
346
+ ret->len = p - start_p;
347
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
348
+ "upload-progress: get_tracking_id found args: %V",ret);
349
+ return ret;
350
+ }
351
+ }
352
+
353
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
354
+ "upload-progress: get_tracking_id no id found");
355
+ return NULL;
356
+ }
357
+
358
+ static ngx_http_uploadprogress_node_t *
359
+ find_node(ngx_str_t * id, ngx_http_uploadprogress_ctx_t * ctx, ngx_log_t * log)
360
+ {
361
+ uint32_t hash;
362
+ ngx_rbtree_node_t *node, *sentinel;
363
+ ngx_int_t rc;
364
+ ngx_http_uploadprogress_node_t *up;
365
+
366
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, log, 0, "upload-progress: find_node %V", id);
367
+
368
+ hash = ngx_crc32_short(id->data, id->len);
369
+
370
+ node = ctx->rbtree->root;
371
+ sentinel = ctx->rbtree->sentinel;
372
+
373
+ while (node != sentinel) {
374
+
375
+ if (hash < node->key) {
376
+ node = node->left;
377
+ continue;
378
+ }
379
+
380
+ if (hash > node->key) {
381
+ node = node->right;
382
+ continue;
383
+ }
384
+
385
+ /* hash == node->key */
386
+
387
+ do {
388
+ up = (ngx_http_uploadprogress_node_t *) node;
389
+
390
+ rc = ngx_memn2cmp(id->data, up->data, id->len, (size_t) up->len);
391
+
392
+ if (rc == 0) {
393
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0,
394
+ "upload-progress: found node");
395
+ return up;
396
+ }
397
+
398
+ node = (rc < 0) ? node->left : node->right;
399
+
400
+ } while (node != sentinel && hash == node->key);
401
+
402
+ /* found a key with unmatching hash (and value), let's keep comparing hashes then */
403
+ }
404
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "upload-progress: can't find node");
405
+ return NULL;
406
+ }
407
+
408
+ static void ngx_http_uploadprogress_event_handler(ngx_http_request_t *r);
409
+
410
+ static ngx_int_t
411
+ ngx_http_uploadprogress_content_handler(ngx_http_request_t *r)
412
+ {
413
+ ngx_int_t rc;
414
+ ngx_http_uploadprogress_module_ctx_t *ctx;
415
+ ngx_http_uploadprogress_conf_t *upcf;
416
+
417
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: ngx_http_uploadprogress_content_handler");
418
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
419
+
420
+ /* call the original request handler */
421
+ rc = upcf->handler(r);
422
+
423
+ /* bail out if error */
424
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
425
+ return rc;
426
+ }
427
+
428
+ /* request is OK, hijack the read_event_handler if the request has to be tracked*/
429
+ ctx = ngx_http_get_module_ctx(r, ngx_http_uploadprogress_module);
430
+ if (ctx != NULL) {
431
+ ctx->read_event_handler = r->read_event_handler;
432
+ r->read_event_handler = ngx_http_uploadprogress_event_handler;
433
+ }
434
+ return rc;
435
+ }
436
+
437
+ static ngx_str_t* ngx_http_uploadprogress_strdup(ngx_str_t *src, ngx_log_t * log)
438
+ {
439
+ ngx_str_t *dst;
440
+ dst = ngx_alloc(src->len + sizeof(ngx_str_t), log);
441
+ if (dst == NULL) {
442
+ return NULL;
443
+ }
444
+
445
+ dst->len = src->len;
446
+ ngx_memcpy(((char*)dst + sizeof(ngx_str_t)) , src->data, src->len);
447
+ dst->data = ((u_char*)dst + sizeof(ngx_str_t));
448
+ return dst;
449
+ }
450
+
451
+ static void ngx_http_uploadprogress_strdupfree(ngx_str_t *str)
452
+ {
453
+ ngx_free(str);
454
+ }
455
+
456
+ static void ngx_http_uploadprogress_event_handler(ngx_http_request_t *r)
457
+ {
458
+ ngx_str_t *id, *oldid;
459
+ ngx_slab_pool_t *shpool;
460
+ ngx_shm_zone_t *shm_zone;
461
+ ngx_http_uploadprogress_ctx_t *ctx;
462
+ ngx_http_uploadprogress_node_t *up;
463
+ ngx_http_uploadprogress_conf_t *upcf;
464
+ ngx_http_uploadprogress_module_ctx_t *module_ctx;
465
+ size_t size;
466
+ off_t rest;
467
+
468
+
469
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "upload-progress: ngx_http_uploadprogress_event_handler");
470
+
471
+ /* find node, update rest */
472
+ oldid = id = get_tracking_id(r);
473
+
474
+ if (id == NULL) {
475
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
476
+ "upload-progress: read_event_handler cant find id");
477
+ return;
478
+ }
479
+
480
+ /* perform a deep copy of id */
481
+ id = ngx_http_uploadprogress_strdup(id, r->connection->log);
482
+ ngx_free(oldid);
483
+
484
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
485
+ "upload-progress: read_event_handler found id: %V", id);
486
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
487
+ shm_zone = upcf->shm_zone;
488
+
489
+ /* call the original read event handler */
490
+ module_ctx = ngx_http_get_module_ctx(r, ngx_http_uploadprogress_module);
491
+ if (module_ctx != NULL ) {
492
+ module_ctx->read_event_handler(r);
493
+ }
494
+
495
+ /* at this stage, r is not anymore safe to use */
496
+ /* the request could have been closed/freed behind our back */
497
+ /* and thats the same issue with any other material that was allocated in the request pool */
498
+ /* that's why we duplicate id afterward */
499
+
500
+ /* it's also possible that the id was null if we got a spurious (like abort) read */
501
+ /* event. In this case we still have called the original read event handler */
502
+ /* but we have to bail out, because we won't ever be able to find our upload node */
503
+
504
+
505
+ if (shm_zone == NULL) {
506
+ ngx_http_uploadprogress_strdupfree(id);
507
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
508
+ "upload-progress: read_event_handler no shm_zone for id: %V", id);
509
+ return;
510
+ }
511
+
512
+ ctx = shm_zone->data;
513
+
514
+ /* get the original connection of the upload */
515
+ shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
516
+
517
+ ngx_shmtx_lock(&shpool->mutex);
518
+
519
+ up = find_node(id, ctx, ngx_cycle->log);
520
+ if (up != NULL && !up->done) {
521
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
522
+ "upload-progress: read_event_handler found node: %V", id);
523
+ rest = r->request_body->rest;
524
+ size = r->request_body->buf->last - r->request_body->buf->pos;
525
+ if ((off_t) size < rest) {
526
+ rest -= size;
527
+ } else {
528
+ rest = 0;
529
+ }
530
+
531
+ up->rest = rest;
532
+ if(up->length == 0)
533
+ up->length = r->headers_in.content_length_n;
534
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
535
+ "upload-progress: read_event_handler storing rest %uO/%uO for %V", up->rest, up->length, id);
536
+ } else {
537
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
538
+ "upload-progress: read_event_handler not found: %V", id);
539
+ }
540
+ ngx_shmtx_unlock(&shpool->mutex);
541
+ ngx_http_uploadprogress_strdupfree(id);
542
+ }
543
+
544
+ /* This generates the response for the report */
545
+ static ngx_int_t
546
+ ngx_http_reportuploads_handler(ngx_http_request_t * r)
547
+ {
548
+ ngx_str_t *id, response;
549
+ ngx_buf_t *b;
550
+ ngx_chain_t out;
551
+ ngx_int_t rc, found=0, done=0, err_status=0;
552
+ off_t rest=0, length=0;
553
+ ngx_uint_t len, i;
554
+ ngx_slab_pool_t *shpool;
555
+ ngx_http_uploadprogress_conf_t *upcf;
556
+ ngx_http_uploadprogress_ctx_t *ctx;
557
+ ngx_http_uploadprogress_node_t *up;
558
+ ngx_table_elt_t *expires, *cc, **ccp;
559
+ ngx_http_uploadprogress_state_t state;
560
+ ngx_http_uploadprogress_template_t *t;
561
+
562
+ if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
563
+ return NGX_HTTP_NOT_ALLOWED;
564
+ }
565
+
566
+ rc = ngx_http_discard_request_body(r);
567
+
568
+ if (rc != NGX_OK) {
569
+ return rc;
570
+ }
571
+
572
+ /* get the tracking id if any */
573
+ id = get_tracking_id(r);
574
+
575
+
576
+ if (id == NULL) {
577
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
578
+ "reportuploads handler cant find id");
579
+ return NGX_DECLINED;
580
+ }
581
+
582
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
583
+ "reportuploads handler found id: %V", id);
584
+
585
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
586
+
587
+ if (upcf->shm_zone == NULL) {
588
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
589
+ "reportuploads no shm_zone for id: %V", id);
590
+ ngx_free(id);
591
+ return NGX_DECLINED;
592
+ }
593
+
594
+ ctx = upcf->shm_zone->data;
595
+
596
+ /* get the original connection of the upload */
597
+ shpool = (ngx_slab_pool_t *) upcf->shm_zone->shm.addr;
598
+
599
+ ngx_shmtx_lock(&shpool->mutex);
600
+
601
+ up = find_node(id, ctx, r->connection->log);
602
+ if (up != NULL) {
603
+ ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
604
+ "reportuploads found node: %V (rest: %uO, length: %uO, done: %ui, err_status: %ui)", id, up->rest, up->length, up->done, up->err_status);
605
+ rest = up->rest;
606
+ length = up->length;
607
+ done = up->done;
608
+ err_status = up->err_status;
609
+ found = 1;
610
+ } else {
611
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
612
+ "reportuploads not found: %V", id);
613
+ }
614
+ ngx_shmtx_unlock(&shpool->mutex);
615
+ ngx_free(id);
616
+
617
+ /* send the output */
618
+ r->headers_out.content_type = upcf->content_type;
619
+
620
+ /* force no-cache */
621
+ expires = r->headers_out.expires;
622
+
623
+ if (expires == NULL) {
624
+
625
+ expires = ngx_list_push(&r->headers_out.headers);
626
+ if (expires == NULL) {
627
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
628
+ }
629
+
630
+ r->headers_out.expires = expires;
631
+
632
+ expires->hash = 1;
633
+ expires->key.len = sizeof("Expires") - 1;
634
+ expires->key.data = (u_char *) "Expires";
635
+ }
636
+
637
+ len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
638
+ expires->value.len = len - 1;
639
+
640
+ ccp = r->headers_out.cache_control.elts;
641
+ if (ccp == NULL) {
642
+
643
+ if (ngx_array_init(&r->headers_out.cache_control, r->pool,
644
+ 1, sizeof(ngx_table_elt_t *))
645
+ != NGX_OK) {
646
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
647
+ }
648
+
649
+ ccp = ngx_array_push(&r->headers_out.cache_control);
650
+ if (ccp == NULL) {
651
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
652
+ }
653
+
654
+ cc = ngx_list_push(&r->headers_out.headers);
655
+ if (cc == NULL) {
656
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
657
+ }
658
+
659
+ cc->hash = 1;
660
+ cc->key.len = sizeof("Cache-Control") - 1;
661
+ cc->key.data = (u_char *) "Cache-Control";
662
+
663
+ *ccp = cc;
664
+
665
+ } else {
666
+ for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
667
+ ccp[i]->hash = 0;
668
+ }
669
+
670
+ cc = ccp[0];
671
+ }
672
+
673
+ expires->value.data = (u_char *) "Thu, 01 Jan 1970 00:00:01 GMT";
674
+
675
+ cc->value.len = sizeof("no-cache") - 1;
676
+ cc->value.data = (u_char *) "no-cache";
677
+
678
+
679
+ if (r->method == NGX_HTTP_HEAD) {
680
+ r->headers_out.status = NGX_HTTP_OK;
681
+
682
+ rc = ngx_http_send_header(r);
683
+
684
+ if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
685
+ return rc;
686
+ }
687
+ }
688
+
689
+ ngx_http_set_ctx(r, up, ngx_http_uploadprogress_module);
690
+
691
+ /*
692
+ There are 4 possibilities
693
+ * request not yet started: found = false
694
+ * request in error: err_status >= NGX_HTTP_BAD_REQUEST
695
+ * request finished: done = true
696
+ * request not yet started but registered: length==0 && rest ==0
697
+ * reauest in progress: rest > 0
698
+ */
699
+
700
+ if (!found) {
701
+ state = uploadprogress_state_starting;
702
+ } else if (err_status >= NGX_HTTP_BAD_REQUEST) {
703
+ state = uploadprogress_state_error;
704
+ } else if (done) {
705
+ state = uploadprogress_state_done;
706
+ } else if ( length == 0 && rest == 0 ) {
707
+ state = uploadprogress_state_starting;
708
+ } else {
709
+ state = uploadprogress_state_uploading;
710
+ }
711
+
712
+ t = upcf->templates.elts;
713
+
714
+ if (ngx_http_script_run(r, &response, t[(ngx_uint_t)state].lengths->elts, 0,
715
+ t[(ngx_uint_t)state].values->elts) == NULL)
716
+ {
717
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
718
+ }
719
+
720
+ ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
721
+ "upload progress: state=%d, err_status=%ui, remaining=%uO, length=%uO",
722
+ state, err_status, (length - rest), length);
723
+
724
+ b = ngx_calloc_buf(r->pool);
725
+ if (b == NULL) {
726
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
727
+ }
728
+
729
+ b->pos = b->start = response.data;
730
+ b->last = b->end = response.data + response.len;
731
+
732
+ b->temporary = 1;
733
+ b->memory = 1;
734
+
735
+ out.buf = b;
736
+ out.next = NULL;
737
+
738
+ r->headers_out.status = NGX_HTTP_OK;
739
+ r->headers_out.content_length_n = b->last - b->pos;
740
+
741
+ b->last_buf = 1;
742
+ rc = ngx_http_send_header(r);
743
+
744
+ if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
745
+ return rc;
746
+ }
747
+
748
+ return ngx_http_output_filter(r, &out);
749
+ }
750
+
751
+ /*
752
+ Let's register the upload connection in our connections rb-tree
753
+ */
754
+ static ngx_int_t
755
+ ngx_http_uploadprogress_handler(ngx_http_request_t * r)
756
+ {
757
+ size_t n;
758
+ ngx_str_t *id;
759
+ uint32_t hash;
760
+ ngx_slab_pool_t *shpool;
761
+ ngx_rbtree_node_t *node;
762
+ ngx_http_uploadprogress_conf_t *upcf;
763
+ ngx_http_uploadprogress_ctx_t *ctx;
764
+ ngx_http_uploadprogress_node_t *up;
765
+ ngx_http_uploadprogress_cleanup_t *upcln;
766
+ ngx_pool_cleanup_t *cln;
767
+
768
+ /* Is it a POST connection */
769
+ if (r->method != NGX_HTTP_POST) {
770
+ return NGX_DECLINED;
771
+ }
772
+
773
+ id = get_tracking_id(r);
774
+ if (id == NULL) {
775
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
776
+ "trackuploads no id found in POST upload req");
777
+ return NGX_DECLINED;
778
+ }
779
+
780
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
781
+ "trackuploads id found: %V", id);
782
+
783
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
784
+
785
+ if (!upcf->track) {
786
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
787
+ "trackuploads not tracking in this location for id: %V", id);
788
+ ngx_free(id);
789
+ return NGX_DECLINED;
790
+ }
791
+
792
+ if (upcf->shm_zone == NULL) {
793
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
794
+ "trackuploads no shm_zone for id: %V", id);
795
+ ngx_free(id);
796
+ return NGX_DECLINED;
797
+ }
798
+
799
+ ctx = upcf->shm_zone->data;
800
+
801
+ hash = ngx_crc32_short(id->data, id->len);
802
+
803
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
804
+ "trackuploads hash %08XD for id: %V", hash, id);
805
+
806
+ shpool = (ngx_slab_pool_t *) upcf->shm_zone->shm.addr;
807
+
808
+ ngx_shmtx_lock(&shpool->mutex);
809
+
810
+ if (find_node(id, ctx, r->connection->log) != NULL) {
811
+ ngx_shmtx_unlock(&shpool->mutex);
812
+ /* already found a node with matching progress ID */
813
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
814
+ "upload_progress: tracking already registered id: %V", id);
815
+
816
+ ngx_free(id);
817
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
818
+ }
819
+
820
+ cln = ngx_pool_cleanup_add(r->pool, sizeof(ngx_http_uploadprogress_cleanup_t));
821
+ if (cln == NULL) {
822
+ ngx_shmtx_unlock(&shpool->mutex);
823
+ ngx_free(id);
824
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
825
+ }
826
+
827
+ n = sizeof(ngx_http_uploadprogress_node_t)
828
+ + id->len;
829
+
830
+ node = ngx_slab_alloc_locked(shpool, n);
831
+ if (node == NULL) {
832
+ ngx_shmtx_unlock(&shpool->mutex);
833
+ ngx_free(id);
834
+ return NGX_HTTP_SERVICE_UNAVAILABLE;
835
+ }
836
+
837
+ up = (ngx_http_uploadprogress_node_t *) node;
838
+
839
+ node->key = hash;
840
+ up->len = (u_char) id->len;
841
+ up->err_status = r->err_status;
842
+ up->done = 0;
843
+ up->rest = 0;
844
+ up->length = 0;
845
+ up->timeout = 0;
846
+
847
+ /* Properly handles small files where no read events happen after the */
848
+ /* request is first handled (apparently this can happen on linux with epoll) */
849
+ if (r->headers_in.content_length_n) {
850
+ up->length = r->headers_in.content_length_n;
851
+ if (r->request_body) {
852
+ up->rest = r->request_body->rest;
853
+ }
854
+ }
855
+
856
+ up->next = ctx->list_head.next;
857
+ up->next->prev = up;
858
+ up->prev = &ctx->list_head;
859
+ ctx->list_head.next = up;
860
+
861
+ ngx_memcpy(up->data, id->data, id->len);
862
+
863
+ ngx_rbtree_insert(ctx->rbtree, node);
864
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
865
+ "trackuploads: %08XD inserted in rbtree", node->key);
866
+
867
+ if (!upcf->cleanup.timer_set) {
868
+ upcf->cleanup.data = upcf->shm_zone;
869
+ upcf->cleanup.handler = ngx_clean_old_connections;
870
+ upcf->cleanup.log = upcf->shm_zone->shm.log;
871
+ ngx_add_timer(&upcf->cleanup, TIMER_FREQUENCY);
872
+ }
873
+
874
+ ngx_shmtx_unlock(&shpool->mutex);
875
+
876
+ cln->handler = ngx_http_uploadprogress_cleanup;
877
+ upcln = cln->data;
878
+
879
+ upcln->shm_zone = upcf->shm_zone;
880
+ upcln->node = node;
881
+ upcln->timeout = upcf->timeout;
882
+ upcln->r = r;
883
+
884
+ ngx_free(id);
885
+
886
+ ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_uploadprogress_module_ctx_t));
887
+ if (ctx == NULL) {
888
+ return NGX_ERROR;
889
+ }
890
+
891
+ ngx_http_set_ctx(r, ctx, ngx_http_uploadprogress_module);
892
+
893
+ /* finally says to the core we don't handle anything */
894
+ return NGX_DECLINED;
895
+ }
896
+
897
+ static void
898
+ ngx_http_uploadprogress_rbtree_insert_value(ngx_rbtree_node_t * temp,
899
+ ngx_rbtree_node_t * node,
900
+ ngx_rbtree_node_t * sentinel)
901
+ {
902
+ ngx_http_uploadprogress_node_t *upn, *upnt;
903
+
904
+ for (;;) {
905
+
906
+ if (node->key < temp->key) {
907
+
908
+ if (temp->left == sentinel) {
909
+ temp->left = node;
910
+ break;
911
+ }
912
+
913
+ temp = temp->left;
914
+
915
+ } else if (node->key > temp->key) {
916
+
917
+ if (temp->right == sentinel) {
918
+ temp->right = node;
919
+ break;
920
+ }
921
+
922
+ temp = temp->right;
923
+
924
+ } else { /* node->key == temp->key */
925
+
926
+ upn = (ngx_http_uploadprogress_node_t *) node;
927
+ upnt = (ngx_http_uploadprogress_node_t *) temp;
928
+
929
+ if (ngx_memn2cmp(upn->data, upnt->data, upn->len, upnt->len) < 0) {
930
+
931
+ if (temp->left == sentinel) {
932
+ temp->left = node;
933
+ break;
934
+ }
935
+
936
+ temp = temp->left;
937
+
938
+ } else {
939
+
940
+ if (temp->right == sentinel) {
941
+ temp->right = node;
942
+ break;
943
+ }
944
+
945
+ temp = temp->right;
946
+ }
947
+ }
948
+ }
949
+
950
+ node->parent = temp;
951
+ node->left = sentinel;
952
+ node->right = sentinel;
953
+ ngx_rbt_red(node);
954
+ }
955
+
956
+
957
+ static void
958
+ ngx_clean_old_connections(ngx_event_t * ev)
959
+ {
960
+ ngx_shm_zone_t *shm_zone;
961
+ ngx_http_uploadprogress_ctx_t *ctx;
962
+ ngx_slab_pool_t *shpool;
963
+ ngx_rbtree_node_t *node;
964
+ ngx_http_uploadprogress_node_t *up, *upprev;
965
+ time_t now = ngx_time();
966
+ int count = 0;
967
+
968
+
969
+ /* scan the rbtree */
970
+ shm_zone = ev->data;
971
+ ctx = shm_zone->data;
972
+ shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
973
+
974
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
975
+ "uploadprogress clean old connections at %T", now);
976
+
977
+ ngx_shmtx_lock(&shpool->mutex);
978
+ node = (ngx_rbtree_node_t *) ctx->list_tail.prev;
979
+ for (;;) {
980
+
981
+
982
+ if (node == &ctx->list_head.node) {
983
+ break;
984
+ }
985
+
986
+ up = (ngx_http_uploadprogress_node_t *) node;
987
+ upprev = up->prev;
988
+
989
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
990
+ "uploadprogress clean: scanning %08XD (req done %ui) timeout at %T",
991
+ node->key, up->done, up->timeout);
992
+
993
+ if ( (up->done && up->timeout < now) || (ngx_quit || ngx_terminate || ngx_exiting) ) {
994
+ up->next->prev = up->prev;
995
+ up->prev->next = up->next;
996
+
997
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
998
+ "uploadprogress clean: removing %08XD (req %ui) ",
999
+ node->key, up->done, up->timeout);
1000
+
1001
+ ngx_rbtree_delete(ctx->rbtree, node);
1002
+ ngx_slab_free_locked(shpool, node);
1003
+ }
1004
+ else
1005
+ count++;
1006
+ node = (ngx_rbtree_node_t *) upprev;
1007
+ }
1008
+
1009
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
1010
+ "uploadprogress clean old connections: quit: %ui term: %ui count: %ui", ngx_quit, ngx_terminate, count);
1011
+
1012
+ /* don't reschedule timer if ngx_quit or ngx_terminate && nodes emtpy */
1013
+ if ( count > 0 || !(ngx_quit || ngx_terminate || ngx_exiting)) {
1014
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
1015
+ "uploadprogress clean old connections restarting timer");
1016
+ ngx_add_timer(ev, TIMER_FREQUENCY); /* trigger again in 60s */
1017
+ } else if (ngx_quit || ngx_terminate || ngx_exiting) {
1018
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, shm_zone->shm.log, 0,
1019
+ "uploadprogress clean old connections quitting , no more active connections: not restarting timer");
1020
+ }
1021
+ ngx_shmtx_unlock(&shpool->mutex);
1022
+ }
1023
+
1024
+
1025
+
1026
+ /*
1027
+ removes the expired node from the upload rbtree
1028
+ */
1029
+ static void
1030
+ ngx_http_uploadprogress_cleanup(void *data)
1031
+ {
1032
+ ngx_http_uploadprogress_cleanup_t *upcln = data;
1033
+ ngx_slab_pool_t *shpool;
1034
+ ngx_rbtree_node_t *node;
1035
+ ngx_http_uploadprogress_node_t *up;
1036
+ ngx_http_request_t *r;
1037
+
1038
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, upcln->shm_zone->shm.log, 0,
1039
+ "uploadprogress cleanup called");
1040
+
1041
+ shpool = (ngx_slab_pool_t *) upcln->shm_zone->shm.addr;
1042
+ node = upcln->node;
1043
+ r = upcln->r;
1044
+ up = (ngx_http_uploadprogress_node_t *) node;
1045
+
1046
+ ngx_shmtx_lock(&shpool->mutex);
1047
+
1048
+ up->done = 1; /* mark the original request as done */
1049
+ up->timeout = ngx_time() + upcln->timeout; /* keep tracking for 60s */
1050
+
1051
+ if (r != NULL ) {
1052
+ ngx_uint_t rc = r->err_status ? r->err_status : r->headers_out.status;
1053
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
1054
+ up->err_status = rc;
1055
+ }
1056
+ }
1057
+
1058
+ ngx_shmtx_unlock(&shpool->mutex);
1059
+
1060
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, upcln->shm_zone->shm.log, 0,
1061
+ "uploadprogress cleanup: connection %08XD to be deleted at %T",
1062
+ node->key, up->timeout);
1063
+
1064
+ }
1065
+
1066
+ static ngx_int_t
1067
+ ngx_http_uploadprogress_init_zone(ngx_shm_zone_t * shm_zone, void *data)
1068
+ {
1069
+ ngx_http_uploadprogress_ctx_t *octx = data;
1070
+
1071
+ ngx_slab_pool_t *shpool;
1072
+ ngx_rbtree_node_t *sentinel;
1073
+ ngx_http_uploadprogress_ctx_t *ctx;
1074
+
1075
+ ctx = shm_zone->data;
1076
+
1077
+ if (octx) {
1078
+ ctx->rbtree = octx->rbtree;
1079
+ return NGX_OK;
1080
+ }
1081
+
1082
+ shpool = (ngx_slab_pool_t *) shm_zone->shm.addr;
1083
+
1084
+ ctx->rbtree = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_t));
1085
+ if (ctx->rbtree == NULL) {
1086
+ return NGX_ERROR;
1087
+ }
1088
+
1089
+ sentinel = ngx_slab_alloc(shpool, sizeof(ngx_rbtree_node_t));
1090
+ if (sentinel == NULL) {
1091
+ return NGX_ERROR;
1092
+ }
1093
+
1094
+ ngx_rbtree_sentinel_init(sentinel);
1095
+
1096
+ ctx->rbtree->root = sentinel;
1097
+ ctx->rbtree->sentinel = sentinel;
1098
+ ctx->rbtree->insert = ngx_http_uploadprogress_rbtree_insert_value;
1099
+
1100
+ return NGX_OK;
1101
+ }
1102
+
1103
+ static ngx_int_t
1104
+ ngx_http_uploadprogress_errortracker(ngx_http_request_t * r)
1105
+ {
1106
+ size_t n;
1107
+ ngx_str_t *id;
1108
+ ngx_slab_pool_t *shpool;
1109
+ ngx_rbtree_node_t *node;
1110
+ ngx_http_uploadprogress_ctx_t *ctx;
1111
+ ngx_http_uploadprogress_node_t *up;
1112
+ ngx_http_uploadprogress_conf_t *upcf;
1113
+ uint32_t hash;
1114
+ ngx_http_uploadprogress_cleanup_t *upcln;
1115
+ ngx_pool_cleanup_t *cln;
1116
+
1117
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1118
+ "uploadprogress error-tracker error: %D", r->err_status);
1119
+ if (r->err_status >= NGX_HTTP_SPECIAL_RESPONSE) {
1120
+
1121
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
1122
+
1123
+ if (!upcf->track) {
1124
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1125
+ "uploadprogress error-tracker not tracking in this location");
1126
+ goto finish;
1127
+ }
1128
+
1129
+ id = get_tracking_id(r);
1130
+ if (id == NULL) {
1131
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1132
+ "trackuploads error-tracker no id found in POST upload req");
1133
+ goto finish;
1134
+ }
1135
+
1136
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1137
+ "trackuploads error-tracker id found: %V", id);
1138
+
1139
+
1140
+ if (upcf->shm_zone == NULL) {
1141
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1142
+ "trackuploads no shm_zone for id: %V", id);
1143
+ ngx_free(id);
1144
+ goto finish;
1145
+ }
1146
+
1147
+ ctx = upcf->shm_zone->data;
1148
+
1149
+ hash = ngx_crc32_short(id->data, id->len);
1150
+
1151
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1152
+ "trackuploads error-tracking hash %08XD for id: %V", hash,
1153
+ id);
1154
+
1155
+ shpool = (ngx_slab_pool_t *) upcf->shm_zone->shm.addr;
1156
+
1157
+ ngx_shmtx_lock(&shpool->mutex);
1158
+
1159
+ if ((up = find_node(id, ctx, r->connection->log)) != NULL) {
1160
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1161
+ "trackuploads error-tracking found node for id: %V", id);
1162
+ up->err_status = r->err_status;
1163
+ ngx_shmtx_unlock(&shpool->mutex);
1164
+ ngx_free(id);
1165
+ goto finish;
1166
+ }
1167
+
1168
+ /* no lz found for this tracking id */
1169
+ n = sizeof(ngx_http_uploadprogress_node_t) + id->len;
1170
+
1171
+ cln = ngx_pool_cleanup_add(r->pool, sizeof(ngx_http_uploadprogress_cleanup_t));
1172
+ if (cln == NULL) {
1173
+ ngx_shmtx_unlock(&shpool->mutex);
1174
+ ngx_free(id);
1175
+ goto finish;
1176
+ }
1177
+
1178
+
1179
+ node = ngx_slab_alloc_locked(shpool, n);
1180
+ if (node == NULL) {
1181
+ ngx_shmtx_unlock(&shpool->mutex);
1182
+ ngx_free(id);
1183
+ goto finish;
1184
+ }
1185
+
1186
+ up = (ngx_http_uploadprogress_node_t *) node;
1187
+
1188
+ node->key = hash;
1189
+ up->len = (u_char) id->len;
1190
+ up->err_status = r->err_status;
1191
+ up->done = 0;
1192
+ up->rest = 0;
1193
+ up->length = 0;
1194
+ up->timeout = 0;
1195
+
1196
+ ngx_memcpy(up->data, id->data, id->len);
1197
+
1198
+ up->next = ctx->list_head.next;
1199
+ up->next->prev = up;
1200
+ up->prev = &ctx->list_head;
1201
+ ctx->list_head.next = up;
1202
+
1203
+ ngx_rbtree_insert(ctx->rbtree, node);
1204
+
1205
+ /* start the timer if needed */
1206
+ if (!upcf->cleanup.timer_set) {
1207
+ upcf->cleanup.data = upcf->shm_zone;
1208
+ upcf->cleanup.handler = ngx_clean_old_connections;
1209
+ upcf->cleanup.log = upcf->shm_zone->shm.log;
1210
+ ngx_add_timer(&upcf->cleanup, TIMER_FREQUENCY);
1211
+ }
1212
+
1213
+ ngx_shmtx_unlock(&shpool->mutex);
1214
+
1215
+ cln->handler = ngx_http_uploadprogress_cleanup;
1216
+ upcln = cln->data;
1217
+ upcln->shm_zone = upcf->shm_zone;
1218
+ upcln->node = node;
1219
+ upcln->timeout = upcf->timeout;
1220
+ upcln->r = r;
1221
+
1222
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1223
+ "trackuploads error-tracking adding: %08XD", node->key);
1224
+ ngx_free(id);
1225
+ }
1226
+
1227
+ finish:
1228
+ /* call the filter chain as usual */
1229
+ return ngx_http_next_header_filter(r);
1230
+ }
1231
+
1232
+
1233
+ static ngx_int_t
1234
+ ngx_http_uploadprogress_init(ngx_conf_t * cf)
1235
+ {
1236
+ ngx_http_handler_pt *h;
1237
+ ngx_http_core_main_conf_t *cmcf;
1238
+
1239
+ cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
1240
+
1241
+ /* install the tracking handler */
1242
+ h = ngx_array_push(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
1243
+ if (h == NULL) {
1244
+ return NGX_ERROR;
1245
+ }
1246
+
1247
+ *h = ngx_http_uploadprogress_handler;
1248
+
1249
+ /*
1250
+ we also need to track HTTP errors
1251
+ unfortunately, the above handler is not called in case of
1252
+ errors.
1253
+ we have to register a header output filter that will be
1254
+ called in any case to track those errors
1255
+ */
1256
+ ngx_http_next_header_filter = ngx_http_top_header_filter;
1257
+ ngx_http_top_header_filter = ngx_http_uploadprogress_errortracker;
1258
+
1259
+ return NGX_OK;
1260
+ }
1261
+
1262
+ static void*
1263
+ ngx_http_uploadprogress_create_loc_conf(ngx_conf_t * cf)
1264
+ {
1265
+ ngx_http_uploadprogress_conf_t *conf;
1266
+ ngx_uint_t i;
1267
+
1268
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_uploadprogress_conf_t));
1269
+ if (conf == NULL) {
1270
+ return NGX_CONF_ERROR;
1271
+ }
1272
+
1273
+ if(ngx_array_init(&conf->templates, cf->pool, 4, sizeof(ngx_http_uploadprogress_template_t)) != NGX_OK) {
1274
+ return NGX_CONF_ERROR;
1275
+ }
1276
+
1277
+ for(i = 0;i < conf->templates.nalloc; i++) {
1278
+ ngx_http_uploadprogress_template_t *elt = ngx_array_push(&conf->templates);
1279
+ if (elt == NULL) {
1280
+ return NGX_CONF_ERROR;
1281
+ }
1282
+
1283
+ elt->values = NULL;
1284
+ elt->lengths = NULL;
1285
+ }
1286
+
1287
+ return conf;
1288
+ }
1289
+
1290
+
1291
+ static char*
1292
+ ngx_http_uploadprogress_merge_loc_conf(ngx_conf_t * cf, void *parent, void *child)
1293
+ {
1294
+ ngx_http_uploadprogress_conf_t *prev = parent;
1295
+ ngx_http_uploadprogress_conf_t *conf = child;
1296
+ ngx_http_uploadprogress_template_t *t, *pt, *gt;
1297
+ ngx_uint_t i;
1298
+
1299
+ if (conf->shm_zone == NULL) {
1300
+ conf->shm_zone = prev->shm_zone;
1301
+ conf->timeout = prev->timeout;
1302
+ conf->cleanup = prev->cleanup;
1303
+ conf->handler = prev->handler;
1304
+ conf->track = prev->track;
1305
+ }
1306
+
1307
+ ngx_conf_merge_str_value(conf->content_type, prev->content_type, "text/javascript");
1308
+
1309
+ t = conf->templates.elts;
1310
+ pt = prev->templates.elts;
1311
+ gt = ngx_http_uploadprogress_global_templates.elts;
1312
+
1313
+ for(i = 0;i < conf->templates.nelts; i++) {
1314
+ if(t[i].values == NULL) {
1315
+ if(pt[i].values == NULL && gt != NULL) {
1316
+ t[i].values = gt[i].values;
1317
+ t[i].lengths = gt[i].lengths;
1318
+ }
1319
+ else {
1320
+ t[i].values = pt[i].values;
1321
+ t[i].lengths = pt[i].lengths;
1322
+ }
1323
+ }
1324
+ }
1325
+
1326
+ ngx_conf_merge_str_value(conf->header, prev->header, "X-Progress-ID");
1327
+ ngx_conf_merge_str_value(conf->jsonp_parameter, prev->jsonp_parameter, "callback");
1328
+
1329
+ return NGX_CONF_OK;
1330
+ }
1331
+
1332
+ static ngx_int_t
1333
+ ngx_http_uploadprogress_init_variables_and_templates(ngx_conf_t *cf)
1334
+ {
1335
+ ngx_http_variable_t *var, *v;
1336
+ ngx_http_uploadprogress_state_map_t *m;
1337
+ ngx_uint_t i;
1338
+
1339
+ /* Add variables */
1340
+ for (v = ngx_http_uploadprogress_variables; v->name.len; v++) {
1341
+ var = ngx_http_add_variable(cf, &v->name, v->flags);
1342
+ if (var == NULL) {
1343
+ return NGX_ERROR;
1344
+ }
1345
+
1346
+ var->get_handler = v->get_handler;
1347
+ var->data = v->data;
1348
+ }
1349
+
1350
+ /* Compile global templates (containing Javascript output) */
1351
+ if(ngx_array_init(&ngx_http_uploadprogress_global_templates, cf->pool, 4,
1352
+ sizeof(ngx_http_uploadprogress_template_t)) != NGX_OK) {
1353
+ return NGX_ERROR;
1354
+ }
1355
+
1356
+ m = ngx_http_uploadprogress_state_map;
1357
+ i = 0;
1358
+
1359
+ while(m->name.data != NULL) {
1360
+ ngx_http_uploadprogress_template_t *elt = ngx_array_push(&ngx_http_uploadprogress_global_templates);
1361
+ ngx_http_script_variables_count(ngx_http_uploadprogress_jsonp_defaults + i);
1362
+
1363
+ if (ngx_http_upload_progress_set_template(cf, elt, ngx_http_uploadprogress_jsonp_defaults + i) != NGX_CONF_OK) {
1364
+ return NGX_ERROR;
1365
+ }
1366
+
1367
+ m++;
1368
+ i++;
1369
+ }
1370
+
1371
+
1372
+ return NGX_OK;
1373
+ }
1374
+
1375
+ static char*
1376
+ ngx_http_upload_progress(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1377
+ {
1378
+ ssize_t n;
1379
+ ngx_str_t *value;
1380
+ ngx_shm_zone_t *shm_zone;
1381
+ ngx_http_uploadprogress_ctx_t *ctx;
1382
+
1383
+ value = cf->args->elts;
1384
+
1385
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1386
+ "ngx_upload_progress name: %V", &value[1]);
1387
+
1388
+ ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_uploadprogress_ctx_t));
1389
+ if (ctx == NULL) {
1390
+ return NGX_CONF_ERROR;
1391
+ }
1392
+
1393
+ ctx->list_head.prev = NULL;
1394
+ ctx->list_head.next = &ctx->list_tail;
1395
+
1396
+ ctx->list_tail.prev = &ctx->list_head;
1397
+ ctx->list_tail.next = NULL;
1398
+
1399
+ n = ngx_parse_size(&value[2]);
1400
+
1401
+ if (n == NGX_ERROR) {
1402
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1403
+ "invalid size of track_uploads \"%V\"", &value[2]);
1404
+ return NGX_CONF_ERROR;
1405
+ }
1406
+
1407
+ if (n < (ngx_int_t) (8 * ngx_pagesize)) {
1408
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1409
+ "track_uploads \"%V\" is too small", &value[1]);
1410
+ return NGX_CONF_ERROR;
1411
+ }
1412
+
1413
+ shm_zone = ngx_shared_memory_add(cf, &value[1], n,
1414
+ &ngx_http_uploadprogress_module);
1415
+ if (shm_zone == NULL) {
1416
+ return NGX_CONF_ERROR;
1417
+ }
1418
+
1419
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1420
+ "ngx_upload_progress name: %V, szhm_zone: %p", &value[1],
1421
+ shm_zone);
1422
+
1423
+ if (shm_zone->data) {
1424
+ ctx = shm_zone->data;
1425
+
1426
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1427
+ "track_uploads \"%V\" is already created", &value[1]);
1428
+ return NGX_CONF_ERROR;
1429
+ }
1430
+
1431
+ shm_zone->init = ngx_http_uploadprogress_init_zone;
1432
+ shm_zone->data = ctx;
1433
+
1434
+ return NGX_CONF_OK;
1435
+ }
1436
+
1437
+
1438
+
1439
+ static char*
1440
+ ngx_http_track_uploads(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1441
+ {
1442
+ ngx_http_core_loc_conf_t *clcf;
1443
+ ngx_http_uploadprogress_conf_t *lzcf = conf;
1444
+ ngx_str_t *value;
1445
+
1446
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, "ngx_track_uploads in");
1447
+
1448
+ value = cf->args->elts;
1449
+
1450
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1451
+ "ngx_track_uploads name: %V", &value[1]);
1452
+
1453
+ lzcf->shm_zone = ngx_shared_memory_add(cf, &value[1], 0,
1454
+ &ngx_http_uploadprogress_module);
1455
+ if (lzcf->shm_zone == NULL) {
1456
+ return NGX_CONF_ERROR;
1457
+ }
1458
+
1459
+ lzcf->track = (u_char) 1;
1460
+
1461
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1462
+ "ngx_track_uploads name: %V,szhm_zone: %p", &value[1],
1463
+ lzcf->shm_zone);
1464
+
1465
+
1466
+ lzcf->timeout = ngx_parse_time(&value[2], 1);
1467
+ if (lzcf->timeout == NGX_ERROR) {
1468
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1469
+ "track_uploads \"%V\" timeout value invalid", &value[1]);
1470
+ return NGX_CONF_ERROR;
1471
+ }
1472
+
1473
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1474
+ lzcf->handler = clcf->handler;
1475
+ if ( lzcf->handler == NULL )
1476
+ {
1477
+ return "track_upload should be the last directive in the location, after either proxy_pass or fastcgi_pass";
1478
+ }
1479
+ clcf->handler = ngx_http_uploadprogress_content_handler;
1480
+ return NGX_CONF_OK;
1481
+ }
1482
+
1483
+
1484
+ static char*
1485
+ ngx_http_report_uploads(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1486
+ {
1487
+ ngx_http_uploadprogress_conf_t *lzcf = conf;
1488
+ ngx_http_core_loc_conf_t *clcf;
1489
+ ngx_str_t *value;
1490
+
1491
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, "ngx_report_uploads in");
1492
+
1493
+ value = cf->args->elts;
1494
+
1495
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1496
+ "ngx_report_uploads name: %V", &value[1]);
1497
+
1498
+ lzcf->shm_zone = ngx_shared_memory_add(cf, &value[1], 0,
1499
+ &ngx_http_uploadprogress_module);
1500
+ if (lzcf->shm_zone == NULL) {
1501
+ return NGX_CONF_ERROR;
1502
+ }
1503
+
1504
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
1505
+ "ngx_report_uploads name: %V, szhm_zone: %p", &value[1],
1506
+ lzcf->shm_zone);
1507
+
1508
+ lzcf->track = (u_char) 0;
1509
+
1510
+ /* install our report handler */
1511
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
1512
+ clcf->handler = ngx_http_reportuploads_handler;
1513
+
1514
+ return NGX_CONF_OK;
1515
+ }
1516
+
1517
+ static char*
1518
+ ngx_http_upload_progress_set_template(ngx_conf_t * cf, ngx_http_uploadprogress_template_t *t, ngx_str_t *source)
1519
+ {
1520
+ ssize_t n;
1521
+ ngx_http_script_compile_t sc;
1522
+
1523
+ n = ngx_http_script_variables_count(source);
1524
+
1525
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
1526
+
1527
+ t->lengths = NULL;
1528
+ t->values = NULL;
1529
+
1530
+ sc.cf = cf;
1531
+ sc.source = source;
1532
+ sc.lengths = &t->lengths;
1533
+ sc.values = &t->values;
1534
+ sc.variables = n;
1535
+ sc.complete_lengths = 1;
1536
+ sc.complete_values = 1;
1537
+
1538
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
1539
+ return NGX_CONF_ERROR;
1540
+ }
1541
+
1542
+ return NGX_CONF_OK;
1543
+ }
1544
+
1545
+ static char*
1546
+ ngx_http_upload_progress_template(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1547
+ {
1548
+ ngx_http_uploadprogress_conf_t *upcf = conf;
1549
+ ngx_str_t *value;
1550
+ ngx_http_uploadprogress_state_map_t *m = ngx_http_uploadprogress_state_map;
1551
+ ngx_http_uploadprogress_template_t *t;
1552
+
1553
+ value = cf->args->elts;
1554
+
1555
+ while(m->name.data != NULL) {
1556
+ if((value[1].len == m->name.len && !ngx_strncmp(value[1].data, m->name.data, m->name.len))
1557
+ || (value[1].len == 2 && !ngx_strncmp(value[1].data, m->name.data, 2))) {
1558
+ break;
1559
+ }
1560
+ m++;
1561
+ }
1562
+
1563
+ if (m->name.data == NULL) {
1564
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1565
+ "unknown state \"%V\"", &value[1]);
1566
+ return NGX_CONF_ERROR;
1567
+ }
1568
+
1569
+ t = (ngx_http_uploadprogress_template_t*)upcf->templates.elts + (ngx_uint_t)m->idx;
1570
+
1571
+ return ngx_http_upload_progress_set_template(cf, t, &value[2]);
1572
+ }
1573
+
1574
+ static char*
1575
+ ngx_http_upload_progress_java_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1576
+ {
1577
+ ngx_http_uploadprogress_conf_t *upcf = conf;
1578
+ ngx_http_uploadprogress_template_t *t;
1579
+ ngx_uint_t i;
1580
+ char* rc;
1581
+
1582
+ t = (ngx_http_uploadprogress_template_t*)upcf->templates.elts;
1583
+
1584
+ for(i = 0;i < upcf->templates.nelts;i++) {
1585
+ rc = ngx_http_upload_progress_set_template(cf, t + i, ngx_http_uploadprogress_java_defaults + i);
1586
+
1587
+ if(rc != NGX_CONF_OK) {
1588
+ return rc;
1589
+ }
1590
+ }
1591
+
1592
+ upcf->content_type.data = (u_char*)"text/javascript";
1593
+ upcf->content_type.len = sizeof("text/javascript") - 1;
1594
+
1595
+ return NGX_CONF_OK;
1596
+ }
1597
+
1598
+ static char*
1599
+ ngx_http_upload_progress_json_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1600
+ {
1601
+ ngx_http_uploadprogress_conf_t *upcf = conf;
1602
+ ngx_http_uploadprogress_template_t *t;
1603
+ ngx_uint_t i;
1604
+ char* rc;
1605
+
1606
+ t = (ngx_http_uploadprogress_template_t*)upcf->templates.elts;
1607
+
1608
+ for(i = 0;i < upcf->templates.nelts;i++) {
1609
+ rc = ngx_http_upload_progress_set_template(cf, t + i, ngx_http_uploadprogress_json_defaults + i);
1610
+
1611
+ if(rc != NGX_CONF_OK) {
1612
+ return rc;
1613
+ }
1614
+ }
1615
+
1616
+ upcf->content_type.data = (u_char*)"application/json";
1617
+ upcf->content_type.len = sizeof("application/json") - 1;
1618
+
1619
+ return NGX_CONF_OK;
1620
+ }
1621
+
1622
+ static char*
1623
+ ngx_http_upload_progress_jsonp_output(ngx_conf_t * cf, ngx_command_t * cmd, void *conf)
1624
+ {
1625
+ ngx_http_uploadprogress_conf_t *upcf = conf;
1626
+ ngx_http_uploadprogress_template_t *t;
1627
+ ngx_uint_t i;
1628
+ char* rc;
1629
+
1630
+ t = (ngx_http_uploadprogress_template_t*)upcf->templates.elts;
1631
+
1632
+ for(i = 0;i < upcf->templates.nelts;i++) {
1633
+ rc = ngx_http_upload_progress_set_template(cf, t + i, ngx_http_uploadprogress_jsonp_defaults + i);
1634
+
1635
+ if(rc != NGX_CONF_OK) {
1636
+ return rc;
1637
+ }
1638
+ }
1639
+
1640
+ upcf->content_type.data = (u_char*)"application/javascript";
1641
+ upcf->content_type.len = sizeof("application/javascript") - 1;
1642
+
1643
+ return NGX_CONF_OK;
1644
+ }
1645
+
1646
+ static ngx_int_t ngx_http_uploadprogress_received_variable(ngx_http_request_t *r,
1647
+ ngx_http_variable_value_t *v, uintptr_t data)
1648
+ {
1649
+ ngx_http_uploadprogress_node_t *up;
1650
+ u_char *p;
1651
+ off_t *value;
1652
+
1653
+ up = ngx_http_get_module_ctx(r, ngx_http_uploadprogress_module);
1654
+
1655
+ value = (off_t *) ((char *) up + data);
1656
+
1657
+ p = ngx_palloc(r->pool, NGX_OFF_T_LEN);
1658
+ if (p == NULL) {
1659
+ return NGX_ERROR;
1660
+ }
1661
+
1662
+ v->len = ngx_sprintf(p, "%O", up->length - *value) - p;
1663
+ v->valid = 1;
1664
+ v->no_cacheable = 0;
1665
+ v->not_found = 0;
1666
+ v->data = p;
1667
+
1668
+ return NGX_OK;
1669
+ }
1670
+
1671
+ static ngx_int_t ngx_http_uploadprogress_offset_variable(ngx_http_request_t *r,
1672
+ ngx_http_variable_value_t *v, uintptr_t data)
1673
+ {
1674
+ ngx_http_uploadprogress_node_t *up;
1675
+ u_char *p;
1676
+ off_t *value;
1677
+
1678
+ up = ngx_http_get_module_ctx(r, ngx_http_uploadprogress_module);
1679
+
1680
+ value = (off_t *) ((char *) up + data);
1681
+
1682
+ p = ngx_palloc(r->pool, NGX_OFF_T_LEN);
1683
+ if (p == NULL) {
1684
+ return NGX_ERROR;
1685
+ }
1686
+
1687
+ v->len = ngx_sprintf(p, "%O", *value) - p;
1688
+ v->valid = 1;
1689
+ v->no_cacheable = 0;
1690
+ v->not_found = 0;
1691
+ v->data = p;
1692
+
1693
+ return NGX_OK;
1694
+ }
1695
+
1696
+ static ngx_int_t
1697
+ ngx_http_uploadprogress_status_variable(ngx_http_request_t *r,
1698
+ ngx_http_variable_value_t *v, uintptr_t data)
1699
+ {
1700
+ ngx_http_uploadprogress_node_t *up;
1701
+ u_char *p;
1702
+ off_t *value;
1703
+
1704
+ up = ngx_http_get_module_ctx(r, ngx_http_uploadprogress_module);
1705
+
1706
+ value = (off_t *) ((char *) up + data);
1707
+
1708
+ p = ngx_palloc(r->pool, NGX_OFF_T_LEN);
1709
+ if (p == NULL) {
1710
+ return NGX_ERROR;
1711
+ }
1712
+
1713
+ v->len = ngx_sprintf(p, "%O", *value) - p;
1714
+ v->valid = 1;
1715
+ v->no_cacheable = 0;
1716
+ v->not_found = 0;
1717
+ v->data = p;
1718
+
1719
+ return NGX_OK;
1720
+ }
1721
+
1722
+ static ngx_int_t
1723
+ ngx_http_uploadprogress_callback_variable(ngx_http_request_t *r,
1724
+ ngx_http_variable_value_t *v, uintptr_t data)
1725
+ {
1726
+ u_char *p, *start_p, *val, prefix[1024];
1727
+ ngx_http_uploadprogress_conf_t *upcf;
1728
+ u_int len;
1729
+
1730
+ upcf = ngx_http_get_module_loc_conf(r, ngx_http_uploadprogress_module);
1731
+
1732
+ if (r->args.len) {
1733
+ /* '=' has to be appended to avoid matching parameters that have the */
1734
+ /* configured name as a prefix but are longer */
1735
+ ngx_snprintf(prefix, sizeof(prefix) - 1, "%s=", upcf->jsonp_parameter.data);
1736
+ len = upcf->jsonp_parameter.len + 1;
1737
+ prefix[len] = '\0'; /* Force termination of string */
1738
+
1739
+ p = (u_char *) ngx_strstr(r->args.data, prefix);
1740
+
1741
+ if (p) {
1742
+ p += len;
1743
+ start_p = p;
1744
+ while (p < r->args.data + r->args.len) {
1745
+ if (*((p++) + 1) == '&') {
1746
+ break;
1747
+ }
1748
+ }
1749
+
1750
+ v->len = p - start_p;
1751
+
1752
+ val = ngx_palloc(r->pool, v->len + 1);
1753
+ if (val == NULL) {
1754
+ return NGX_ERROR;
1755
+ }
1756
+
1757
+ ngx_memcpy(val, start_p, v->len);
1758
+ val[v->len] = '\0';
1759
+
1760
+ v->valid = 1;
1761
+ v->no_cacheable = 0;
1762
+ v->not_found = 0;
1763
+ v->data = val;
1764
+ } else {
1765
+ return NGX_ERROR;
1766
+ }
1767
+ } else {
1768
+ return NGX_ERROR;
1769
+ }
1770
+
1771
+ return NGX_OK;
1772
+ }
1773
+
1774
+