nginxtra 1.8.1.12 → 1.10.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +363 -25
  6. data/vendor/nginx/CHANGES.ru +365 -21
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/conf +32 -0
  9. data/vendor/nginx/auto/cc/gcc +1 -1
  10. data/vendor/nginx/auto/cc/icc +2 -2
  11. data/vendor/nginx/auto/cc/msvc +29 -8
  12. data/vendor/nginx/auto/cc/name +2 -25
  13. data/vendor/nginx/auto/cc/sunc +3 -0
  14. data/vendor/nginx/auto/endianness +7 -2
  15. data/vendor/nginx/auto/install +60 -26
  16. data/vendor/nginx/auto/lib/conf +4 -4
  17. data/vendor/nginx/auto/lib/geoip/conf +6 -1
  18. data/vendor/nginx/auto/lib/libgd/conf +6 -1
  19. data/vendor/nginx/auto/lib/libxslt/conf +11 -2
  20. data/vendor/nginx/auto/lib/make +1 -1
  21. data/vendor/nginx/auto/lib/md5/conf +2 -2
  22. data/vendor/nginx/auto/lib/md5/make +2 -2
  23. data/vendor/nginx/auto/lib/openssl/conf +52 -3
  24. data/vendor/nginx/auto/lib/openssl/make +1 -1
  25. data/vendor/nginx/auto/lib/pcre/conf +2 -2
  26. data/vendor/nginx/auto/lib/pcre/make +2 -2
  27. data/vendor/nginx/auto/lib/perl/conf +6 -3
  28. data/vendor/nginx/auto/lib/perl/make +4 -1
  29. data/vendor/nginx/auto/lib/sha1/conf +2 -2
  30. data/vendor/nginx/auto/lib/sha1/make +2 -2
  31. data/vendor/nginx/auto/lib/zlib/conf +2 -2
  32. data/vendor/nginx/auto/lib/zlib/make +2 -2
  33. data/vendor/nginx/auto/make +281 -16
  34. data/vendor/nginx/auto/module +122 -0
  35. data/vendor/nginx/auto/modules +909 -178
  36. data/vendor/nginx/auto/options +81 -19
  37. data/vendor/nginx/auto/os/conf +9 -0
  38. data/vendor/nginx/auto/os/darwin +3 -0
  39. data/vendor/nginx/auto/os/freebsd +0 -20
  40. data/vendor/nginx/auto/os/linux +0 -12
  41. data/vendor/nginx/auto/os/win32 +5 -1
  42. data/vendor/nginx/auto/sources +11 -311
  43. data/vendor/nginx/auto/summary +1 -0
  44. data/vendor/nginx/auto/types/sizeof +5 -3
  45. data/vendor/nginx/auto/types/typedef +9 -4
  46. data/vendor/nginx/auto/types/uintptr_t +7 -2
  47. data/vendor/nginx/auto/unix +72 -12
  48. data/vendor/nginx/conf/fastcgi.conf +1 -0
  49. data/vendor/nginx/conf/fastcgi_params +1 -0
  50. data/vendor/nginx/conf/scgi_params +1 -0
  51. data/vendor/nginx/conf/uwsgi_params +1 -0
  52. data/vendor/nginx/configure +1 -1
  53. data/vendor/nginx/contrib/vim/syntax/nginx.vim +2 -2
  54. data/vendor/nginx/man/nginx.8 +6 -2
  55. data/vendor/nginx/src/core/nginx.c +281 -114
  56. data/vendor/nginx/src/core/nginx.h +2 -2
  57. data/vendor/nginx/src/core/ngx_conf_file.c +54 -13
  58. data/vendor/nginx/src/core/ngx_conf_file.h +8 -52
  59. data/vendor/nginx/src/core/ngx_config.h +0 -5
  60. data/vendor/nginx/src/core/ngx_connection.c +270 -37
  61. data/vendor/nginx/src/core/ngx_connection.h +35 -12
  62. data/vendor/nginx/src/core/ngx_core.h +4 -0
  63. data/vendor/nginx/src/core/ngx_crypt.c +2 -2
  64. data/vendor/nginx/src/core/ngx_cycle.c +72 -25
  65. data/vendor/nginx/src/core/ngx_cycle.h +28 -39
  66. data/vendor/nginx/src/core/ngx_file.c +14 -5
  67. data/vendor/nginx/src/core/ngx_file.h +2 -0
  68. data/vendor/nginx/src/core/ngx_hash.c +13 -1
  69. data/vendor/nginx/src/core/ngx_inet.c +20 -18
  70. data/vendor/nginx/src/core/ngx_log.c +12 -12
  71. data/vendor/nginx/src/core/ngx_log.h +13 -6
  72. data/vendor/nginx/src/core/ngx_module.c +360 -0
  73. data/vendor/nginx/src/core/ngx_module.h +307 -0
  74. data/vendor/nginx/src/core/ngx_open_file_cache.c +2 -2
  75. data/vendor/nginx/src/core/ngx_output_chain.c +8 -4
  76. data/vendor/nginx/src/core/ngx_palloc.c +42 -44
  77. data/vendor/nginx/src/{http/ngx_http_parse_time.c → core/ngx_parse_time.c} +2 -3
  78. data/vendor/nginx/src/core/ngx_parse_time.h +22 -0
  79. data/vendor/nginx/src/core/ngx_proxy_protocol.c +50 -1
  80. data/vendor/nginx/src/core/ngx_proxy_protocol.h +3 -1
  81. data/vendor/nginx/src/core/ngx_regex.c +1 -38
  82. data/vendor/nginx/src/core/ngx_resolver.c +1814 -320
  83. data/vendor/nginx/src/core/ngx_resolver.h +67 -10
  84. data/vendor/nginx/src/core/ngx_rwlock.c +120 -0
  85. data/vendor/nginx/src/core/ngx_rwlock.h +21 -0
  86. data/vendor/nginx/src/core/ngx_slab.c +6 -5
  87. data/vendor/nginx/src/core/ngx_string.c +1 -1
  88. data/vendor/nginx/src/core/ngx_syslog.c +11 -3
  89. data/vendor/nginx/src/core/ngx_syslog.h +2 -1
  90. data/vendor/nginx/src/core/ngx_thread_pool.c +4 -0
  91. data/vendor/nginx/src/core/ngx_times.c +2 -2
  92. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +3 -1
  93. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +5 -2
  94. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +5 -5
  95. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +15 -8
  96. data/vendor/nginx/src/event/modules/ngx_poll_module.c +0 -10
  97. data/vendor/nginx/src/event/modules/ngx_select_module.c +0 -10
  98. data/vendor/nginx/src/event/ngx_event.c +60 -103
  99. data/vendor/nginx/src/event/ngx_event.h +22 -26
  100. data/vendor/nginx/src/event/ngx_event_accept.c +414 -88
  101. data/vendor/nginx/src/event/ngx_event_connect.c +27 -18
  102. data/vendor/nginx/src/event/ngx_event_connect.h +1 -0
  103. data/vendor/nginx/src/event/ngx_event_openssl.c +65 -25
  104. data/vendor/nginx/src/event/ngx_event_openssl.h +17 -0
  105. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +73 -7
  106. data/vendor/nginx/src/event/ngx_event_pipe.c +85 -27
  107. data/vendor/nginx/src/event/ngx_event_pipe.h +10 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +2 -2
  110. data/vendor/nginx/src/http/modules/ngx_http_chunked_filter_module.c +2 -2
  111. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +6 -6
  112. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +17 -11
  113. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +2 -2
  114. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +9 -9
  115. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +2 -2
  116. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +2 -2
  117. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +0 -7
  118. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +6 -6
  119. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +2 -1
  120. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +13 -13
  121. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +2 -2
  122. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +26 -21
  123. data/vendor/nginx/src/http/modules/ngx_http_random_index_module.c +1 -1
  124. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +26 -8
  125. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +73 -3
  126. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +1 -1
  127. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +6 -6
  128. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +5 -3
  129. data/vendor/nginx/src/http/modules/ngx_http_slice_filter_module.c +526 -0
  130. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +7 -7
  131. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +19 -16
  132. data/vendor/nginx/src/http/modules/ngx_http_static_module.c +1 -1
  133. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +1 -1
  134. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +373 -173
  135. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +72 -46
  136. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +18 -30
  137. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +50 -39
  138. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +38 -129
  139. data/vendor/nginx/src/http/modules/ngx_http_upstream_zone_module.c +246 -0
  140. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +6 -5
  141. data/vendor/nginx/src/http/modules/perl/nginx.xs +9 -9
  142. data/vendor/nginx/src/http/ngx_http.c +46 -43
  143. data/vendor/nginx/src/http/ngx_http.h +4 -9
  144. data/vendor/nginx/src/http/ngx_http_cache.h +4 -0
  145. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +13 -5
  146. data/vendor/nginx/src/http/ngx_http_core_module.c +92 -91
  147. data/vendor/nginx/src/http/ngx_http_core_module.h +12 -8
  148. data/vendor/nginx/src/http/ngx_http_file_cache.c +61 -10
  149. data/vendor/nginx/src/http/ngx_http_request.c +37 -50
  150. data/vendor/nginx/src/http/ngx_http_request.h +10 -15
  151. data/vendor/nginx/src/http/ngx_http_request_body.c +64 -88
  152. data/vendor/nginx/src/http/ngx_http_script.c +3 -3
  153. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -4
  154. data/vendor/nginx/src/http/ngx_http_upstream.c +245 -109
  155. data/vendor/nginx/src/http/ngx_http_upstream.h +11 -5
  156. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +212 -65
  157. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +66 -5
  158. data/vendor/nginx/src/http/ngx_http_variables.c +28 -15
  159. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +1 -1
  160. data/vendor/nginx/src/http/v2/ngx_http_v2.c +4349 -0
  161. data/vendor/nginx/src/http/v2/ngx_http_v2.h +337 -0
  162. data/vendor/nginx/src/http/v2/ngx_http_v2_filter_module.c +1391 -0
  163. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_decode.c +2714 -0
  164. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_encode.c +254 -0
  165. data/vendor/nginx/src/http/v2/ngx_http_v2_module.c +469 -0
  166. data/vendor/nginx/src/http/{ngx_http_spdy_module.h → v2/ngx_http_v2_module.h} +10 -9
  167. data/vendor/nginx/src/http/v2/ngx_http_v2_table.c +349 -0
  168. data/vendor/nginx/src/mail/ngx_mail.c +49 -82
  169. data/vendor/nginx/src/mail/ngx_mail.h +16 -23
  170. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +1 -1
  171. data/vendor/nginx/src/mail/ngx_mail_core_module.c +60 -34
  172. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -12
  173. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +1 -14
  174. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +1 -1
  175. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +5 -5
  176. data/vendor/nginx/src/os/unix/ngx_atomic.h +10 -10
  177. data/vendor/nginx/src/os/unix/ngx_channel.h +4 -4
  178. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +2 -0
  179. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -0
  180. data/vendor/nginx/src/os/unix/ngx_dlopen.c +28 -0
  181. data/vendor/nginx/src/os/unix/ngx_dlopen.h +31 -0
  182. data/vendor/nginx/src/os/unix/ngx_errno.h +1 -0
  183. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +1 -1
  184. data/vendor/nginx/src/os/unix/ngx_files.c +313 -80
  185. data/vendor/nginx/src/os/unix/ngx_files.h +5 -2
  186. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +3 -1
  187. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -0
  188. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +13 -0
  189. data/vendor/nginx/src/os/unix/ngx_linux.h +0 -2
  190. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +1 -1
  191. data/vendor/nginx/src/os/unix/ngx_linux_config.h +2 -6
  192. data/vendor/nginx/src/os/unix/ngx_linux_init.c +1 -33
  193. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +55 -12
  194. data/vendor/nginx/src/os/unix/ngx_os.h +3 -9
  195. data/vendor/nginx/src/os/unix/ngx_posix_config.h +14 -1
  196. data/vendor/nginx/src/os/unix/ngx_posix_init.c +2 -1
  197. data/vendor/nginx/src/os/unix/ngx_process.c +1 -1
  198. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +25 -51
  199. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +1 -0
  200. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +24 -28
  201. data/vendor/nginx/src/os/unix/ngx_recv.c +30 -79
  202. data/vendor/nginx/src/os/unix/ngx_send.c +1 -1
  203. data/vendor/nginx/src/os/unix/ngx_setaffinity.c +14 -30
  204. data/vendor/nginx/src/os/unix/ngx_setaffinity.h +15 -1
  205. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +2 -0
  206. data/vendor/nginx/src/os/unix/ngx_solaris_init.c +1 -0
  207. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +23 -0
  208. data/vendor/nginx/src/os/unix/ngx_sunpro_amd64.il +3 -3
  209. data/vendor/nginx/src/os/unix/ngx_sunpro_x86.il +3 -3
  210. data/vendor/nginx/src/os/unix/ngx_udp_recv.c +5 -48
  211. data/vendor/nginx/src/os/unix/ngx_udp_send.c +56 -0
  212. data/vendor/nginx/src/stream/ngx_stream.c +564 -0
  213. data/vendor/nginx/src/stream/ngx_stream.h +212 -0
  214. data/vendor/nginx/src/stream/ngx_stream_access_module.c +451 -0
  215. data/vendor/nginx/src/stream/ngx_stream_core_module.c +562 -0
  216. data/vendor/nginx/src/stream/ngx_stream_handler.c +344 -0
  217. data/vendor/nginx/src/stream/ngx_stream_limit_conn_module.c +632 -0
  218. data/vendor/nginx/src/stream/ngx_stream_proxy_module.c +1674 -0
  219. data/vendor/nginx/src/stream/ngx_stream_ssl_module.c +460 -0
  220. data/vendor/nginx/src/stream/ngx_stream_ssl_module.h +49 -0
  221. data/vendor/nginx/src/stream/ngx_stream_upstream.c +464 -0
  222. data/vendor/nginx/src/stream/ngx_stream_upstream.h +107 -0
  223. data/vendor/nginx/src/stream/ngx_stream_upstream_hash_module.c +656 -0
  224. data/vendor/nginx/src/stream/ngx_stream_upstream_least_conn_module.c +307 -0
  225. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.c +702 -0
  226. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.h +139 -0
  227. data/vendor/nginx/src/stream/ngx_stream_upstream_zone_module.c +242 -0
  228. metadata +39 -15
  229. data/vendor/nginx/src/event/modules/ngx_aio_module.c +0 -171
  230. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +0 -735
  231. data/vendor/nginx/src/http/ngx_http_spdy.c +0 -3701
  232. data/vendor/nginx/src/http/ngx_http_spdy.h +0 -261
  233. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +0 -1222
  234. data/vendor/nginx/src/http/ngx_http_spdy_module.c +0 -408
  235. data/vendor/nginx/src/os/unix/ngx_aio_read.c +0 -109
  236. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +0 -78
  237. data/vendor/nginx/src/os/unix/ngx_aio_write.c +0 -109
  238. data/vendor/nginx/src/os/unix/ngx_aio_write_chain.c +0 -100
@@ -0,0 +1,254 @@
1
+
2
+ /*
3
+ * Copyright (C) Nginx, Inc.
4
+ * Copyright (C) Valentin V. Bartenev
5
+ * Copyright (C) 2015 Vlad Krasnov
6
+ */
7
+
8
+
9
+ #include <ngx_config.h>
10
+ #include <ngx_core.h>
11
+ #include <ngx_http.h>
12
+
13
+
14
+ typedef struct {
15
+ uint32_t code;
16
+ uint32_t len;
17
+ } ngx_http_v2_huff_encode_code_t;
18
+
19
+
20
+ static ngx_http_v2_huff_encode_code_t ngx_http_v2_huff_encode_table[256] =
21
+ {
22
+ {0x00001ff8, 13}, {0x007fffd8, 23}, {0x0fffffe2, 28}, {0x0fffffe3, 28},
23
+ {0x0fffffe4, 28}, {0x0fffffe5, 28}, {0x0fffffe6, 28}, {0x0fffffe7, 28},
24
+ {0x0fffffe8, 28}, {0x00ffffea, 24}, {0x3ffffffc, 30}, {0x0fffffe9, 28},
25
+ {0x0fffffea, 28}, {0x3ffffffd, 30}, {0x0fffffeb, 28}, {0x0fffffec, 28},
26
+ {0x0fffffed, 28}, {0x0fffffee, 28}, {0x0fffffef, 28}, {0x0ffffff0, 28},
27
+ {0x0ffffff1, 28}, {0x0ffffff2, 28}, {0x3ffffffe, 30}, {0x0ffffff3, 28},
28
+ {0x0ffffff4, 28}, {0x0ffffff5, 28}, {0x0ffffff6, 28}, {0x0ffffff7, 28},
29
+ {0x0ffffff8, 28}, {0x0ffffff9, 28}, {0x0ffffffa, 28}, {0x0ffffffb, 28},
30
+ {0x00000014, 6}, {0x000003f8, 10}, {0x000003f9, 10}, {0x00000ffa, 12},
31
+ {0x00001ff9, 13}, {0x00000015, 6}, {0x000000f8, 8}, {0x000007fa, 11},
32
+ {0x000003fa, 10}, {0x000003fb, 10}, {0x000000f9, 8}, {0x000007fb, 11},
33
+ {0x000000fa, 8}, {0x00000016, 6}, {0x00000017, 6}, {0x00000018, 6},
34
+ {0x00000000, 5}, {0x00000001, 5}, {0x00000002, 5}, {0x00000019, 6},
35
+ {0x0000001a, 6}, {0x0000001b, 6}, {0x0000001c, 6}, {0x0000001d, 6},
36
+ {0x0000001e, 6}, {0x0000001f, 6}, {0x0000005c, 7}, {0x000000fb, 8},
37
+ {0x00007ffc, 15}, {0x00000020, 6}, {0x00000ffb, 12}, {0x000003fc, 10},
38
+ {0x00001ffa, 13}, {0x00000021, 6}, {0x0000005d, 7}, {0x0000005e, 7},
39
+ {0x0000005f, 7}, {0x00000060, 7}, {0x00000061, 7}, {0x00000062, 7},
40
+ {0x00000063, 7}, {0x00000064, 7}, {0x00000065, 7}, {0x00000066, 7},
41
+ {0x00000067, 7}, {0x00000068, 7}, {0x00000069, 7}, {0x0000006a, 7},
42
+ {0x0000006b, 7}, {0x0000006c, 7}, {0x0000006d, 7}, {0x0000006e, 7},
43
+ {0x0000006f, 7}, {0x00000070, 7}, {0x00000071, 7}, {0x00000072, 7},
44
+ {0x000000fc, 8}, {0x00000073, 7}, {0x000000fd, 8}, {0x00001ffb, 13},
45
+ {0x0007fff0, 19}, {0x00001ffc, 13}, {0x00003ffc, 14}, {0x00000022, 6},
46
+ {0x00007ffd, 15}, {0x00000003, 5}, {0x00000023, 6}, {0x00000004, 5},
47
+ {0x00000024, 6}, {0x00000005, 5}, {0x00000025, 6}, {0x00000026, 6},
48
+ {0x00000027, 6}, {0x00000006, 5}, {0x00000074, 7}, {0x00000075, 7},
49
+ {0x00000028, 6}, {0x00000029, 6}, {0x0000002a, 6}, {0x00000007, 5},
50
+ {0x0000002b, 6}, {0x00000076, 7}, {0x0000002c, 6}, {0x00000008, 5},
51
+ {0x00000009, 5}, {0x0000002d, 6}, {0x00000077, 7}, {0x00000078, 7},
52
+ {0x00000079, 7}, {0x0000007a, 7}, {0x0000007b, 7}, {0x00007ffe, 15},
53
+ {0x000007fc, 11}, {0x00003ffd, 14}, {0x00001ffd, 13}, {0x0ffffffc, 28},
54
+ {0x000fffe6, 20}, {0x003fffd2, 22}, {0x000fffe7, 20}, {0x000fffe8, 20},
55
+ {0x003fffd3, 22}, {0x003fffd4, 22}, {0x003fffd5, 22}, {0x007fffd9, 23},
56
+ {0x003fffd6, 22}, {0x007fffda, 23}, {0x007fffdb, 23}, {0x007fffdc, 23},
57
+ {0x007fffdd, 23}, {0x007fffde, 23}, {0x00ffffeb, 24}, {0x007fffdf, 23},
58
+ {0x00ffffec, 24}, {0x00ffffed, 24}, {0x003fffd7, 22}, {0x007fffe0, 23},
59
+ {0x00ffffee, 24}, {0x007fffe1, 23}, {0x007fffe2, 23}, {0x007fffe3, 23},
60
+ {0x007fffe4, 23}, {0x001fffdc, 21}, {0x003fffd8, 22}, {0x007fffe5, 23},
61
+ {0x003fffd9, 22}, {0x007fffe6, 23}, {0x007fffe7, 23}, {0x00ffffef, 24},
62
+ {0x003fffda, 22}, {0x001fffdd, 21}, {0x000fffe9, 20}, {0x003fffdb, 22},
63
+ {0x003fffdc, 22}, {0x007fffe8, 23}, {0x007fffe9, 23}, {0x001fffde, 21},
64
+ {0x007fffea, 23}, {0x003fffdd, 22}, {0x003fffde, 22}, {0x00fffff0, 24},
65
+ {0x001fffdf, 21}, {0x003fffdf, 22}, {0x007fffeb, 23}, {0x007fffec, 23},
66
+ {0x001fffe0, 21}, {0x001fffe1, 21}, {0x003fffe0, 22}, {0x001fffe2, 21},
67
+ {0x007fffed, 23}, {0x003fffe1, 22}, {0x007fffee, 23}, {0x007fffef, 23},
68
+ {0x000fffea, 20}, {0x003fffe2, 22}, {0x003fffe3, 22}, {0x003fffe4, 22},
69
+ {0x007ffff0, 23}, {0x003fffe5, 22}, {0x003fffe6, 22}, {0x007ffff1, 23},
70
+ {0x03ffffe0, 26}, {0x03ffffe1, 26}, {0x000fffeb, 20}, {0x0007fff1, 19},
71
+ {0x003fffe7, 22}, {0x007ffff2, 23}, {0x003fffe8, 22}, {0x01ffffec, 25},
72
+ {0x03ffffe2, 26}, {0x03ffffe3, 26}, {0x03ffffe4, 26}, {0x07ffffde, 27},
73
+ {0x07ffffdf, 27}, {0x03ffffe5, 26}, {0x00fffff1, 24}, {0x01ffffed, 25},
74
+ {0x0007fff2, 19}, {0x001fffe3, 21}, {0x03ffffe6, 26}, {0x07ffffe0, 27},
75
+ {0x07ffffe1, 27}, {0x03ffffe7, 26}, {0x07ffffe2, 27}, {0x00fffff2, 24},
76
+ {0x001fffe4, 21}, {0x001fffe5, 21}, {0x03ffffe8, 26}, {0x03ffffe9, 26},
77
+ {0x0ffffffd, 28}, {0x07ffffe3, 27}, {0x07ffffe4, 27}, {0x07ffffe5, 27},
78
+ {0x000fffec, 20}, {0x00fffff3, 24}, {0x000fffed, 20}, {0x001fffe6, 21},
79
+ {0x003fffe9, 22}, {0x001fffe7, 21}, {0x001fffe8, 21}, {0x007ffff3, 23},
80
+ {0x003fffea, 22}, {0x003fffeb, 22}, {0x01ffffee, 25}, {0x01ffffef, 25},
81
+ {0x00fffff4, 24}, {0x00fffff5, 24}, {0x03ffffea, 26}, {0x007ffff4, 23},
82
+ {0x03ffffeb, 26}, {0x07ffffe6, 27}, {0x03ffffec, 26}, {0x03ffffed, 26},
83
+ {0x07ffffe7, 27}, {0x07ffffe8, 27}, {0x07ffffe9, 27}, {0x07ffffea, 27},
84
+ {0x07ffffeb, 27}, {0x0ffffffe, 28}, {0x07ffffec, 27}, {0x07ffffed, 27},
85
+ {0x07ffffee, 27}, {0x07ffffef, 27}, {0x07fffff0, 27}, {0x03ffffee, 26}
86
+ };
87
+
88
+
89
+ /* same as above, but embeds lowercase transformation */
90
+ static ngx_http_v2_huff_encode_code_t ngx_http_v2_huff_encode_table_lc[256] =
91
+ {
92
+ {0x00001ff8, 13}, {0x007fffd8, 23}, {0x0fffffe2, 28}, {0x0fffffe3, 28},
93
+ {0x0fffffe4, 28}, {0x0fffffe5, 28}, {0x0fffffe6, 28}, {0x0fffffe7, 28},
94
+ {0x0fffffe8, 28}, {0x00ffffea, 24}, {0x3ffffffc, 30}, {0x0fffffe9, 28},
95
+ {0x0fffffea, 28}, {0x3ffffffd, 30}, {0x0fffffeb, 28}, {0x0fffffec, 28},
96
+ {0x0fffffed, 28}, {0x0fffffee, 28}, {0x0fffffef, 28}, {0x0ffffff0, 28},
97
+ {0x0ffffff1, 28}, {0x0ffffff2, 28}, {0x3ffffffe, 30}, {0x0ffffff3, 28},
98
+ {0x0ffffff4, 28}, {0x0ffffff5, 28}, {0x0ffffff6, 28}, {0x0ffffff7, 28},
99
+ {0x0ffffff8, 28}, {0x0ffffff9, 28}, {0x0ffffffa, 28}, {0x0ffffffb, 28},
100
+ {0x00000014, 6}, {0x000003f8, 10}, {0x000003f9, 10}, {0x00000ffa, 12},
101
+ {0x00001ff9, 13}, {0x00000015, 6}, {0x000000f8, 8}, {0x000007fa, 11},
102
+ {0x000003fa, 10}, {0x000003fb, 10}, {0x000000f9, 8}, {0x000007fb, 11},
103
+ {0x000000fa, 8}, {0x00000016, 6}, {0x00000017, 6}, {0x00000018, 6},
104
+ {0x00000000, 5}, {0x00000001, 5}, {0x00000002, 5}, {0x00000019, 6},
105
+ {0x0000001a, 6}, {0x0000001b, 6}, {0x0000001c, 6}, {0x0000001d, 6},
106
+ {0x0000001e, 6}, {0x0000001f, 6}, {0x0000005c, 7}, {0x000000fb, 8},
107
+ {0x00007ffc, 15}, {0x00000020, 6}, {0x00000ffb, 12}, {0x000003fc, 10},
108
+ {0x00001ffa, 13}, {0x00000003, 5}, {0x00000023, 6}, {0x00000004, 5},
109
+ {0x00000024, 6}, {0x00000005, 5}, {0x00000025, 6}, {0x00000026, 6},
110
+ {0x00000027, 6}, {0x00000006, 5}, {0x00000074, 7}, {0x00000075, 7},
111
+ {0x00000028, 6}, {0x00000029, 6}, {0x0000002a, 6}, {0x00000007, 5},
112
+ {0x0000002b, 6}, {0x00000076, 7}, {0x0000002c, 6}, {0x00000008, 5},
113
+ {0x00000009, 5}, {0x0000002d, 6}, {0x00000077, 7}, {0x00000078, 7},
114
+ {0x00000079, 7}, {0x0000007a, 7}, {0x0000007b, 7}, {0x00001ffb, 13},
115
+ {0x0007fff0, 19}, {0x00001ffc, 13}, {0x00003ffc, 14}, {0x00000022, 6},
116
+ {0x00007ffd, 15}, {0x00000003, 5}, {0x00000023, 6}, {0x00000004, 5},
117
+ {0x00000024, 6}, {0x00000005, 5}, {0x00000025, 6}, {0x00000026, 6},
118
+ {0x00000027, 6}, {0x00000006, 5}, {0x00000074, 7}, {0x00000075, 7},
119
+ {0x00000028, 6}, {0x00000029, 6}, {0x0000002a, 6}, {0x00000007, 5},
120
+ {0x0000002b, 6}, {0x00000076, 7}, {0x0000002c, 6}, {0x00000008, 5},
121
+ {0x00000009, 5}, {0x0000002d, 6}, {0x00000077, 7}, {0x00000078, 7},
122
+ {0x00000079, 7}, {0x0000007a, 7}, {0x0000007b, 7}, {0x00007ffe, 15},
123
+ {0x000007fc, 11}, {0x00003ffd, 14}, {0x00001ffd, 13}, {0x0ffffffc, 28},
124
+ {0x000fffe6, 20}, {0x003fffd2, 22}, {0x000fffe7, 20}, {0x000fffe8, 20},
125
+ {0x003fffd3, 22}, {0x003fffd4, 22}, {0x003fffd5, 22}, {0x007fffd9, 23},
126
+ {0x003fffd6, 22}, {0x007fffda, 23}, {0x007fffdb, 23}, {0x007fffdc, 23},
127
+ {0x007fffdd, 23}, {0x007fffde, 23}, {0x00ffffeb, 24}, {0x007fffdf, 23},
128
+ {0x00ffffec, 24}, {0x00ffffed, 24}, {0x003fffd7, 22}, {0x007fffe0, 23},
129
+ {0x00ffffee, 24}, {0x007fffe1, 23}, {0x007fffe2, 23}, {0x007fffe3, 23},
130
+ {0x007fffe4, 23}, {0x001fffdc, 21}, {0x003fffd8, 22}, {0x007fffe5, 23},
131
+ {0x003fffd9, 22}, {0x007fffe6, 23}, {0x007fffe7, 23}, {0x00ffffef, 24},
132
+ {0x003fffda, 22}, {0x001fffdd, 21}, {0x000fffe9, 20}, {0x003fffdb, 22},
133
+ {0x003fffdc, 22}, {0x007fffe8, 23}, {0x007fffe9, 23}, {0x001fffde, 21},
134
+ {0x007fffea, 23}, {0x003fffdd, 22}, {0x003fffde, 22}, {0x00fffff0, 24},
135
+ {0x001fffdf, 21}, {0x003fffdf, 22}, {0x007fffeb, 23}, {0x007fffec, 23},
136
+ {0x001fffe0, 21}, {0x001fffe1, 21}, {0x003fffe0, 22}, {0x001fffe2, 21},
137
+ {0x007fffed, 23}, {0x003fffe1, 22}, {0x007fffee, 23}, {0x007fffef, 23},
138
+ {0x000fffea, 20}, {0x003fffe2, 22}, {0x003fffe3, 22}, {0x003fffe4, 22},
139
+ {0x007ffff0, 23}, {0x003fffe5, 22}, {0x003fffe6, 22}, {0x007ffff1, 23},
140
+ {0x03ffffe0, 26}, {0x03ffffe1, 26}, {0x000fffeb, 20}, {0x0007fff1, 19},
141
+ {0x003fffe7, 22}, {0x007ffff2, 23}, {0x003fffe8, 22}, {0x01ffffec, 25},
142
+ {0x03ffffe2, 26}, {0x03ffffe3, 26}, {0x03ffffe4, 26}, {0x07ffffde, 27},
143
+ {0x07ffffdf, 27}, {0x03ffffe5, 26}, {0x00fffff1, 24}, {0x01ffffed, 25},
144
+ {0x0007fff2, 19}, {0x001fffe3, 21}, {0x03ffffe6, 26}, {0x07ffffe0, 27},
145
+ {0x07ffffe1, 27}, {0x03ffffe7, 26}, {0x07ffffe2, 27}, {0x00fffff2, 24},
146
+ {0x001fffe4, 21}, {0x001fffe5, 21}, {0x03ffffe8, 26}, {0x03ffffe9, 26},
147
+ {0x0ffffffd, 28}, {0x07ffffe3, 27}, {0x07ffffe4, 27}, {0x07ffffe5, 27},
148
+ {0x000fffec, 20}, {0x00fffff3, 24}, {0x000fffed, 20}, {0x001fffe6, 21},
149
+ {0x003fffe9, 22}, {0x001fffe7, 21}, {0x001fffe8, 21}, {0x007ffff3, 23},
150
+ {0x003fffea, 22}, {0x003fffeb, 22}, {0x01ffffee, 25}, {0x01ffffef, 25},
151
+ {0x00fffff4, 24}, {0x00fffff5, 24}, {0x03ffffea, 26}, {0x007ffff4, 23},
152
+ {0x03ffffeb, 26}, {0x07ffffe6, 27}, {0x03ffffec, 26}, {0x03ffffed, 26},
153
+ {0x07ffffe7, 27}, {0x07ffffe8, 27}, {0x07ffffe9, 27}, {0x07ffffea, 27},
154
+ {0x07ffffeb, 27}, {0x0ffffffe, 28}, {0x07ffffec, 27}, {0x07ffffed, 27},
155
+ {0x07ffffee, 27}, {0x07ffffef, 27}, {0x07fffff0, 27}, {0x03ffffee, 26}
156
+ };
157
+
158
+
159
+ #if (NGX_PTR_SIZE == 8)
160
+
161
+ #if (NGX_HAVE_LITTLE_ENDIAN)
162
+
163
+ #if (NGX_HAVE_GCC_BSWAP64)
164
+ #define ngx_http_v2_huff_encode_buf(dst, buf) \
165
+ (*(uint64_t *) (dst) = __builtin_bswap64(buf))
166
+ #else
167
+ #define ngx_http_v2_huff_encode_buf(dst, buf) \
168
+ ((dst)[0] = (u_char) ((buf) >> 56), \
169
+ (dst)[1] = (u_char) ((buf) >> 48), \
170
+ (dst)[2] = (u_char) ((buf) >> 40), \
171
+ (dst)[3] = (u_char) ((buf) >> 32), \
172
+ (dst)[4] = (u_char) ((buf) >> 24), \
173
+ (dst)[5] = (u_char) ((buf) >> 16), \
174
+ (dst)[6] = (u_char) ((buf) >> 8), \
175
+ (dst)[7] = (u_char) (buf))
176
+ #endif
177
+
178
+ #else /* !NGX_HAVE_LITTLE_ENDIAN */
179
+ #define ngx_http_v2_huff_encode_buf(dst, buf) \
180
+ (*(uint64_t *) (dst) = (buf))
181
+ #endif
182
+
183
+ #else /* NGX_PTR_SIZE == 4 */
184
+
185
+ #define ngx_http_v2_huff_encode_buf(dst, buf) \
186
+ (*(uint32_t *) (dst) = htonl(buf))
187
+
188
+ #endif
189
+
190
+
191
+ size_t
192
+ ngx_http_v2_huff_encode(u_char *src, size_t len, u_char *dst, ngx_uint_t lower)
193
+ {
194
+ u_char *end;
195
+ size_t hlen;
196
+ ngx_uint_t buf, pending, code;
197
+ ngx_http_v2_huff_encode_code_t *table, *next;
198
+
199
+ table = lower ? ngx_http_v2_huff_encode_table_lc
200
+ : ngx_http_v2_huff_encode_table;
201
+ hlen = 0;
202
+ buf = 0;
203
+ pending = 0;
204
+
205
+ end = src + len;
206
+
207
+ while (src != end) {
208
+ next = &table[*src++];
209
+
210
+ code = next->code;
211
+ pending += next->len;
212
+
213
+ /* accumulate bits */
214
+ if (pending < sizeof(buf) * 8) {
215
+ buf |= code << (sizeof(buf) * 8 - pending);
216
+ continue;
217
+ }
218
+
219
+ if (hlen + sizeof(buf) >= len) {
220
+ return 0;
221
+ }
222
+
223
+ pending -= sizeof(buf) * 8;
224
+
225
+ buf |= code >> pending;
226
+
227
+ ngx_http_v2_huff_encode_buf(&dst[hlen], buf);
228
+
229
+ hlen += sizeof(buf);
230
+
231
+ buf = pending ? code << (sizeof(buf) * 8 - pending) : 0;
232
+ }
233
+
234
+ if (pending == 0) {
235
+ return hlen;
236
+ }
237
+
238
+ buf |= (ngx_uint_t) -1 >> pending;
239
+
240
+ pending = ngx_align(pending, 8);
241
+
242
+ if (hlen + pending / 8 >= len) {
243
+ return 0;
244
+ }
245
+
246
+ buf >>= sizeof(buf) * 8 - pending;
247
+
248
+ do {
249
+ pending -= 8;
250
+ dst[hlen++] = (u_char) (buf >> pending);
251
+ } while (pending);
252
+
253
+ return hlen;
254
+ }
@@ -0,0 +1,469 @@
1
+
2
+ /*
3
+ * Copyright (C) Nginx, Inc.
4
+ * Copyright (C) Valentin V. Bartenev
5
+ */
6
+
7
+
8
+ #include <ngx_config.h>
9
+ #include <ngx_core.h>
10
+ #include <ngx_http.h>
11
+ #include <ngx_http_v2_module.h>
12
+
13
+
14
+ static ngx_int_t ngx_http_v2_add_variables(ngx_conf_t *cf);
15
+
16
+ static ngx_int_t ngx_http_v2_variable(ngx_http_request_t *r,
17
+ ngx_http_variable_value_t *v, uintptr_t data);
18
+
19
+ static ngx_int_t ngx_http_v2_module_init(ngx_cycle_t *cycle);
20
+
21
+ static void *ngx_http_v2_create_main_conf(ngx_conf_t *cf);
22
+ static char *ngx_http_v2_init_main_conf(ngx_conf_t *cf, void *conf);
23
+ static void *ngx_http_v2_create_srv_conf(ngx_conf_t *cf);
24
+ static char *ngx_http_v2_merge_srv_conf(ngx_conf_t *cf, void *parent,
25
+ void *child);
26
+ static void *ngx_http_v2_create_loc_conf(ngx_conf_t *cf);
27
+ static char *ngx_http_v2_merge_loc_conf(ngx_conf_t *cf, void *parent,
28
+ void *child);
29
+
30
+ static char *ngx_http_v2_recv_buffer_size(ngx_conf_t *cf, void *post,
31
+ void *data);
32
+ static char *ngx_http_v2_pool_size(ngx_conf_t *cf, void *post, void *data);
33
+ static char *ngx_http_v2_streams_index_mask(ngx_conf_t *cf, void *post,
34
+ void *data);
35
+ static char *ngx_http_v2_chunk_size(ngx_conf_t *cf, void *post, void *data);
36
+ static char *ngx_http_v2_spdy_deprecated(ngx_conf_t *cf, ngx_command_t *cmd,
37
+ void *conf);
38
+
39
+
40
+ static ngx_conf_post_t ngx_http_v2_recv_buffer_size_post =
41
+ { ngx_http_v2_recv_buffer_size };
42
+ static ngx_conf_post_t ngx_http_v2_pool_size_post =
43
+ { ngx_http_v2_pool_size };
44
+ static ngx_conf_post_t ngx_http_v2_streams_index_mask_post =
45
+ { ngx_http_v2_streams_index_mask };
46
+ static ngx_conf_post_t ngx_http_v2_chunk_size_post =
47
+ { ngx_http_v2_chunk_size };
48
+
49
+
50
+ static ngx_command_t ngx_http_v2_commands[] = {
51
+
52
+ { ngx_string("http2_recv_buffer_size"),
53
+ NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
54
+ ngx_conf_set_size_slot,
55
+ NGX_HTTP_MAIN_CONF_OFFSET,
56
+ offsetof(ngx_http_v2_main_conf_t, recv_buffer_size),
57
+ &ngx_http_v2_recv_buffer_size_post },
58
+
59
+ { ngx_string("http2_pool_size"),
60
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
61
+ ngx_conf_set_size_slot,
62
+ NGX_HTTP_SRV_CONF_OFFSET,
63
+ offsetof(ngx_http_v2_srv_conf_t, pool_size),
64
+ &ngx_http_v2_pool_size_post },
65
+
66
+ { ngx_string("http2_max_concurrent_streams"),
67
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
68
+ ngx_conf_set_num_slot,
69
+ NGX_HTTP_SRV_CONF_OFFSET,
70
+ offsetof(ngx_http_v2_srv_conf_t, concurrent_streams),
71
+ NULL },
72
+
73
+ { ngx_string("http2_max_field_size"),
74
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
75
+ ngx_conf_set_size_slot,
76
+ NGX_HTTP_SRV_CONF_OFFSET,
77
+ offsetof(ngx_http_v2_srv_conf_t, max_field_size),
78
+ NULL },
79
+
80
+ { ngx_string("http2_max_header_size"),
81
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
82
+ ngx_conf_set_size_slot,
83
+ NGX_HTTP_SRV_CONF_OFFSET,
84
+ offsetof(ngx_http_v2_srv_conf_t, max_header_size),
85
+ NULL },
86
+
87
+ { ngx_string("http2_streams_index_size"),
88
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
89
+ ngx_conf_set_num_slot,
90
+ NGX_HTTP_SRV_CONF_OFFSET,
91
+ offsetof(ngx_http_v2_srv_conf_t, streams_index_mask),
92
+ &ngx_http_v2_streams_index_mask_post },
93
+
94
+ { ngx_string("http2_recv_timeout"),
95
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
96
+ ngx_conf_set_msec_slot,
97
+ NGX_HTTP_SRV_CONF_OFFSET,
98
+ offsetof(ngx_http_v2_srv_conf_t, recv_timeout),
99
+ NULL },
100
+
101
+ { ngx_string("http2_idle_timeout"),
102
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
103
+ ngx_conf_set_msec_slot,
104
+ NGX_HTTP_SRV_CONF_OFFSET,
105
+ offsetof(ngx_http_v2_srv_conf_t, idle_timeout),
106
+ NULL },
107
+
108
+ { ngx_string("http2_chunk_size"),
109
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
110
+ ngx_conf_set_size_slot,
111
+ NGX_HTTP_LOC_CONF_OFFSET,
112
+ offsetof(ngx_http_v2_loc_conf_t, chunk_size),
113
+ &ngx_http_v2_chunk_size_post },
114
+
115
+ { ngx_string("spdy_recv_buffer_size"),
116
+ NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
117
+ ngx_http_v2_spdy_deprecated,
118
+ NGX_HTTP_MAIN_CONF_OFFSET,
119
+ 0,
120
+ NULL },
121
+
122
+ { ngx_string("spdy_pool_size"),
123
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
124
+ ngx_http_v2_spdy_deprecated,
125
+ NGX_HTTP_SRV_CONF_OFFSET,
126
+ 0,
127
+ NULL },
128
+
129
+ { ngx_string("spdy_max_concurrent_streams"),
130
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
131
+ ngx_http_v2_spdy_deprecated,
132
+ NGX_HTTP_SRV_CONF_OFFSET,
133
+ 0,
134
+ NULL },
135
+
136
+ { ngx_string("spdy_streams_index_size"),
137
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
138
+ ngx_http_v2_spdy_deprecated,
139
+ NGX_HTTP_SRV_CONF_OFFSET,
140
+ 0,
141
+ NULL },
142
+
143
+ { ngx_string("spdy_recv_timeout"),
144
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
145
+ ngx_http_v2_spdy_deprecated,
146
+ NGX_HTTP_SRV_CONF_OFFSET,
147
+ 0,
148
+ NULL },
149
+
150
+ { ngx_string("spdy_keepalive_timeout"),
151
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
152
+ ngx_http_v2_spdy_deprecated,
153
+ NGX_HTTP_SRV_CONF_OFFSET,
154
+ 0,
155
+ NULL },
156
+
157
+ { ngx_string("spdy_headers_comp"),
158
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
159
+ ngx_http_v2_spdy_deprecated,
160
+ NGX_HTTP_SRV_CONF_OFFSET,
161
+ 0,
162
+ NULL },
163
+
164
+ { ngx_string("spdy_chunk_size"),
165
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
166
+ ngx_http_v2_spdy_deprecated,
167
+ NGX_HTTP_LOC_CONF_OFFSET,
168
+ 0,
169
+ NULL },
170
+
171
+ ngx_null_command
172
+ };
173
+
174
+
175
+ static ngx_http_module_t ngx_http_v2_module_ctx = {
176
+ ngx_http_v2_add_variables, /* preconfiguration */
177
+ NULL, /* postconfiguration */
178
+
179
+ ngx_http_v2_create_main_conf, /* create main configuration */
180
+ ngx_http_v2_init_main_conf, /* init main configuration */
181
+
182
+ ngx_http_v2_create_srv_conf, /* create server configuration */
183
+ ngx_http_v2_merge_srv_conf, /* merge server configuration */
184
+
185
+ ngx_http_v2_create_loc_conf, /* create location configuration */
186
+ ngx_http_v2_merge_loc_conf /* merge location configuration */
187
+ };
188
+
189
+
190
+ ngx_module_t ngx_http_v2_module = {
191
+ NGX_MODULE_V1,
192
+ &ngx_http_v2_module_ctx, /* module context */
193
+ ngx_http_v2_commands, /* module directives */
194
+ NGX_HTTP_MODULE, /* module type */
195
+ NULL, /* init master */
196
+ ngx_http_v2_module_init, /* init module */
197
+ NULL, /* init process */
198
+ NULL, /* init thread */
199
+ NULL, /* exit thread */
200
+ NULL, /* exit process */
201
+ NULL, /* exit master */
202
+ NGX_MODULE_V1_PADDING
203
+ };
204
+
205
+
206
+ static ngx_http_variable_t ngx_http_v2_vars[] = {
207
+
208
+ { ngx_string("http2"), NULL,
209
+ ngx_http_v2_variable, 0, 0, 0 },
210
+
211
+ { ngx_null_string, NULL, NULL, 0, 0, 0 }
212
+ };
213
+
214
+
215
+ static ngx_int_t
216
+ ngx_http_v2_add_variables(ngx_conf_t *cf)
217
+ {
218
+ ngx_http_variable_t *var, *v;
219
+
220
+ for (v = ngx_http_v2_vars; v->name.len; v++) {
221
+ var = ngx_http_add_variable(cf, &v->name, v->flags);
222
+ if (var == NULL) {
223
+ return NGX_ERROR;
224
+ }
225
+
226
+ var->get_handler = v->get_handler;
227
+ var->data = v->data;
228
+ }
229
+
230
+ return NGX_OK;
231
+ }
232
+
233
+
234
+ static ngx_int_t
235
+ ngx_http_v2_variable(ngx_http_request_t *r,
236
+ ngx_http_variable_value_t *v, uintptr_t data)
237
+ {
238
+
239
+ if (r->stream) {
240
+ #if (NGX_HTTP_SSL)
241
+
242
+ if (r->connection->ssl) {
243
+ v->len = sizeof("h2") - 1;
244
+ v->valid = 1;
245
+ v->no_cacheable = 0;
246
+ v->not_found = 0;
247
+ v->data = (u_char *) "h2";
248
+
249
+ return NGX_OK;
250
+ }
251
+
252
+ #endif
253
+ v->len = sizeof("h2c") - 1;
254
+ v->valid = 1;
255
+ v->no_cacheable = 0;
256
+ v->not_found = 0;
257
+ v->data = (u_char *) "h2c";
258
+
259
+ return NGX_OK;
260
+ }
261
+
262
+ *v = ngx_http_variable_null_value;
263
+
264
+ return NGX_OK;
265
+ }
266
+
267
+
268
+ static ngx_int_t
269
+ ngx_http_v2_module_init(ngx_cycle_t *cycle)
270
+ {
271
+ return NGX_OK;
272
+ }
273
+
274
+
275
+ static void *
276
+ ngx_http_v2_create_main_conf(ngx_conf_t *cf)
277
+ {
278
+ ngx_http_v2_main_conf_t *h2mcf;
279
+
280
+ h2mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v2_main_conf_t));
281
+ if (h2mcf == NULL) {
282
+ return NULL;
283
+ }
284
+
285
+ h2mcf->recv_buffer_size = NGX_CONF_UNSET_SIZE;
286
+
287
+ return h2mcf;
288
+ }
289
+
290
+
291
+ static char *
292
+ ngx_http_v2_init_main_conf(ngx_conf_t *cf, void *conf)
293
+ {
294
+ ngx_http_v2_main_conf_t *h2mcf = conf;
295
+
296
+ ngx_conf_init_size_value(h2mcf->recv_buffer_size, 256 * 1024);
297
+
298
+ return NGX_CONF_OK;
299
+ }
300
+
301
+
302
+ static void *
303
+ ngx_http_v2_create_srv_conf(ngx_conf_t *cf)
304
+ {
305
+ ngx_http_v2_srv_conf_t *h2scf;
306
+
307
+ h2scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v2_srv_conf_t));
308
+ if (h2scf == NULL) {
309
+ return NULL;
310
+ }
311
+
312
+ h2scf->pool_size = NGX_CONF_UNSET_SIZE;
313
+
314
+ h2scf->concurrent_streams = NGX_CONF_UNSET_UINT;
315
+
316
+ h2scf->max_field_size = NGX_CONF_UNSET_SIZE;
317
+ h2scf->max_header_size = NGX_CONF_UNSET_SIZE;
318
+
319
+ h2scf->streams_index_mask = NGX_CONF_UNSET_UINT;
320
+
321
+ h2scf->recv_timeout = NGX_CONF_UNSET_MSEC;
322
+ h2scf->idle_timeout = NGX_CONF_UNSET_MSEC;
323
+
324
+ return h2scf;
325
+ }
326
+
327
+
328
+ static char *
329
+ ngx_http_v2_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
330
+ {
331
+ ngx_http_v2_srv_conf_t *prev = parent;
332
+ ngx_http_v2_srv_conf_t *conf = child;
333
+
334
+ ngx_conf_merge_size_value(conf->pool_size, prev->pool_size, 4096);
335
+
336
+ ngx_conf_merge_uint_value(conf->concurrent_streams,
337
+ prev->concurrent_streams, 128);
338
+
339
+ ngx_conf_merge_size_value(conf->max_field_size, prev->max_field_size,
340
+ 4096);
341
+ ngx_conf_merge_size_value(conf->max_header_size, prev->max_header_size,
342
+ 16384);
343
+
344
+ ngx_conf_merge_uint_value(conf->streams_index_mask,
345
+ prev->streams_index_mask, 32 - 1);
346
+
347
+ ngx_conf_merge_msec_value(conf->recv_timeout,
348
+ prev->recv_timeout, 30000);
349
+ ngx_conf_merge_msec_value(conf->idle_timeout,
350
+ prev->idle_timeout, 180000);
351
+
352
+ return NGX_CONF_OK;
353
+ }
354
+
355
+
356
+ static void *
357
+ ngx_http_v2_create_loc_conf(ngx_conf_t *cf)
358
+ {
359
+ ngx_http_v2_loc_conf_t *h2lcf;
360
+
361
+ h2lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v2_loc_conf_t));
362
+ if (h2lcf == NULL) {
363
+ return NULL;
364
+ }
365
+
366
+ h2lcf->chunk_size = NGX_CONF_UNSET_SIZE;
367
+
368
+ return h2lcf;
369
+ }
370
+
371
+
372
+ static char *
373
+ ngx_http_v2_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
374
+ {
375
+ ngx_http_v2_loc_conf_t *prev = parent;
376
+ ngx_http_v2_loc_conf_t *conf = child;
377
+
378
+ ngx_conf_merge_size_value(conf->chunk_size, prev->chunk_size, 8 * 1024);
379
+
380
+ return NGX_CONF_OK;
381
+ }
382
+
383
+
384
+ static char *
385
+ ngx_http_v2_recv_buffer_size(ngx_conf_t *cf, void *post, void *data)
386
+ {
387
+ size_t *sp = data;
388
+
389
+ if (*sp <= 2 * NGX_HTTP_V2_STATE_BUFFER_SIZE) {
390
+ return "value is too small";
391
+ }
392
+
393
+ return NGX_CONF_OK;
394
+ }
395
+
396
+
397
+ static char *
398
+ ngx_http_v2_pool_size(ngx_conf_t *cf, void *post, void *data)
399
+ {
400
+ size_t *sp = data;
401
+
402
+ if (*sp < NGX_MIN_POOL_SIZE) {
403
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
404
+ "the pool size must be no less than %uz",
405
+ NGX_MIN_POOL_SIZE);
406
+
407
+ return NGX_CONF_ERROR;
408
+ }
409
+
410
+ if (*sp % NGX_POOL_ALIGNMENT) {
411
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
412
+ "the pool size must be a multiple of %uz",
413
+ NGX_POOL_ALIGNMENT);
414
+
415
+ return NGX_CONF_ERROR;
416
+ }
417
+
418
+ return NGX_CONF_OK;
419
+ }
420
+
421
+
422
+ static char *
423
+ ngx_http_v2_streams_index_mask(ngx_conf_t *cf, void *post, void *data)
424
+ {
425
+ ngx_uint_t *np = data;
426
+
427
+ ngx_uint_t mask;
428
+
429
+ mask = *np - 1;
430
+
431
+ if (*np == 0 || (*np & mask)) {
432
+ return "must be a power of two";
433
+ }
434
+
435
+ *np = mask;
436
+
437
+ return NGX_CONF_OK;
438
+ }
439
+
440
+
441
+ static char *
442
+ ngx_http_v2_chunk_size(ngx_conf_t *cf, void *post, void *data)
443
+ {
444
+ size_t *sp = data;
445
+
446
+ if (*sp == 0) {
447
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
448
+ "the http2 chunk size cannot be zero");
449
+
450
+ return NGX_CONF_ERROR;
451
+ }
452
+
453
+ if (*sp > NGX_HTTP_V2_MAX_FRAME_SIZE) {
454
+ *sp = NGX_HTTP_V2_MAX_FRAME_SIZE;
455
+ }
456
+
457
+ return NGX_CONF_OK;
458
+ }
459
+
460
+
461
+ static char *
462
+ ngx_http_v2_spdy_deprecated(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
463
+ {
464
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
465
+ "invalid directive \"%V\": ngx_http_spdy_module "
466
+ "was superseded by ngx_http_v2_module", &cmd->name);
467
+
468
+ return NGX_CONF_OK;
469
+ }