mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-07 02:28:53 +08:00
Compare commits
674 Commits
nghttpx-us
...
v1.37.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfb47d30a5 | ||
|
|
dbbe4e017a | ||
|
|
371bc3a8f7 | ||
|
|
5e7889c5ef | ||
|
|
b1b2ad5017 | ||
|
|
e043ca83c5 | ||
|
|
c2434dfbbc | ||
|
|
816ad2102f | ||
|
|
f5feb16ef4 | ||
|
|
adf09f2124 | ||
|
|
2591960e2f | ||
|
|
d93842db3e | ||
|
|
8dc2b263ba | ||
|
|
8d842701b5 | ||
|
|
de85b0fda5 | ||
|
|
5d6beed590 | ||
|
|
1ff9de4c87 | ||
|
|
34482ed4df | ||
|
|
9b6ced66f3 | ||
|
|
e7e8ee5fe6 | ||
|
|
b3b4e33535 | ||
|
|
bd93d90a89 | ||
|
|
ea69c84b33 | ||
|
|
783b649bb1 | ||
|
|
eb21e6f8f7 | ||
|
|
ab2aa5672b | ||
|
|
ff87a54202 | ||
|
|
439dbce679 | ||
|
|
e9c9838cdc | ||
|
|
803d4ba948 | ||
|
|
732245e562 | ||
|
|
9e8d5433e7 | ||
|
|
fdcdb21c38 | ||
|
|
11d0533cfc | ||
|
|
dbb5f00d68 | ||
|
|
9cc412e2fd | ||
|
|
5b2efc0a12 | ||
|
|
7e4c48a461 | ||
|
|
082e162f3c | ||
|
|
7cc7c06c7b | ||
|
|
12ebeb30d0 | ||
|
|
c78abbe1d2 | ||
|
|
124c7848c0 | ||
|
|
ce9667c4f5 | ||
|
|
f3f40840b3 | ||
|
|
302abf1b46 | ||
|
|
089a03be42 | ||
|
|
de4fe72861 | ||
|
|
d1b3a83f59 | ||
|
|
eb6792533d | ||
|
|
6800d317e7 | ||
|
|
c98362eab1 | ||
|
|
e520469b3e | ||
|
|
54067256eb | ||
|
|
c4d2eeeec7 | ||
|
|
f51e696e4a | ||
|
|
a433b132fc | ||
|
|
cf48a56d2e | ||
|
|
6cad1b243b | ||
|
|
3c393dca58 | ||
|
|
172924457f | ||
|
|
f6644a92af | ||
|
|
48998f7239 | ||
|
|
15ff52f9fb | ||
|
|
6c03bb142b | ||
|
|
524b439221 | ||
|
|
859bf2bc41 | ||
|
|
b5619fb156 | ||
|
|
dcbe0c690f | ||
|
|
2996c28456 | ||
|
|
42e8ceb656 | ||
|
|
1daf9ce8b7 | ||
|
|
d68edf56c0 | ||
|
|
0c4e9fef29 | ||
|
|
571404c6e8 | ||
|
|
4d562b773b | ||
|
|
e62258713e | ||
|
|
4bd075defd | ||
|
|
b46a324943 | ||
|
|
4bd44b9cdf | ||
|
|
1b42110d4f | ||
|
|
0735ec55f3 | ||
|
|
00554779e1 | ||
|
|
0963f38935 | ||
|
|
1abfa3ca5f | ||
|
|
f2159bc2c1 | ||
|
|
b0eb68ee9e | ||
|
|
e7b7b037f6 | ||
|
|
5e4f434fd8 | ||
|
|
20ea964f2f | ||
|
|
d105619bc3 | ||
|
|
ec5729b1fa | ||
|
|
6c9196953e | ||
|
|
46576178a3 | ||
|
|
5e925f873e | ||
|
|
153531d4d0 | ||
|
|
f7287df03f | ||
|
|
2b085815b7 | ||
|
|
986fa30264 | ||
|
|
7c8cb3a0ce | ||
|
|
334c439ce0 | ||
|
|
6c17ed7e61 | ||
|
|
6700626c30 | ||
|
|
15162addc4 | ||
|
|
9327077741 | ||
|
|
aeb92bbbe2 | ||
|
|
fc7489e044 | ||
|
|
87ac872fdc | ||
|
|
c278adde7a | ||
|
|
f94d720909 | ||
|
|
9b9baa6bd9 | ||
|
|
02566ee383 | ||
|
|
3002f31b1f | ||
|
|
d2a594a753 | ||
|
|
651e147711 | ||
|
|
a42faf1cc2 | ||
|
|
4aac05e193 | ||
|
|
b80dfaa8a0 | ||
|
|
a19d8f5d31 | ||
|
|
33f6e90a56 | ||
|
|
ed7fabcbc2 | ||
|
|
8753b6da14 | ||
|
|
f2de733bdf | ||
|
|
88ff8c69a0 | ||
|
|
a63558a1eb | ||
|
|
3575a1325e | ||
|
|
e2de2fee69 | ||
|
|
9f415979fb | ||
|
|
4bfc0cd196 | ||
|
|
9c824b87fe | ||
|
|
a1ea1696be | ||
|
|
dfc0f248c6 | ||
|
|
ed7c9db2a6 | ||
|
|
5b42815afb | ||
|
|
cfe7fa9a75 | ||
|
|
cb8a9d58fd | ||
|
|
023b94480b | ||
|
|
9b03c64f68 | ||
|
|
b8eccec62d | ||
|
|
9f21258720 | ||
|
|
47f6012407 | ||
|
|
770e44de4d | ||
|
|
2ab319c137 | ||
|
|
3992302432 | ||
|
|
b30f312a70 | ||
|
|
c5cdb78a95 | ||
|
|
d82811303b | ||
|
|
f79a58120e | ||
|
|
9d843334d6 | ||
|
|
23cb3f38a6 | ||
|
|
1d682dcdae | ||
|
|
601fbbb4ae | ||
|
|
f44aa2466f | ||
|
|
dd74a6dd34 | ||
|
|
e959e7338e | ||
|
|
fb9a204de2 | ||
|
|
cd096802bd | ||
|
|
7417fd71a4 | ||
|
|
2d1a981c81 | ||
|
|
45acc922eb | ||
|
|
214d089910 | ||
|
|
31fd707d0c | ||
|
|
9a2e38e058 | ||
|
|
d24527e7e6 | ||
|
|
6195d747ce | ||
|
|
fb97f596e1 | ||
|
|
0ccc7a770d | ||
|
|
32826466f5 | ||
|
|
0422f8a844 | ||
|
|
e329479a99 | ||
|
|
f80a7873ba | ||
|
|
866ac6ab27 | ||
|
|
b574ae6aa2 | ||
|
|
de4fd7cd35 | ||
|
|
32d7883c47 | ||
|
|
9b24e19763 | ||
|
|
13ffece12d | ||
|
|
9d5b781df6 | ||
|
|
11d822c2a7 | ||
|
|
4098512b5d | ||
|
|
7e06ac1072 | ||
|
|
c6d8c4013c | ||
|
|
e5b3f9addd | ||
|
|
880f948684 | ||
|
|
bda7e079e2 | ||
|
|
fc94018b97 | ||
|
|
159c5e446a | ||
|
|
bfd4d8b052 | ||
|
|
388e785822 | ||
|
|
2ba1389993 | ||
|
|
d65a417306 | ||
|
|
575bc309b9 | ||
|
|
00909d0742 | ||
|
|
a7e38724e7 | ||
|
|
325612bcde | ||
|
|
8034221525 | ||
|
|
2e6593e5a5 | ||
|
|
572735e496 | ||
|
|
e8d693c395 | ||
|
|
f44dfcd9dc | ||
|
|
1f1b0d93d4 | ||
|
|
ce8c749b77 | ||
|
|
3e4f257b91 | ||
|
|
86fab997b4 | ||
|
|
c3ecd44592 | ||
|
|
c65ca20a49 | ||
|
|
a5c408c5e3 | ||
|
|
06379b2861 | ||
|
|
e04de48ed9 | ||
|
|
009646421c | ||
|
|
8d0b4544f8 | ||
|
|
d8a34131e1 | ||
|
|
5db17d0af9 | ||
|
|
1bf69b5662 | ||
|
|
3febaef1fa | ||
|
|
b1bd6035e8 | ||
|
|
b48bcb214a | ||
|
|
6f3ce2c72d | ||
|
|
2f9121cf44 | ||
|
|
e65e7711ca | ||
|
|
636ef51b0f | ||
|
|
400934e5a3 | ||
|
|
4c3a3acf9b | ||
|
|
9aa6002c37 | ||
|
|
f342260bfe | ||
|
|
a6dd497016 | ||
|
|
842509dab6 | ||
|
|
4add618a3f | ||
|
|
6e74466231 | ||
|
|
478eac099f | ||
|
|
88e2029e37 | ||
|
|
45d76cf501 | ||
|
|
54573f28a8 | ||
|
|
17793e99dc | ||
|
|
5eac3c9025 | ||
|
|
e70195ae91 | ||
|
|
fe51e7fa1a | ||
|
|
eb951c2ce4 | ||
|
|
39f0ce7c25 | ||
|
|
65157811d4 | ||
|
|
e8af7afc65 | ||
|
|
38abfd1863 | ||
|
|
ff3edc09ed | ||
|
|
0bb1540682 | ||
|
|
f0836c7e39 | ||
|
|
25db178b7d | ||
|
|
1b6713e6ec | ||
|
|
c1a496cf4e | ||
|
|
e098a21132 | ||
|
|
0ba4bf51e4 | ||
|
|
6deee2037d | ||
|
|
6761a933fe | ||
|
|
5cc3d159e1 | ||
|
|
652f57e79d | ||
|
|
acd6b40e4c | ||
|
|
0fbb46edd6 | ||
|
|
6ad629de47 | ||
|
|
74754982f1 | ||
|
|
a31a2e3b2c | ||
|
|
a776b0dbcc | ||
|
|
cfd926f09b | ||
|
|
72f52716ae | ||
|
|
439b9b6c6a | ||
|
|
4849845292 | ||
|
|
d30f38163c | ||
|
|
cff9ebe1dd | ||
|
|
4d1139f653 | ||
|
|
48f574076c | ||
|
|
c1f14d73c7 | ||
|
|
216f4dad83 | ||
|
|
a4e27d766b | ||
|
|
96df14d2ec | ||
|
|
2365f12e39 | ||
|
|
96ea9cdaf7 | ||
|
|
03f7ec0f60 | ||
|
|
a941699962 | ||
|
|
2056e812bd | ||
|
|
04348ff20e | ||
|
|
d8e378fea9 | ||
|
|
1ebb6810a1 | ||
|
|
2a694b270a | ||
|
|
a3ebeeafba | ||
|
|
422ad1be32 | ||
|
|
97f1735cf5 | ||
|
|
939ad5ddbe | ||
|
|
24d92b979d | ||
|
|
4c92ff1843 | ||
|
|
280db5c6ba | ||
|
|
7fbcb2d005 | ||
|
|
53aeb2c3d7 | ||
|
|
ff200bfcf3 | ||
|
|
fee3151fd2 | ||
|
|
99a85159ae | ||
|
|
2a981a3f56 | ||
|
|
0028275d7b | ||
|
|
ee8bfddfc9 | ||
|
|
194acb1f2c | ||
|
|
43a2a70ae7 | ||
|
|
73344ae9aa | ||
|
|
c479f6122f | ||
|
|
eca0a3025b | ||
|
|
4720c5cb3d | ||
|
|
cd55ab28ab | ||
|
|
d402cfdf16 | ||
|
|
22502182d0 | ||
|
|
05e1fd5e77 | ||
|
|
943d7923f9 | ||
|
|
568ecbfb28 | ||
|
|
f5ddd7f43b | ||
|
|
88abbce7e7 | ||
|
|
16e9036568 | ||
|
|
fa7945c627 | ||
|
|
daca43f0dd | ||
|
|
16bc11e670 | ||
|
|
6f7e94cdba | ||
|
|
61efa15a14 | ||
|
|
8c0ea56bb8 | ||
|
|
549053710b | ||
|
|
6010d39325 | ||
|
|
be5c39a1cf | ||
|
|
b8fda6808b | ||
|
|
e29b9c1261 | ||
|
|
539e27812b | ||
|
|
7008afd40e | ||
|
|
77a41756db | ||
|
|
b15045d60e | ||
|
|
03084f7517 | ||
|
|
60baca27e4 | ||
|
|
86990db236 | ||
|
|
cb376bcd80 | ||
|
|
f2b8edd1e2 | ||
|
|
c4f8afcfde | ||
|
|
1a1a216d5a | ||
|
|
9f80a82c1a | ||
|
|
c573c80bd3 | ||
|
|
3cd6817e21 | ||
|
|
d4a69658a1 | ||
|
|
8e06fe4971 | ||
|
|
aaeeec8f1c | ||
|
|
66d5e24606 | ||
|
|
e8907a073f | ||
|
|
9656ac0254 | ||
|
|
75624617ce | ||
|
|
1a8f6578b3 | ||
|
|
4f0548b018 | ||
|
|
5119e82b93 | ||
|
|
3be5856c82 | ||
|
|
a319143901 | ||
|
|
17c88d60c7 | ||
|
|
7601511fdf | ||
|
|
f507b5eee4 | ||
|
|
93821165be | ||
|
|
aaa0b858e4 | ||
|
|
5fa1938691 | ||
|
|
56ee3d4820 | ||
|
|
c2d9a1ed6f | ||
|
|
fcf9ab2798 | ||
|
|
35e445bd04 | ||
|
|
88ce3c31b7 | ||
|
|
16320a0f81 | ||
|
|
8c72fb3539 | ||
|
|
8ffe389daa | ||
|
|
189a4516a1 | ||
|
|
2576855ded | ||
|
|
7d4d48a35e | ||
|
|
cc6f759190 | ||
|
|
c23fc86a23 | ||
|
|
d2324bdda1 | ||
|
|
6f0ae9d49a | ||
|
|
0389af5724 | ||
|
|
1766e25f45 | ||
|
|
323001238a | ||
|
|
91f062f873 | ||
|
|
650a0cfbff | ||
|
|
e6b8b3d1d3 | ||
|
|
a170023f23 | ||
|
|
4be4c0cddc | ||
|
|
0de9d374df | ||
|
|
0df199198a | ||
|
|
7646e376e0 | ||
|
|
5996798a34 | ||
|
|
6fec532012 | ||
|
|
15713e0b7c | ||
|
|
a6a561af47 | ||
|
|
09c468a4b4 | ||
|
|
bcda1c2409 | ||
|
|
afcd8d9ab1 | ||
|
|
c9b1c91944 | ||
|
|
5d9434eb09 | ||
|
|
1a44b5d52a | ||
|
|
6635ca5e26 | ||
|
|
9c6c78833b | ||
|
|
9a9ab0813c | ||
|
|
0ccaaa48ce | ||
|
|
3f2fe98dd1 | ||
|
|
0d91e9c255 | ||
|
|
af926fbe1f | ||
|
|
83039ae2d4 | ||
|
|
4c53da6961 | ||
|
|
eb306f463e | ||
|
|
788835c5fd | ||
|
|
4d76606fa2 | ||
|
|
1baf7d34b3 | ||
|
|
c78159469a | ||
|
|
b72ca0289c | ||
|
|
46f670f8a2 | ||
|
|
4b44362b9f | ||
|
|
d068a29798 | ||
|
|
0836a51408 | ||
|
|
566cee8fe7 | ||
|
|
e85698e131 | ||
|
|
5f3c541c4c | ||
|
|
3c43e00d8a | ||
|
|
92d686d356 | ||
|
|
0f69e9c825 | ||
|
|
217d979458 | ||
|
|
cc289972fc | ||
|
|
c601e603c2 | ||
|
|
1002c6da1c | ||
|
|
0911337689 | ||
|
|
3bcc416e13 | ||
|
|
65837806f5 | ||
|
|
b0772dcc66 | ||
|
|
c6d65aad3b | ||
|
|
18dd20ce55 | ||
|
|
0f6d76a501 | ||
|
|
0f1320109f | ||
|
|
defa28c618 | ||
|
|
b7c95be47c | ||
|
|
a18d154e0e | ||
|
|
52195a12ee | ||
|
|
59c78d5809 | ||
|
|
be164fc8f9 | ||
|
|
5833ef1efc | ||
|
|
28f88d46f3 | ||
|
|
6ec7683991 | ||
|
|
fb2d8f79d6 | ||
|
|
8f7fa1b1bf | ||
|
|
e5889ce622 | ||
|
|
3a6f83394c | ||
|
|
acf36f3d1a | ||
|
|
63e6a8bab2 | ||
|
|
5361cc6bd1 | ||
|
|
cabac55394 | ||
|
|
db7483ef10 | ||
|
|
4b51ccbefe | ||
|
|
74c2f1257a | ||
|
|
1428a5e3ae | ||
|
|
fe021c1524 | ||
|
|
c57bf21306 | ||
|
|
1743b7d92d | ||
|
|
7f31278c4c | ||
|
|
8401e16a15 | ||
|
|
07fb5854f3 | ||
|
|
b56a99bfba | ||
|
|
b91e4e4df1 | ||
|
|
52a4d6ac31 | ||
|
|
796ab87b14 | ||
|
|
ed1fad3bd4 | ||
|
|
9c1876f542 | ||
|
|
7d111d9963 | ||
|
|
8c2ce0cf3f | ||
|
|
1b442cb16f | ||
|
|
2bf3680d87 | ||
|
|
0d4f0f0db5 | ||
|
|
e17ff8fd32 | ||
|
|
14edd12304 | ||
|
|
e6ffdb23a4 | ||
|
|
98fdedac06 | ||
|
|
255037264a | ||
|
|
d3fcbe9a02 | ||
|
|
bcdd588c6e | ||
|
|
b5007d45f7 | ||
|
|
a584cf5a4f | ||
|
|
77f7a2fa7f | ||
|
|
f2c539dc70 | ||
|
|
78d7160a99 | ||
|
|
196673bbce | ||
|
|
794d13082c | ||
|
|
5f5cf4107e | ||
|
|
6f3ec54b9f | ||
|
|
58043a6b04 | ||
|
|
a885315ef5 | ||
|
|
d7581525ac | ||
|
|
385068eb91 | ||
|
|
1085f68018 | ||
|
|
21af775ce0 | ||
|
|
bf16fee6e9 | ||
|
|
2358a2137a | ||
|
|
66baa7dc25 | ||
|
|
d63b4c1034 | ||
|
|
963e220a1c | ||
|
|
2f146e4d4c | ||
|
|
f796eede5a | ||
|
|
c89453be95 | ||
|
|
c3f5f5ca36 | ||
|
|
911d12f7c4 | ||
|
|
34d3c45d35 | ||
|
|
17614312e0 | ||
|
|
977779ae8d | ||
|
|
a2e35a0757 | ||
|
|
a4a2b6403b | ||
|
|
8ce8e289c9 | ||
|
|
03be97e437 | ||
|
|
2c5cf5a82a | ||
|
|
0a2d1965df | ||
|
|
c8a5f1e335 | ||
|
|
5e00cf9620 | ||
|
|
ce6370e25c | ||
|
|
3f8c1e4b34 | ||
|
|
25cda200be | ||
|
|
a1bc83a2ba | ||
|
|
bc3949db9e | ||
|
|
6cfa885207 | ||
|
|
899588e0b5 | ||
|
|
49af52a68d | ||
|
|
ec908af19c | ||
|
|
e61ac4682e | ||
|
|
4d10dce61d | ||
|
|
c569830dfc | ||
|
|
2d9fd87029 | ||
|
|
2670bfb8ba | ||
|
|
cc9190ab37 | ||
|
|
980570de71 | ||
|
|
ef92b54db3 | ||
|
|
0130124cea | ||
|
|
e2a7e867f9 | ||
|
|
32ce0ce5d9 | ||
|
|
28082ff5f5 | ||
|
|
46ccc4332c | ||
|
|
3a1217e667 | ||
|
|
39fd0c1278 | ||
|
|
4e6bd54dd1 | ||
|
|
5c9f46a6b0 | ||
|
|
7d53866157 | ||
|
|
9a2e948c42 | ||
|
|
223e971c7e | ||
|
|
df814223ff | ||
|
|
82b326e684 | ||
|
|
6aa581d2f0 | ||
|
|
8c0b2c684a | ||
|
|
62324781bd | ||
|
|
7ae0b2dc09 | ||
|
|
058122b804 | ||
|
|
69f63c529d | ||
|
|
e17a6b29b6 | ||
|
|
b12c2a13c0 | ||
|
|
236c835abc | ||
|
|
b41a5afe04 | ||
|
|
ad338bfa44 | ||
|
|
a899522679 | ||
|
|
b9b58c781e | ||
|
|
aa1eec4642 | ||
|
|
0c8d9469ea | ||
|
|
079e1bdffc | ||
|
|
b4337d1b54 | ||
|
|
e6a11c5e12 | ||
|
|
dbe287ff5e | ||
|
|
61dc1a7c62 | ||
|
|
dc1e0c0195 | ||
|
|
041531458b | ||
|
|
1374bb81fd | ||
|
|
f41ac103d3 | ||
|
|
f6301714db | ||
|
|
7dc39b1ee9 | ||
|
|
696a7ce407 | ||
|
|
d28d788623 | ||
|
|
99122ee7bb | ||
|
|
19ee7ec794 | ||
|
|
cd9ec0d20f | ||
|
|
e77883e980 | ||
|
|
0994c92550 | ||
|
|
465c7208cc | ||
|
|
4f9f181f07 | ||
|
|
b7e7a4bf26 | ||
|
|
c7df65309b | ||
|
|
26900262f3 | ||
|
|
9b5ce36368 | ||
|
|
f69b52b1aa | ||
|
|
1e1d908c12 | ||
|
|
6c69d675da | ||
|
|
feabd6f739 | ||
|
|
1ea590c364 | ||
|
|
b21779e685 | ||
|
|
12a4e7c3a2 | ||
|
|
799a76de74 | ||
|
|
b1fee8ff63 | ||
|
|
9cc223d419 | ||
|
|
20edd64301 | ||
|
|
9aee518352 | ||
|
|
6ca515ea70 | ||
|
|
51b933c5f0 | ||
|
|
3f13d33543 | ||
|
|
85a12429ee | ||
|
|
3e0e3f5459 | ||
|
|
801869a5d5 | ||
|
|
54f4b85beb | ||
|
|
fa074145a4 | ||
|
|
b2d6550179 | ||
|
|
62dd1f5177 | ||
|
|
dc7c12d474 | ||
|
|
a6dda5f91c | ||
|
|
c1f7795dd6 | ||
|
|
4989e6e419 | ||
|
|
d4963bcd32 | ||
|
|
d725255784 | ||
|
|
5f4159a0d7 | ||
|
|
0a2a5e6604 | ||
|
|
acd05f2aa5 | ||
|
|
bb7718a64a | ||
|
|
e59fc725ab | ||
|
|
4fcd0fc144 | ||
|
|
373be22d7e | ||
|
|
b647a7c5b7 | ||
|
|
46ba9e080d | ||
|
|
e1b8317ae8 | ||
|
|
ea67864e08 | ||
|
|
6b286e0d94 | ||
|
|
d10ea5ea06 | ||
|
|
2af57c3cfc | ||
|
|
0c8b1a4f74 | ||
|
|
9d16292fe4 | ||
|
|
e2b9590c0f | ||
|
|
24fb640a55 | ||
|
|
e6a05cb66d | ||
|
|
12f9b09845 | ||
|
|
102b98813f | ||
|
|
1f55e5d34d | ||
|
|
5618e1bbc9 | ||
|
|
450ffaa6f0 | ||
|
|
dc15832030 | ||
|
|
0797e89a90 | ||
|
|
9f1543f81e | ||
|
|
a7c780a732 | ||
|
|
1bd6893084 | ||
|
|
ae21130b13 | ||
|
|
e06ed85747 | ||
|
|
83fd72c97e | ||
|
|
ace40f298d | ||
|
|
1133cc0bbc | ||
|
|
6960039aee | ||
|
|
bf5eeb831b | ||
|
|
e5b84fad09 | ||
|
|
cfb39171a7 | ||
|
|
2f6e1ac336 | ||
|
|
9e8d9d658a | ||
|
|
6ecfac6954 | ||
|
|
368775c2ed | ||
|
|
1e9a094edd | ||
|
|
ceb4dcf3b2 | ||
|
|
d2ef80fe3a | ||
|
|
79ae5aed67 | ||
|
|
56e86cd944 | ||
|
|
19a311ad62 | ||
|
|
b36e53cccd | ||
|
|
f3a5a0a0ec | ||
|
|
001d45efad | ||
|
|
56c455bca4 | ||
|
|
4bf3cb2cc0 | ||
|
|
c78528d54b | ||
|
|
f994664934 | ||
|
|
44e290da66 | ||
|
|
8aed101585 | ||
|
|
54ba1bebf2 | ||
|
|
e44c58282e | ||
|
|
c02b1041d9 | ||
|
|
0d20e07436 | ||
|
|
b7f956c967 | ||
|
|
786f52a81c | ||
|
|
23209baaf5 | ||
|
|
9d2503f9c0 | ||
|
|
1c31213aef | ||
|
|
fdb75ba5fe | ||
|
|
3ddc446ba2 |
@@ -4,7 +4,7 @@ AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
@@ -16,10 +16,10 @@ AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
@@ -28,17 +28,25 @@ BraceWrapping:
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
@@ -46,8 +54,13 @@ Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
IncludeCategories:
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||
@@ -56,6 +69,7 @@ IncludeCategories:
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '$'
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
@@ -65,21 +79,30 @@ MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -3,4 +3,5 @@
|
||||
url = https://github.com/mruby/mruby
|
||||
[submodule "third-party/neverbleed"]
|
||||
path = third-party/neverbleed
|
||||
url = https://github.com/h2o/neverbleed.git
|
||||
url = https://github.com/tatsuhiro-t/neverbleed.git
|
||||
branch = openssl111fix
|
||||
|
||||
26
.travis.yml
26
.travis.yml
@@ -1,3 +1,4 @@
|
||||
dist: xenial
|
||||
env:
|
||||
matrix:
|
||||
- CI_BUILD=cmake
|
||||
@@ -6,15 +7,13 @@ language: cpp
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
sudo: false
|
||||
sudo: required
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- george-edison55-precise-backports
|
||||
packages:
|
||||
- g++-4.9
|
||||
- libstdc++-4.9-dev
|
||||
- g++-8
|
||||
- autoconf
|
||||
- automake
|
||||
- autotools-dev
|
||||
@@ -33,29 +32,18 @@ addons:
|
||||
- cmake-data
|
||||
before_install:
|
||||
- $CC --version
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-8" CC="gcc-8"; fi
|
||||
- $CC --version
|
||||
- go version
|
||||
- cmake --version
|
||||
before_script:
|
||||
# First build spdylay, since integration tests require it.
|
||||
# spdylay is going to be built under third-party/spdylay
|
||||
- cd third-party
|
||||
- git clone https://github.com/tatsuhiro-t/spdylay.git
|
||||
- cd spdylay
|
||||
- autoreconf -i
|
||||
# Don't use ASAN for spdylay since failmalloc does not work with it.
|
||||
- ./configure --disable-src --disable-examples
|
||||
- make check
|
||||
- export SPDYLAY_HOME=$PWD
|
||||
- cd ../..
|
||||
# Now build nghttp2
|
||||
- if [ "$CI_BUILD" = "autotools" ]; then autoreconf -i; fi
|
||||
- git submodule update --init
|
||||
- if [ "$CI_BUILD" = "autotools" ]; then ./configure --enable-werror --with-mruby --with-neverbleed LIBSPDYLAY_CFLAGS="-I$SPDYLAY_HOME/lib/includes" LIBSPDYLAY_LIBS="-L$SPDYLAY_HOME/lib/.libs -lspdylay" CPPFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address; fi
|
||||
- if [ "$CI_BUILD" = "cmake" ]; then cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1 -DSPDYLAY_INCLUDE_DIR="$SPDYLAY_HOME/lib/includes" -DSPDYLAY_LIBRARY="$SPDYLAY_HOME/lib/.libs/libspdylay.so"; fi
|
||||
- if [ "$CI_BUILD" = "autotools" ]; then ./configure --with-mruby; fi
|
||||
- if [ "$CI_BUILD" = "cmake" ]; then cmake -DENABLE_WERROR=1 -DWITH_MRUBY=1 -DWITH_NEVERBLEED=1; fi
|
||||
script:
|
||||
- if [ "$CI_BUILD" = "autotools" ]; then make distcheck; fi
|
||||
- if [ "$CI_BUILD" = "autotools" ]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="--with-mruby --with-neverbleed --enable-werror CPPFLAGS=-fsanitize=address LDFLAGS=\"-fsanitize=address -fuse-ld=gold\""; fi
|
||||
- if [ "$CI_BUILD" = "cmake" ]; then make check; fi
|
||||
# As of April, 23, 2016, golang http2 build fails, probably because
|
||||
# the default go version is too old.
|
||||
|
||||
31
AUTHORS
31
AUTHORS
@@ -16,30 +16,43 @@ github issues [2].
|
||||
187j3x1
|
||||
Alek Storm
|
||||
Alex Nalivko
|
||||
Alexandros Konstantinakis-Karmis
|
||||
Alexis La Goutte
|
||||
Amir Pakdel
|
||||
Anders Bakken
|
||||
Andreas Pohl
|
||||
Andy Davies
|
||||
Angus Gratton
|
||||
Anna Henningsen
|
||||
Ant Bryan
|
||||
Benedikt Christoph Wolters
|
||||
Benjamin Peterson
|
||||
Bernard Spil
|
||||
Brendan Heinonen
|
||||
Brian Card
|
||||
Brian Suh
|
||||
Daniel Evers
|
||||
Daniel Stenberg
|
||||
Dave Reisner
|
||||
David Beitey
|
||||
David Weekly
|
||||
Dmitriy Vetutnev
|
||||
Don
|
||||
Dylan Plecki
|
||||
Etienne Cimon
|
||||
Fabian Möller
|
||||
Fabian Wiesel
|
||||
Gabi Davar
|
||||
Gitai
|
||||
Google Inc.
|
||||
Jacob Champion
|
||||
Jan Kundrát
|
||||
Jan-E
|
||||
Janusz Dziemidowicz
|
||||
Jay Satiro
|
||||
Jianqing Wang
|
||||
Jim Morrison
|
||||
Josh Braegger
|
||||
José F. Calcerrada
|
||||
Kamil Dudka
|
||||
Kazuho Oku
|
||||
@@ -47,32 +60,46 @@ Kenny (kang-yen) Peng
|
||||
Kenny Peng
|
||||
Kit Chan
|
||||
Kyle Schomp
|
||||
LazyHamster
|
||||
Lucas Pardue
|
||||
MATSUMOTO Ryosuke
|
||||
Marc Bachmann
|
||||
Matt Rudary
|
||||
Matt Way
|
||||
Mike Conlen
|
||||
Mike Frysinger
|
||||
Mike Lothian
|
||||
Nicholas Hurley
|
||||
Nora Shoemaker
|
||||
Pedro Santos
|
||||
Peeyush Aggarwal
|
||||
Peter Wu
|
||||
Piotr Sikora
|
||||
Raul Gutierrez Segales
|
||||
Remo E
|
||||
Reza Tavakoli
|
||||
Rick Lei
|
||||
Ross Smith II
|
||||
Scott Mitchell
|
||||
Sebastiaan Deckers
|
||||
Simon Frankenberger
|
||||
Simone Basso
|
||||
Soham Sinha
|
||||
Stefan Eissing
|
||||
Stephen Ludin
|
||||
Sunpoet Po-Chuan Hsieh
|
||||
Svante Signell
|
||||
Syohei YOSHIDA
|
||||
Tapanito
|
||||
Tatsuhiko Kubo
|
||||
Tatsuhiro Tsujikawa
|
||||
Tobias Geerinckx-Rice
|
||||
Tom Harwood
|
||||
Tomasz Buchert
|
||||
Tomasz Torcz
|
||||
Vernon Tang
|
||||
Viacheslav Biriukov
|
||||
Viktor Szakats
|
||||
Viktor Szépe
|
||||
Wenfeng Liu
|
||||
Xiaoguang Sun
|
||||
@@ -80,10 +107,14 @@ Zhuoyun Wei
|
||||
acesso
|
||||
ayanamist
|
||||
bxshi
|
||||
clemahieu
|
||||
dalf
|
||||
dawg
|
||||
es
|
||||
fangdingjun
|
||||
jwchoi
|
||||
kumagi
|
||||
lstefani
|
||||
makovich
|
||||
mod-h2-dev
|
||||
moparisthebest
|
||||
|
||||
@@ -24,15 +24,15 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
# XXX using 1.8.90 instead of 1.9.0-DEV
|
||||
project(nghttp2 VERSION 1.19.90)
|
||||
project(nghttp2 VERSION 1.37.0)
|
||||
|
||||
# See versioning rule:
|
||||
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||
set(LT_CURRENT 26)
|
||||
set(LT_REVISION 4)
|
||||
set(LT_AGE 12)
|
||||
set(LT_CURRENT 31)
|
||||
set(LT_REVISION 2)
|
||||
set(LT_AGE 17)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
include(Version)
|
||||
|
||||
math(EXPR LT_SOVERSION "${LT_CURRENT} - ${LT_AGE}")
|
||||
@@ -79,7 +79,7 @@ else()
|
||||
set(ENABLE_PYTHON_BINDINGS_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
find_package(LibXml2 2.7.7)
|
||||
find_package(LibXml2 2.6.26)
|
||||
set(WITH_LIBXML2_DEFAULT ${LIBXML2_FOUND})
|
||||
find_package(Jemalloc)
|
||||
set(WITH_JEMALLOC_DEFAULT ${JEMALLOC_FOUND})
|
||||
@@ -106,28 +106,18 @@ endif()
|
||||
foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
foreach(_lang C CXX)
|
||||
string(TOUPPER "CMAKE_${_lang}_FLAGS_${_build_type}" _var)
|
||||
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" "" ${_var} "${${_var}}")
|
||||
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " ${_var} "${${_var}}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
#
|
||||
# If we're running GCC or clang define _U_ to be "__attribute__((unused))"
|
||||
# so we can use _U_ to flag unused function parameters and not get warnings
|
||||
# about them. Otherwise, define _U_ to be an empty string so that _U_ used
|
||||
# to flag an unused function parameters will compile with other compilers.
|
||||
#
|
||||
# XXX - similar hints for other compilers?
|
||||
#
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(HINT_UNUSED_PARAM "__attribute__((unused))")
|
||||
set(HINT_NORETURN "__attribute__((noreturn))")
|
||||
else()
|
||||
set(HINT_UNUSED_PARAM)
|
||||
set(HINT_NORETURN)
|
||||
endif()
|
||||
|
||||
include(ExtractValidFlags)
|
||||
foreach(_cxx1x_flag -std=c++11 -std=c++0x)
|
||||
foreach(_cxx1x_flag -std=c++14)
|
||||
extract_valid_cxx_flags(_cxx1x_flag_supported ${_cxx1x_flag})
|
||||
if(_cxx1x_flag_supported)
|
||||
set(CXX1XCXXFLAGS ${_cxx1x_flag})
|
||||
@@ -312,6 +302,7 @@ check_type_size("time_t" SIZEOF_TIME_T)
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(_Exit HAVE__EXIT)
|
||||
check_function_exists(accept4 HAVE_ACCEPT4)
|
||||
check_function_exists(mkostemp HAVE_MKOSTEMP)
|
||||
|
||||
include(CheckSymbolExists)
|
||||
# XXX does this correctly detect initgroups (un)availability on cygwin?
|
||||
|
||||
@@ -14,6 +14,8 @@ option(ENABLE_PYTHON_BINDINGS "Build Python bindings"
|
||||
${ENABLE_PYTHON_BINDINGS_DEFAULT})
|
||||
option(ENABLE_FAILMALLOC "Build failmalloc test program" ON)
|
||||
option(ENABLE_LIB_ONLY "Build libnghttp2 only. This is a short hand for -DENABLE_APP=0 -DENABLE_EXAMPLES=0 -DENABLE_HPACK_TOOLS=0 -DENABLE_PYTHON_BINDINGS=0")
|
||||
option(ENABLE_STATIC_LIB "Build libnghttp2 in static mode also")
|
||||
option(ENABLE_SHARED_LIB "Build libnghttp2 as a shared library" ON)
|
||||
|
||||
option(WITH_LIBXML2 "Use libxml2"
|
||||
${WITH_LIBXML2_DEFAULT})
|
||||
|
||||
@@ -10,39 +10,47 @@
|
||||
#
|
||||
# $ sudo docker run -v /path/to/dest:/out nghttp2-android cp /root/build/nghttp2/src/nghttpx /out
|
||||
|
||||
FROM ubuntu:vivid
|
||||
|
||||
# Only use standalone-toolchain for reduce size
|
||||
FROM ubuntu:xenial
|
||||
MAINTAINER Tatsuhiro Tsujikawa
|
||||
|
||||
ENV ANDROID_HOME /root/android
|
||||
ENV PREFIX $ANDROID_HOME/usr/local
|
||||
ENV ANDROID_HOME /root
|
||||
ENV TOOLCHAIN $ANDROID_HOME/toolchain
|
||||
ENV PATH $TOOLCHAIN/bin:$PATH
|
||||
|
||||
# It would be better to use nearest ubuntu archive mirror for faster
|
||||
# downloads.
|
||||
# RUN sed -ie 's/archive\.ubuntu/jp.archive.ubuntu/g' /etc/apt/sources.list
|
||||
ENV NDK_VERSION r14b
|
||||
|
||||
RUN apt-get update
|
||||
# genisoimage, libc6-i386 and lib32stdc++6 are required to decompress ndk.
|
||||
RUN apt-get install -y make binutils autoconf automake autotools-dev libtool \
|
||||
pkg-config git curl dpkg-dev libxml2-dev \
|
||||
genisoimage libc6-i386 lib32stdc++6
|
||||
WORKDIR /root
|
||||
RUN apt-get update && \
|
||||
apt-get install -y unzip make binutils autoconf \
|
||||
automake autotools-dev libtool pkg-config git \
|
||||
curl dpkg-dev libxml2-dev genisoimage libc6-i386 \
|
||||
lib32stdc++6 python&& \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Install toolchain
|
||||
RUN curl -L -O https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip && \
|
||||
unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip && \
|
||||
rm android-ndk-$NDK_VERSION-linux-x86_64.zip && \
|
||||
mkdir -p $ANDROID_HOME/toolchain && \
|
||||
$ANDROID_HOME/android-ndk-$NDK_VERSION/build/tools/make-standalone-toolchain.sh \
|
||||
--install-dir=$ANDROID_HOME/toolchain \
|
||||
--toolchain=arm-linux-androideabi-4.9 \
|
||||
--force && \
|
||||
rm -r android-ndk-$NDK_VERSION
|
||||
|
||||
ENV PREFIX /root/usr/local
|
||||
|
||||
# Setup version of libraries
|
||||
ENV OPENSSL_VERSION 1.0.2d
|
||||
ENV SPDYLAY_VERSION v1.4.0
|
||||
ENV LIBEV_VERSION 4.19
|
||||
ENV ZLIB_VERSION 1.2.8
|
||||
ENV CARES_VERSION 1.13.0
|
||||
ENV NGHTTP2_VERSION v1.24.0
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN curl -L -O http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin && \
|
||||
chmod a+x android-ndk-r10d-linux-x86_64.bin && \
|
||||
./android-ndk-r10d-linux-x86_64.bin && \
|
||||
rm android-ndk-r10d-linux-x86_64.bin
|
||||
|
||||
WORKDIR /root/build/android-ndk-r10d
|
||||
RUN /bin/bash build/tools/make-standalone-toolchain.sh \
|
||||
--install-dir=$ANDROID_HOME/toolchain \
|
||||
--toolchain=arm-linux-androideabi-4.9 --llvm-version=3.5 \
|
||||
--system=linux-x86_64
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN git clone https://github.com/tatsuhiro-t/spdylay
|
||||
RUN git clone https://github.com/tatsuhiro-t/spdylay -b $SPDYLAY_VERSION --depth 1
|
||||
WORKDIR /root/build/spdylay
|
||||
RUN autoreconf -i && \
|
||||
./configure \
|
||||
@@ -59,22 +67,22 @@ RUN autoreconf -i && \
|
||||
make install
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN curl -L -O https://www.openssl.org/source/openssl-1.0.2d.tar.gz && \
|
||||
tar xf openssl-1.0.2d.tar.gz && \
|
||||
rm openssl-1.0.2d.tar.gz
|
||||
RUN curl -L -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz && \
|
||||
tar xf openssl-$OPENSSL_VERSION.tar.gz && \
|
||||
rm openssl-$OPENSSL_VERSION.tar.gz
|
||||
|
||||
WORKDIR /root/build/openssl-1.0.2d
|
||||
WORKDIR /root/build/openssl-$OPENSSL_VERSION
|
||||
RUN export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi- && \
|
||||
./Configure --prefix=$PREFIX android && \
|
||||
make && make install_sw
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN curl -L -O http://dist.schmorp.de/libev/libev-4.19.tar.gz && \
|
||||
RUN curl -L -O http://dist.schmorp.de/libev/Attic/libev-$LIBEV_VERSION.tar.gz && \
|
||||
curl -L -O https://gist.github.com/tatsuhiro-t/48c45f08950f587180ed/raw/80a8f003b5d1091eae497c5995bbaa68096e739b/libev-4.19-android.patch && \
|
||||
tar xf libev-4.19.tar.gz && \
|
||||
rm libev-4.19.tar.gz
|
||||
tar xf libev-$LIBEV_VERSION.tar.gz && \
|
||||
rm libev-$LIBEV_VERSION.tar.gz
|
||||
|
||||
WORKDIR /root/build/libev-4.19
|
||||
WORKDIR /root/build/libev-$LIBEV_VERSION
|
||||
RUN patch -p1 < ../libev-4.19-android.patch && \
|
||||
./configure \
|
||||
--host=arm-linux-androideabi \
|
||||
@@ -87,11 +95,11 @@ RUN patch -p1 < ../libev-4.19-android.patch && \
|
||||
make install
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN curl -L -O http://zlib.net/zlib-1.2.8.tar.gz && \
|
||||
tar xf zlib-1.2.8.tar.gz && \
|
||||
rm zlib-1.2.8.tar.gz
|
||||
RUN curl -L -O https://downloads.sourceforge.net/project/libpng/zlib/$ZLIB_VERSION/zlib-$ZLIB_VERSION.tar.gz && \
|
||||
tar xf zlib-$ZLIB_VERSION.tar.gz && \
|
||||
rm zlib-$ZLIB_VERSION.tar.gz
|
||||
|
||||
WORKDIR /root/build/zlib-1.2.8
|
||||
WORKDIR /root/build/zlib-$ZLIB_VERSION
|
||||
RUN HOST=arm-linux-androideabi \
|
||||
CC=$HOST-gcc \
|
||||
AR=$HOST-ar \
|
||||
@@ -105,11 +113,26 @@ RUN HOST=arm-linux-androideabi \
|
||||
--static && \
|
||||
make install
|
||||
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN git clone https://github.com/nghttp2/nghttp2
|
||||
RUN curl -L -O https://c-ares.haxx.se/download/c-ares-$CARES_VERSION.tar.gz && \
|
||||
tar xf c-ares-$CARES_VERSION.tar.gz && \
|
||||
rm c-ares-$CARES_VERSION.tar.gz
|
||||
|
||||
WORKDIR /root/build/c-ares-$CARES_VERSION
|
||||
RUN ./configure \
|
||||
--host=arm-linux-androideabi \
|
||||
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
||||
--prefix=$PREFIX \
|
||||
--disable-shared && \
|
||||
make install
|
||||
|
||||
WORKDIR /root/build
|
||||
RUN git clone https://github.com/nghttp2/nghttp2 -b $NGHTTP2_VERSION --depth 1
|
||||
WORKDIR /root/build/nghttp2
|
||||
RUN autoreconf -i && \
|
||||
./configure \
|
||||
--enable-app \
|
||||
--disable-shared \
|
||||
--host=arm-linux-androideabi \
|
||||
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
||||
@@ -118,11 +141,10 @@ RUN autoreconf -i && \
|
||||
--disable-python-bindings \
|
||||
--disable-examples \
|
||||
--disable-threads \
|
||||
LIBSPDYLAY_CFLAGS=-I$PREFIX/usr/local/include \
|
||||
LIBSPDYLAY_LIBS="-L$PREFIX/usr/local/lib -lspdylay" \
|
||||
CPPFLAGS="-fPIE -I$PREFIX/include" \
|
||||
CXXFLAGS="-fno-strict-aliasing" \
|
||||
PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
|
||||
LDFLAGS="-fPIE -pie -L$PREFIX/lib" && \
|
||||
CC="$TOOLCHAIN"/bin/arm-linux-androideabi-clang \
|
||||
CXX="$TOOLCHAIN"/bin/arm-linux-androideabi-clang++ \
|
||||
CPPFLAGS="-fPIE -I$PREFIX/include" \
|
||||
PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
|
||||
LDFLAGS="-fPIE -pie -L$PREFIX/lib" && \
|
||||
make && \
|
||||
arm-linux-androideabi-strip src/nghttpx src/nghttpd src/nghttp
|
||||
|
||||
182
README.rst
182
README.rst
@@ -4,10 +4,10 @@ nghttp2 - HTTP/2 C Library
|
||||
This is an implementation of the Hypertext Transfer Protocol version 2
|
||||
in C.
|
||||
|
||||
The framing layer of HTTP/2 is implemented as a reusable C
|
||||
library. On top of that, we have implemented an HTTP/2 client, server
|
||||
and proxy. We have also developed load test and benchmarking tools for
|
||||
HTTP/2 and SPDY.
|
||||
The framing layer of HTTP/2 is implemented as a reusable C library.
|
||||
On top of that, we have implemented an HTTP/2 client, server and
|
||||
proxy. We have also developed load test and benchmarking tools for
|
||||
HTTP/2.
|
||||
|
||||
An HPACK encoder and decoder are available as a public API.
|
||||
|
||||
@@ -34,8 +34,8 @@ implementation.
|
||||
|
||||
* https://nghttp2.org/ (TLS + ALPN/NPN)
|
||||
|
||||
This endpoint supports ``h2``, ``h2-16``, ``h2-14``, ``spdy/3.1``
|
||||
and ``http/1.1`` via ALPN/NPN and requires TLSv1.2 for HTTP/2
|
||||
This endpoint supports ``h2``, ``h2-16``, ``h2-14``, and
|
||||
``http/1.1`` via ALPN/NPN and requires TLSv1.2 for HTTP/2
|
||||
connection.
|
||||
|
||||
* http://nghttp2.org/ (HTTP Upgrade and HTTP/2 Direct)
|
||||
@@ -76,15 +76,15 @@ ALPN support requires OpenSSL >= 1.0.2 (released 22 January 2015).
|
||||
LibreSSL >= 2.2.0 can be used instead of OpenSSL, but OpenSSL has more
|
||||
features than LibreSSL at the time of this writing.
|
||||
|
||||
To enable the SPDY protocol in the application program ``nghttpx`` and
|
||||
``h2load``, the following package is required:
|
||||
|
||||
* spdylay >= 1.3.2
|
||||
|
||||
To enable ``-a`` option (getting linked assets from the downloaded
|
||||
resource) in ``nghttp``, the following package is required:
|
||||
|
||||
* libxml2 >= 2.7.7
|
||||
* libxml2 >= 2.6.26
|
||||
|
||||
To enable systemd support in nghttpx, the following package is
|
||||
required:
|
||||
|
||||
* libsystemd-dev >= 209
|
||||
|
||||
The HPACK tools require the following package:
|
||||
|
||||
@@ -115,17 +115,15 @@ The Python bindings require the following packages:
|
||||
* python >= 2.7
|
||||
* python-setuptools
|
||||
|
||||
If you are using Ubuntu 14.04 LTS (trusty) or Debian 7.0 (wheezy) and above run the following to install the needed packages:
|
||||
If you are using Ubuntu 16.04 LTS (Xenial Xerus) or Debian 8 (jessie)
|
||||
and above, run the following to install the required packages:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
sudo apt-get install g++ make binutils autoconf automake autotools-dev libtool pkg-config \
|
||||
zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson-dev \
|
||||
libc-ares-dev libjemalloc-dev cython python3-dev python-setuptools
|
||||
|
||||
From Ubuntu 15.10, spdylay has been available as a package named
|
||||
`libspdylay-dev`. For the earlier Ubuntu release, you need to build
|
||||
it yourself: http://tatsuhiro-t.github.io/spdylay/
|
||||
libc-ares-dev libjemalloc-dev libsystemd-dev \
|
||||
cython python3-dev python-setuptools
|
||||
|
||||
To enable mruby support for nghttpx, `mruby
|
||||
<https://github.com/mruby/mruby>`_ is required. We need to build
|
||||
@@ -147,22 +145,10 @@ minimizes the risk of private key leakage when serious bug like
|
||||
Heartbleed is exploited. The neverbleed is disabled by default. To
|
||||
enable it, use ``--with-neverbleed`` configure option.
|
||||
|
||||
Building from git
|
||||
-----------------
|
||||
|
||||
Building from git is easy, but please be sure that at least autoconf 2.68 is
|
||||
used:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ git submodule update --init
|
||||
$ autoreconf -i
|
||||
$ automake
|
||||
$ autoconf
|
||||
$ ./configure
|
||||
$ make
|
||||
|
||||
To compile the source code, gcc >= 4.8.3 or clang >= 3.4 is required.
|
||||
Compiling libnghttp2 C source code requires a C99 compiler. gcc 4.8
|
||||
is known to be adequate. In order to compile the C++ source code, gcc
|
||||
>= 6.0 or clang >= 6.0 is required. C++ source code requires C++14
|
||||
language features.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -187,6 +173,62 @@ To compile the source code, gcc >= 4.8.3 or clang >= 3.4 is required.
|
||||
applications were not built, then using ``--enable-app`` may find
|
||||
that cause, such as the missing dependency.
|
||||
|
||||
.. note::
|
||||
|
||||
In order to detect third party libraries, pkg-config is used
|
||||
(however we don't use pkg-config for some libraries (e.g., libev)).
|
||||
By default, pkg-config searches ``*.pc`` file in the standard
|
||||
locations (e.g., /usr/lib/pkgconfig). If it is necessary to use
|
||||
``*.pc`` file in the custom location, specify paths to
|
||||
``PKG_CONFIG_PATH`` environment variable, and pass it to configure
|
||||
script, like so:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ ./configure PKG_CONFIG_PATH=/path/to/pkgconfig
|
||||
|
||||
For pkg-config managed libraries, ``*_CFLAG`` and ``*_LIBS``
|
||||
environment variables are defined (e.g., ``OPENSSL_CFLAGS``,
|
||||
``OPENSSL_LIBS``). Specifying non-empty string to these variables
|
||||
completely overrides pkg-config. In other words, if they are
|
||||
specified, pkg-config is not used for detection, and user is
|
||||
responsible to specify the correct values to these variables. For
|
||||
complete list of these variables, run ``./configure -h``.
|
||||
|
||||
Building nghttp2 from release tar archive
|
||||
-----------------------------------------
|
||||
|
||||
The nghttp2 project regularly releases tar archives which includes
|
||||
nghttp2 source code, and generated build files. They can be
|
||||
downloaded from `Releases
|
||||
<https://github.com/nghttp2/nghttp2/releases>`_ page.
|
||||
|
||||
Building nghttp2 from git requires autotools development packages.
|
||||
Building from tar archives does not require them, and thus it is much
|
||||
easier. The usual build step is as follows:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ tar xf nghttp2-X.Y.Z.tar.bz2
|
||||
$ cd nghttp2-X.Y.Z
|
||||
$ ./configure
|
||||
$ make
|
||||
|
||||
Building from git
|
||||
-----------------
|
||||
|
||||
Building from git is easy, but please be sure that at least autoconf 2.68 is
|
||||
used:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ git submodule update --init
|
||||
$ autoreconf -i
|
||||
$ automake
|
||||
$ autoconf
|
||||
$ ./configure
|
||||
$ make
|
||||
|
||||
Notes for building on Windows (MSVC)
|
||||
------------------------------------
|
||||
|
||||
@@ -233,6 +275,18 @@ If you want to compile the applications under ``examples/``, you need
|
||||
to remove or rename the ``event.h`` from libev's installation, because
|
||||
it conflicts with libevent's installation.
|
||||
|
||||
Notes for installation on Linux systems
|
||||
--------------------------------------------
|
||||
After installing nghttp2 tool suite with ``make install`` one might experience a similar error:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
nghttpx: error while loading shared libraries: libnghttp2.so.14: cannot open shared object file: No such file or directory
|
||||
|
||||
This means that the tool is unable to locate the ``libnghttp2.so`` shared library.
|
||||
|
||||
To update the shared library cache run ``sudo ldconfig``.
|
||||
|
||||
Building the documentation
|
||||
--------------------------
|
||||
|
||||
@@ -268,7 +322,6 @@ its testing framework. We depend on the following libraries:
|
||||
* golang.org/x/net/http2
|
||||
* golang.org/x/net/websocket
|
||||
* https://github.com/tatsuhiro-t/go-nghttp2
|
||||
* https://github.com/tatsuhiro-t/spdy
|
||||
|
||||
To download the above packages, after settings ``GOPATH``, run the
|
||||
following command under ``integration-tests`` directory:
|
||||
@@ -286,11 +339,6 @@ To run the tests, run the following command under
|
||||
|
||||
Inside the tests, we use port 3009 to run the test subject server.
|
||||
|
||||
.. note::
|
||||
|
||||
github.com/tatsuhiro-t/spdy is a copy used to be available at
|
||||
golang.org/x/net/spdy, but it is now gone.
|
||||
|
||||
Migration from v0.7.15 or earlier
|
||||
---------------------------------
|
||||
|
||||
@@ -691,7 +739,7 @@ information. Here is sample output from ``nghttpd``:
|
||||
nghttpx - proxy
|
||||
+++++++++++++++
|
||||
|
||||
``nghttpx`` is a multi-threaded reverse proxy for HTTP/2, SPDY and
|
||||
``nghttpx`` is a multi-threaded reverse proxy for HTTP/2, and
|
||||
HTTP/1.1, and powers http://nghttp2.org and supports HTTP/2 server
|
||||
push.
|
||||
|
||||
@@ -706,31 +754,30 @@ to know how to migrate from earlier releases.
|
||||
``nghttpx`` implements `important performance-oriented features
|
||||
<https://istlsfastyet.com/#server-performance>`_ in TLS, such as
|
||||
session IDs, session tickets (with automatic key rotation), OCSP
|
||||
stapling, dynamic record sizing, ALPN/NPN, forward secrecy and SPDY &
|
||||
HTTP/2. ``nghttpx`` also offers the functionality to share session
|
||||
cache and ticket keys among multiple ``nghttpx`` instances via
|
||||
memcached.
|
||||
stapling, dynamic record sizing, ALPN/NPN, forward secrecy and HTTP/2.
|
||||
``nghttpx`` also offers the functionality to share session cache and
|
||||
ticket keys among multiple ``nghttpx`` instances via memcached.
|
||||
|
||||
``nghttpx`` has 2 operation modes:
|
||||
|
||||
================== ====================== ================ =============
|
||||
Mode option Frontend Backend Note
|
||||
================== ====================== ================ =============
|
||||
default mode HTTP/2, SPDY, HTTP/1.1 HTTP/1.1, HTTP/2 Reverse proxy
|
||||
``--http2-proxy`` HTTP/2, SPDY, HTTP/1.1 HTTP/1.1, HTTP/2 Forward proxy
|
||||
================== ====================== ================ =============
|
||||
================== ================ ================ =============
|
||||
Mode option Frontend Backend Note
|
||||
================== ================ ================ =============
|
||||
default mode HTTP/2, HTTP/1.1 HTTP/1.1, HTTP/2 Reverse proxy
|
||||
``--http2-proxy`` HTTP/2, HTTP/1.1 HTTP/1.1, HTTP/2 Forward proxy
|
||||
================== ================ ================ =============
|
||||
|
||||
The interesting mode at the moment is the default mode. It works like
|
||||
a reverse proxy and listens for HTTP/2, SPDY and HTTP/1.1 and can be
|
||||
a reverse proxy and listens for HTTP/2, and HTTP/1.1 and can be
|
||||
deployed as a SSL/TLS terminator for existing web server.
|
||||
|
||||
In all modes, the frontend connections are encrypted by SSL/TLS by
|
||||
default. To disable encryption, use the ``no-tls`` keyword in
|
||||
``--frontend`` option. If encryption is disabled, SPDY is disabled in
|
||||
the frontend and incoming HTTP/1.1 connections can be upgraded to
|
||||
HTTP/2 through HTTP Upgrade. On the other hard, backend connections
|
||||
are not encrypted by default. To encrypt backend connections, use
|
||||
``tls`` keyword in ``--backend`` option.
|
||||
``--frontend`` option. If encryption is disabled, incoming HTTP/1.1
|
||||
connections can be upgraded to HTTP/2 through HTTP Upgrade. On the
|
||||
other hard, backend connections are not encrypted by default. To
|
||||
encrypt backend connections, use ``tls`` keyword in ``--backend``
|
||||
option.
|
||||
|
||||
``nghttpx`` supports a configuration file. See the ``--conf`` option and
|
||||
sample configuration file ``nghttpx.conf.sample``.
|
||||
@@ -740,16 +787,16 @@ server:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Client <-- (HTTP/2, SPDY, HTTP/1.1) --> nghttpx <-- (HTTP/1.1, HTTP/2) --> Web Server
|
||||
[reverse proxy]
|
||||
Client <-- (HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/1.1, HTTP/2) --> Web Server
|
||||
[reverse proxy]
|
||||
|
||||
With the ``--http2-proxy`` option, it works as forward proxy, and it
|
||||
is so called secure HTTP/2 proxy (aka SPDY proxy):
|
||||
is so called secure HTTP/2 proxy:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Client <-- (HTTP/2, SPDY, HTTP/1.1) --> nghttpx <-- (HTTP/1.1) --> Proxy
|
||||
[secure proxy] (e.g., Squid, ATS)
|
||||
Client <-- (HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/1.1) --> Proxy
|
||||
[secure proxy] (e.g., Squid, ATS)
|
||||
|
||||
The ``Client`` in the above example needs to be configured to use
|
||||
``nghttpx`` as secure proxy.
|
||||
@@ -781,7 +828,7 @@ proxy through an HTTP proxy:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Client <-- (HTTP/2, SPDY, HTTP/1.1) --> nghttpx <-- (HTTP/2) --
|
||||
Client <-- (HTTP/2, HTTP/1.1) --> nghttpx <-- (HTTP/2) --
|
||||
|
||||
--===================---> HTTP/2 Proxy
|
||||
(HTTP proxy tunnel) (e.g., nghttpx -s)
|
||||
@@ -789,9 +836,8 @@ proxy through an HTTP proxy:
|
||||
Benchmarking tool
|
||||
-----------------
|
||||
|
||||
The ``h2load`` program is a benchmarking tool for HTTP/2 and SPDY.
|
||||
The SPDY support is enabled if the program was built with the spdylay
|
||||
library. The UI of ``h2load`` is heavily inspired by ``weighttp``
|
||||
The ``h2load`` program is a benchmarking tool for HTTP/2. The UI of
|
||||
``h2load`` is heavily inspired by ``weighttp``
|
||||
(https://github.com/lighttpd/weighttp). The typical usage is as
|
||||
follows:
|
||||
|
||||
@@ -907,7 +953,7 @@ output_length
|
||||
The length of the compressed header block.
|
||||
|
||||
percentage_of_original_size
|
||||
``input_length`` / ``output_length`` * 100
|
||||
``output_length`` / ``input_length`` * 100
|
||||
|
||||
wire
|
||||
The compressed header block as a hex string.
|
||||
@@ -1288,7 +1334,7 @@ are:
|
||||
* Boost::Thread
|
||||
|
||||
The server API is designed to build an HTTP/2 server very easily to utilize
|
||||
C++11 anonymous functions and closures. The bare minimum example of
|
||||
C++14 anonymous functions and closures. The bare minimum example of
|
||||
an HTTP/2 server looks like this:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@@ -40,6 +40,9 @@ if(LIBEVENT_INCLUDE_DIR)
|
||||
# Libevent 2.0
|
||||
file(STRINGS "${LIBEVENT_INCLUDE_DIR}/event2/event-config.h"
|
||||
LIBEVENT_VERSION REGEX "${_version_regex}")
|
||||
if("${LIBEVENT_VERSION}" STREQUAL "")
|
||||
set(LIBEVENT_VERSION ${PC_LIBEVENT_VERSION})
|
||||
endif()
|
||||
else()
|
||||
# Libevent 1.4
|
||||
file(STRINGS "${LIBEVENT_INCLUDE_DIR}/event-config.h"
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
|
||||
/* Hint to the compiler that a function parameter is not used */
|
||||
#define _U_ @HINT_UNUSED_PARAM@
|
||||
|
||||
/* Hint to the compiler that a function never returns */
|
||||
#define NGHTTP2_NORETURN @HINT_NORETURN@
|
||||
|
||||
@@ -38,6 +34,9 @@
|
||||
/* Define to 1 if you have the `accept4` function. */
|
||||
#cmakedefine HAVE_ACCEPT4 1
|
||||
|
||||
/* Define to 1 if you have the `mkostemp` function. */
|
||||
#cmakedefine HAVE_MKOSTEMP 1
|
||||
|
||||
/* Define to 1 if you have the `initgroups` function. */
|
||||
#cmakedefine01 HAVE_DECL_INITGROUPS
|
||||
|
||||
|
||||
75
configure.ac
75
configure.ac
@@ -25,7 +25,7 @@ dnl Do not change user variables!
|
||||
dnl http://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT([nghttp2], [1.20.0-DEV], [t-tujikawa@users.sourceforge.net])
|
||||
AC_INIT([nghttp2], [1.37.0], [t-tujikawa@users.sourceforge.net])
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
@@ -44,9 +44,9 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
dnl See versioning rule:
|
||||
dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||
AC_SUBST(LT_CURRENT, 26)
|
||||
AC_SUBST(LT_REVISION, 4)
|
||||
AC_SUBST(LT_AGE, 12)
|
||||
AC_SUBST(LT_CURRENT, 31)
|
||||
AC_SUBST(LT_REVISION, 2)
|
||||
AC_SUBST(LT_AGE, 17)
|
||||
|
||||
major=`echo $PACKAGE_VERSION |cut -d. -f1 | sed -e "s/[^0-9]//g"`
|
||||
minor=`echo $PACKAGE_VERSION |cut -d. -f2 | sed -e "s/[^0-9]//g"`
|
||||
@@ -117,10 +117,10 @@ AC_ARG_WITH([jemalloc],
|
||||
[Use jemalloc [default=check]])],
|
||||
[request_jemalloc=$withval], [request_jemalloc=check])
|
||||
|
||||
AC_ARG_WITH([spdylay],
|
||||
[AS_HELP_STRING([--with-spdylay],
|
||||
[Use spdylay [default=check]])],
|
||||
[request_spdylay=$withval], [request_spdylay=check])
|
||||
AC_ARG_WITH([systemd],
|
||||
[AS_HELP_STRING([--with-systemd],
|
||||
[Enable systemd support in nghttpx [default=check]])],
|
||||
[request_systemd=$withval], [request_systemd=check])
|
||||
|
||||
AC_ARG_WITH([mruby],
|
||||
[AS_HELP_STRING([--with-mruby],
|
||||
@@ -171,26 +171,16 @@ else
|
||||
AC_SUBST([CYTHON])
|
||||
fi
|
||||
|
||||
#
|
||||
# If we're running GCC or clang define _U_ to be "__attribute__((unused))"
|
||||
# so we can use _U_ to flag unused function parameters and not get warnings
|
||||
# about them. Otherwise, define _U_ to be an empty string so that _U_ used
|
||||
# to flag an unused function parameters will compile with other compilers.
|
||||
#
|
||||
# XXX - similar hints for other compilers?
|
||||
#
|
||||
if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
|
||||
AC_DEFINE([_U_], [__attribute__((unused))], [Hint to the compiler that a function parameters is not used])
|
||||
AC_DEFINE([NGHTTP2_NORETURN], [__attribute__((noreturn))], [Hint to the compiler that a function never return])
|
||||
else
|
||||
AC_DEFINE([_U_], , [Hint to the compiler that a function parameter is not used])
|
||||
AC_DEFINE([NGHTTP2_NORETURN], , [Hint to the compiler that a function never return])
|
||||
fi
|
||||
|
||||
save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS=
|
||||
|
||||
AX_CXX_COMPILE_STDCXX_11([noext], [optional])
|
||||
AX_CXX_COMPILE_STDCXX([14], [noext], [optional])
|
||||
|
||||
CXX1XCXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$save_CXXFLAGS"
|
||||
@@ -395,8 +385,27 @@ else
|
||||
AC_MSG_NOTICE($JANSSON_PKG_ERRORS)
|
||||
fi
|
||||
|
||||
|
||||
# libsystemd (for src/nghttpx)
|
||||
have_libsystemd=no
|
||||
if test "x${request_systemd}" != "xno"; then
|
||||
PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 209], [have_libsystemd=yes],
|
||||
[have_libsystemd=no])
|
||||
if test "x${have_libsystemd}" = "xyes"; then
|
||||
AC_DEFINE([HAVE_LIBSYSTEMD], [1],
|
||||
[Define to 1 if you have `libsystemd` library.])
|
||||
else
|
||||
AC_MSG_NOTICE($SYSTEMD_PKG_ERRORS)
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x${request_systemd}" = "xyes" &&
|
||||
test "x${have_libsystemd}" != "xyes"; then
|
||||
AC_MSG_ERROR([systemd was requested (--with-systemd) but not found])
|
||||
fi
|
||||
|
||||
# libxml2 (for src/nghttp)
|
||||
PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.7.7],
|
||||
PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.26],
|
||||
[have_libxml2=yes], [have_libxml2=no])
|
||||
if test "x${have_libxml2}" = "xyes"; then
|
||||
AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have `libxml2` library.])
|
||||
@@ -444,26 +453,6 @@ if test "x${request_jemalloc}" = "xyes" &&
|
||||
AC_MSG_ERROR([jemalloc was requested (--with-jemalloc) but not found])
|
||||
fi
|
||||
|
||||
# spdylay (for src/nghttpx and src/h2load)
|
||||
have_spdylay=no
|
||||
if test "x${request_spdylay}" != "xno"; then
|
||||
PKG_CHECK_MODULES([LIBSPDYLAY], [libspdylay >= 1.3.2],
|
||||
[have_spdylay=yes], [have_spdylay=no])
|
||||
if test "x${have_spdylay}" = "xyes"; then
|
||||
AC_DEFINE([HAVE_SPDYLAY], [1], [Define to 1 if you have `spdylay` library.])
|
||||
else
|
||||
AC_MSG_NOTICE($LIBSPDYLAY_PKG_ERRORS)
|
||||
AC_MSG_NOTICE([The SPDY support in nghttpx and h2load will be disabled.])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x${request_spdylay}" = "xyes" &&
|
||||
test "x${have_spdylay}" != "xyes"; then
|
||||
AC_MSG_ERROR([spdylay was requested (--with-spdylay) but not found])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([HAVE_SPDYLAY], [ test "x${have_spdylay}" = "xyes" ])
|
||||
|
||||
# Check Boost Asio library
|
||||
have_asio_lib=no
|
||||
|
||||
@@ -699,6 +688,7 @@ AC_CHECK_FUNCS([ \
|
||||
memchr \
|
||||
memmove \
|
||||
memset \
|
||||
mkostemp \
|
||||
socket \
|
||||
sqrt \
|
||||
strchr \
|
||||
@@ -790,6 +780,9 @@ if test "x$werror" != "xno"; then
|
||||
AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAGS="$CXXFLAGS -Werror"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wformat-security], [CXXFLAGS="$CXXFLAGS -Wformat-security"])
|
||||
AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CXXFLAGS="$CXXFLAGS -Wsometimes-uninitialized"])
|
||||
# Disable noexcept-type warning of g++-7. This is not harmful as
|
||||
# long as all source files are compiled with the same compiler.
|
||||
AX_CHECK_COMPILE_FLAG([-Wno-noexcept-type], [CXXFLAGS="$CXXFLAGS -Wno-noexcept-type"])
|
||||
AC_LANG_POP()
|
||||
fi
|
||||
|
||||
@@ -910,10 +903,10 @@ AC_MSG_NOTICE([summary of build options:
|
||||
Libev: ${have_libev} (CFLAGS='${LIBEV_CFLAGS}' LIBS='${LIBEV_LIBS}')
|
||||
Libc-ares ${have_libcares} (CFLAGS='${LIBCARES_CFLAGS}' LIBS='${LIBCARES_LIBS}')
|
||||
Libevent(SSL): ${have_libevent_openssl} (CFLAGS='${LIBEVENT_OPENSSL_CFLAGS}' LIBS='${LIBEVENT_OPENSSL_LIBS}')
|
||||
Spdylay: ${have_spdylay} (CFLAGS='${LIBSPDYLAY_CFLAGS}' LIBS='${LIBSPDYLAY_LIBS}')
|
||||
Jansson: ${have_jansson} (CFLAGS='${JANSSON_CFLAGS}' LIBS='${JANSSON_LIBS}')
|
||||
Jemalloc: ${have_jemalloc} (LIBS='${JEMALLOC_LIBS}')
|
||||
Zlib: ${have_zlib} (CFLAGS='${ZLIB_CFLAGS}' LIBS='${ZLIB_LIBS}')
|
||||
Systemd: ${have_libsystemd} (CFLAGS='${SYSTEMD_CFLAGS}' LIBS='${SYSTEMD_LIBS}')
|
||||
Boost CPPFLAGS: ${BOOST_CPPFLAGS}
|
||||
Boost LDFLAGS: ${BOOST_LDFLAGS}
|
||||
Boost::ASIO: ${BOOST_ASIO_LIB}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
[Unit]
|
||||
Description=HTTP/2 proxy
|
||||
Documentation=man:nghttpx
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=@bindir@/nghttpx --conf=/etc/nghttpx/nghttpx.conf --pid-file=/run/nghttpx.pid --daemon
|
||||
Type=notify
|
||||
ExecStart=@bindir@/nghttpx --conf=/etc/nghttpx/nghttpx.conf
|
||||
ExecReload=/bin/kill --signal HUP $MAINPID
|
||||
KillSignal=SIGQUIT
|
||||
PrivateTmp=yes
|
||||
ProtectHome=yes
|
||||
ProtectSystem=full
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -49,6 +49,7 @@ set(APIDOCS
|
||||
nghttp2_rcbuf_decref.rst
|
||||
nghttp2_rcbuf_get_buf.rst
|
||||
nghttp2_rcbuf_incref.rst
|
||||
nghttp2_rcbuf_is_static.rst
|
||||
nghttp2_select_next_protocol.rst
|
||||
nghttp2_session_callbacks_del.rst
|
||||
nghttp2_session_callbacks_new.rst
|
||||
|
||||
@@ -62,6 +62,7 @@ APIDOCS= \
|
||||
nghttp2_option_set_max_send_header_block_length.rst \
|
||||
nghttp2_option_set_no_auto_ping_ack.rst \
|
||||
nghttp2_option_set_no_auto_window_update.rst \
|
||||
nghttp2_option_set_no_closed_streams.rst \
|
||||
nghttp2_option_set_no_http_messaging.rst \
|
||||
nghttp2_option_set_no_recv_client_magic.rst \
|
||||
nghttp2_option_set_peer_max_concurrent_streams.rst \
|
||||
@@ -73,12 +74,14 @@ APIDOCS= \
|
||||
nghttp2_rcbuf_decref.rst \
|
||||
nghttp2_rcbuf_get_buf.rst \
|
||||
nghttp2_rcbuf_incref.rst \
|
||||
nghttp2_rcbuf_is_static.rst \
|
||||
nghttp2_select_next_protocol.rst \
|
||||
nghttp2_session_callbacks_del.rst \
|
||||
nghttp2_session_callbacks_new.rst \
|
||||
nghttp2_session_callbacks_set_before_frame_send_callback.rst \
|
||||
nghttp2_session_callbacks_set_data_source_read_length_callback.rst \
|
||||
nghttp2_session_callbacks_set_error_callback.rst \
|
||||
nghttp2_session_callbacks_set_error_callback2.rst \
|
||||
nghttp2_session_callbacks_set_on_begin_frame_callback.rst \
|
||||
nghttp2_session_callbacks_set_on_begin_headers_callback.rst \
|
||||
nghttp2_session_callbacks_set_on_data_chunk_recv_callback.rst \
|
||||
@@ -140,6 +143,7 @@ APIDOCS= \
|
||||
nghttp2_session_set_local_window_size.rst \
|
||||
nghttp2_session_set_next_stream_id.rst \
|
||||
nghttp2_session_set_stream_user_data.rst \
|
||||
nghttp2_session_set_user_data.rst \
|
||||
nghttp2_session_terminate_session.rst \
|
||||
nghttp2_session_terminate_session2.rst \
|
||||
nghttp2_session_upgrade.rst \
|
||||
@@ -160,6 +164,7 @@ APIDOCS= \
|
||||
nghttp2_submit_extension.rst \
|
||||
nghttp2_submit_goaway.rst \
|
||||
nghttp2_submit_headers.rst \
|
||||
nghttp2_submit_origin.rst \
|
||||
nghttp2_submit_ping.rst \
|
||||
nghttp2_submit_priority.rst \
|
||||
nghttp2_submit_push_promise.rst \
|
||||
@@ -266,7 +271,7 @@ apiref.rst: \
|
||||
$(APIDOCS): apiref.rst
|
||||
|
||||
clean-local:
|
||||
[ $(srcdir) = $(builddir) ] || for i in $(RST_FILES); do [ -e $(builddir)/$$i ] && rm -f $(builddir)/$$i; done
|
||||
if [ $(srcdir) != $(builddir) ]; then for i in $(RST_FILES); do rm -f $(builddir)/$$i; done fi
|
||||
-rm -f apiref.rst
|
||||
-rm -f $(APIDOCS)
|
||||
-rm -rf $(BUILDDIR)/*
|
||||
|
||||
@@ -13,6 +13,7 @@ import re
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.parsers.rst import Directive
|
||||
|
||||
from sphinx import addnodes
|
||||
from sphinx import version_info
|
||||
@@ -21,10 +22,8 @@ from sphinx.locale import l_, _
|
||||
from sphinx.domains import Domain, ObjType, Index
|
||||
from sphinx.directives import ObjectDescription
|
||||
from sphinx.util.nodes import make_refnode
|
||||
from sphinx.util.compat import Directive
|
||||
from sphinx.util.docfields import Field, GroupedField, TypedField
|
||||
|
||||
|
||||
# REs for Ruby signatures
|
||||
rb_sig_re = re.compile(
|
||||
r'''^ ([\w.]*\.)? # class name(s)
|
||||
|
||||
@@ -8,7 +8,7 @@ _h2load()
|
||||
_get_comp_words_by_ref cur prev
|
||||
case $cur in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W '--connection-window-bits --clients --verbose --ciphers --rate --no-tls-proto --header-table-size --requests --base-uri --h1 --threads --npn-list --rate-period --data --version --connection-inactivity-timeout --timing-script-file --encoder-header-table-size --max-concurrent-streams --connection-active-timeout --input-file --help --window-bits --header ' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W '--connection-window-bits --clients --verbose --ciphers --rate --no-tls-proto --header-table-size --requests --log-file --base-uri --h1 --threads --npn-list --rate-period --data --version --connection-inactivity-timeout --timing-script-file --encoder-header-table-size --max-concurrent-streams --connection-active-timeout --input-file --help --window-bits --warm-up-time --duration --header ' -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
_filedir
|
||||
|
||||
@@ -8,7 +8,7 @@ _nghttp()
|
||||
_get_comp_words_by_ref cur prev
|
||||
case $cur in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W '--no-push --verbose --no-dep --get-assets --har --header-table-size --multiply --encoder-header-table-size --padding --hexdump --max-concurrent-streams --continuation --connection-window-bits --peer-max-concurrent-streams --timeout --data --no-content-length --version --color --cert --upgrade --remote-name --trailer --weight --help --key --null-out --window-bits --expect-continue --stat --header ' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W '--no-push --verbose --no-dep --get-assets --har --header-table-size --multiply --encoder-header-table-size --padding --hexdump --max-concurrent-streams --continuation --connection-window-bits --peer-max-concurrent-streams --timeout --data --no-content-length --version --color --cert --upgrade --remote-name --trailer --weight --help --key --null-out --window-bits --expect-continue --stat --no-verify-peer --header ' -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
_filedir
|
||||
|
||||
@@ -8,7 +8,7 @@ _nghttpx()
|
||||
_get_comp_words_by_ref cur prev
|
||||
case $cur in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W '--worker-read-rate --include --frontend-http2-dump-response-header --tls-ticket-key-file --verify-client-cacert --max-response-header-fields --backend-http2-window-size --frontend-keep-alive-timeout --backend-request-buffer --max-request-header-fields --fastopen --backend-connect-timeout --conf --dns-lookup-timeout --backend-http2-max-concurrent-streams --worker-write-burst --npn-list --dns-max-try --fetch-ocsp-response-file --no-via --tls-session-cache-memcached-cert-file --no-http2-cipher-black-list --mruby-file --client-no-http2-cipher-black-list --stream-read-timeout --client-ciphers --forwarded-for --accesslog-syslog --dns-cache-timeout --frontend-http2-read-timeout --listener-disable-timeout --ciphers --client-psk-secrets --strip-incoming-x-forwarded-for --no-server-rewrite --private-key-passwd-file --backend-keep-alive-timeout --backend-http-proxy-uri --rlimit-nofile --tls-ticket-key-memcached-cert-file --ocsp-update-interval --forwarded-by --tls-session-cache-memcached-private-key-file --error-page --backend-write-timeout --tls-dyn-rec-warmup-threshold --tls-ticket-key-memcached-max-retry --frontend-http2-window-size --http2-no-cookie-crumbling --worker-read-burst --dh-param-file --accesslog-format --errorlog-syslog --request-header-field-buffer --api-max-request-body --frontend-http2-decoder-dynamic-table-size --errorlog-file --frontend-http2-max-concurrent-streams --psk-secrets --frontend-write-timeout --tls-ticket-key-cipher --read-burst --backend --server-name --insecure --backend-max-backoff --log-level --host-rewrite --tls-proto-list --tls-ticket-key-memcached-interval --frontend-http2-setting-timeout --frontend-http2-connection-window-size --worker-frontend-connections --syslog-facility --no-server-push --no-location-rewrite --tls-session-cache-memcached --no-ocsp --frontend-http2-encoder-dynamic-table-size --workers --add-forwarded --worker-write-rate --add-request-header --backend-http2-settings-timeout --subcert --ecdh-curves --no-kqueue --help --frontend-frame-debug --tls-sct-dir --pid-file --frontend-http2-dump-request-header --daemon --write-rate --altsvc --backend-http2-decoder-dynamic-table-size --user --add-x-forwarded-for --frontend-read-timeout --tls-ticket-key-memcached-max-fail --backlog --write-burst --backend-connections-per-host --response-header-field-buffer --tls-ticket-key-memcached-address-family --padding --tls-session-cache-memcached-address-family --stream-write-timeout --cacert --tls-ticket-key-memcached-private-key-file --accesslog-write-early --backend-address-family --backend-http2-connection-window-size --version --add-response-header --backend-read-timeout --frontend-http2-optimize-window-size --frontend --accesslog-file --http2-proxy --backend-http2-encoder-dynamic-table-size --client-private-key-file --client-cert-file --tls-ticket-key-memcached --tls-dyn-rec-idle-timeout --frontend-http2-optimize-write-buffer-size --verify-client --backend-response-buffer --read-rate --backend-connections-per-frontend --strip-incoming-forwarded ' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W '--worker-read-rate --include --frontend-http2-dump-response-header --tls-ticket-key-file --verify-client-cacert --max-response-header-fields --backend-http2-window-size --tls13-client-ciphers --frontend-keep-alive-timeout --backend-request-buffer --max-request-header-fields --backend-connect-timeout --tls-max-proto-version --conf --dns-lookup-timeout --backend-http2-max-concurrent-streams --worker-write-burst --npn-list --dns-max-try --fetch-ocsp-response-file --no-via --tls-session-cache-memcached-cert-file --no-http2-cipher-black-list --mruby-file --add-forwarded --client-no-http2-cipher-black-list --stream-read-timeout --client-ciphers --ocsp-update-interval --forwarded-for --accesslog-syslog --dns-cache-timeout --frontend-http2-read-timeout --listener-disable-timeout --ciphers --client-psk-secrets --strip-incoming-x-forwarded-for --no-server-rewrite --private-key-passwd-file --backend-keep-alive-timeout --backend-http-proxy-uri --frontend-max-requests --tls-no-postpone-early-data --rlimit-nofile --no-strip-incoming-x-forwarded-proto --tls-ticket-key-memcached-cert-file --no-verify-ocsp --forwarded-by --tls-session-cache-memcached-private-key-file --error-page --ocsp-startup --backend-write-timeout --tls-dyn-rec-warmup-threshold --tls-ticket-key-memcached-max-retry --frontend-http2-window-size --http2-no-cookie-crumbling --worker-read-burst --dh-param-file --accesslog-format --errorlog-syslog --redirect-https-port --request-header-field-buffer --api-max-request-body --frontend-http2-decoder-dynamic-table-size --errorlog-file --frontend-http2-max-concurrent-streams --psk-secrets --frontend-write-timeout --tls-ticket-key-cipher --read-burst --no-add-x-forwarded-proto --backend --server-name --insecure --backend-max-backoff --log-level --host-rewrite --tls-ticket-key-memcached-interval --frontend-http2-setting-timeout --frontend-http2-connection-window-size --worker-frontend-connections --syslog-facility --fastopen --no-location-rewrite --single-thread --tls-session-cache-memcached --no-ocsp --backend-response-buffer --tls-min-proto-version --workers --add-x-forwarded-for --no-server-push --worker-write-rate --add-request-header --backend-http2-settings-timeout --subcert --ignore-per-pattern-mruby-error --ecdh-curves --no-kqueue --help --frontend-frame-debug --tls-sct-dir --pid-file --frontend-http2-dump-request-header --daemon --write-rate --altsvc --backend-http2-decoder-dynamic-table-size --no-strip-incoming-early-data --user --verify-client-tolerate-expired --frontend-read-timeout --tls-ticket-key-memcached-max-fail --backlog --write-burst --backend-connections-per-host --tls-max-early-data --response-header-field-buffer --tls-ticket-key-memcached-address-family --padding --tls-session-cache-memcached-address-family --stream-write-timeout --cacert --tls-ticket-key-memcached-private-key-file --accesslog-write-early --backend-address-family --backend-http2-connection-window-size --tls13-ciphers --version --add-response-header --backend-read-timeout --frontend-http2-optimize-window-size --frontend --accesslog-file --http2-proxy --backend-http2-encoder-dynamic-table-size --client-private-key-file --single-process --client-cert-file --tls-ticket-key-memcached --tls-dyn-rec-idle-timeout --frontend-http2-optimize-write-buffer-size --verify-client --frontend-http2-encoder-dynamic-table-size --read-rate --backend-connections-per-frontend --strip-incoming-forwarded ' -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
_filedir
|
||||
|
||||
@@ -157,7 +157,7 @@ html_theme_path = ['@top_srcdir@/doc/_themes']
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
html_use_smartypants = False
|
||||
#html_use_smartypants = False
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
html_sidebars = {
|
||||
|
||||
2
doc/docutils.conf
Normal file
2
doc/docutils.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[parsers]
|
||||
smart_quotes=no
|
||||
61
doc/h2load.1
61
doc/h2load.1
@@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "H2LOAD" "1" "Jan 25, 2017" "1.19.0" "nghttp2"
|
||||
.TH "H2LOAD" "1" "Mar 07, 2019" "1.37.0" "nghttp2"
|
||||
.SH NAME
|
||||
h2load \- HTTP/2 benchmarking tool
|
||||
.
|
||||
@@ -35,7 +35,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
||||
\fBh2load\fP [OPTIONS]... [URI]...
|
||||
.SH DESCRIPTION
|
||||
.sp
|
||||
benchmarking tool for HTTP/2 and SPDY server
|
||||
benchmarking tool for HTTP/2 server
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B <URI>
|
||||
@@ -54,7 +54,9 @@ scheme, host or port values.
|
||||
Number of requests across all clients. If it is used
|
||||
with \fI\%\-\-timing\-script\-file\fP option, this option specifies
|
||||
the number of requests each client performs rather than
|
||||
the number of requests across all clients.
|
||||
the number of requests across all clients. This option
|
||||
is ignored if timing\-based benchmarking is enabled (see
|
||||
\fI\%\-\-duration\fP option).
|
||||
.sp
|
||||
Default: \fB1\fP
|
||||
.UNINDENT
|
||||
@@ -99,7 +101,6 @@ Default: \fB1\fP
|
||||
.TP
|
||||
.B \-w, \-\-window\-bits=<N>
|
||||
Sets the stream level initial window size to (2**<N>)\-1.
|
||||
For SPDY, 2**<N> is used instead.
|
||||
.sp
|
||||
Default: \fB30\fP
|
||||
.UNINDENT
|
||||
@@ -107,9 +108,7 @@ Default: \fB30\fP
|
||||
.TP
|
||||
.B \-W, \-\-connection\-window\-bits=<N>
|
||||
Sets the connection level initial window size to
|
||||
(2**<N>)\-1. For SPDY, if <N> is strictly less than 16,
|
||||
this option is ignored. Otherwise 2**<N> is used for
|
||||
SPDY.
|
||||
(2**<N>)\-1.
|
||||
.sp
|
||||
Default: \fB30\fP
|
||||
.UNINDENT
|
||||
@@ -124,15 +123,14 @@ Add/Override a header to the requests.
|
||||
Set allowed cipher list. The format of the string is
|
||||
described in OpenSSL ciphers(1).
|
||||
.sp
|
||||
Default: \fBECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:DHE\-RSA\-AES128\-GCM\-SHA256:DHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256:ECDHE\-ECDSA\-AES128\-SHA:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-RSA\-AES128\-SHA:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES256\-SHA:ECDHE\-RSA\-AES256\-SHA:DHE\-RSA\-AES128\-SHA256:DHE\-RSA\-AES128\-SHA:DHE\-RSA\-AES256\-SHA256:DHE\-RSA\-AES256\-SHA:ECDHE\-ECDSA\-DES\-CBC3\-SHA:ECDHE\-RSA\-DES\-CBC3\-SHA:EDH\-RSA\-DES\-CBC3\-SHA:AES128\-GCM\-SHA256:AES256\-GCM\-SHA384:AES128\-SHA256:AES256\-SHA256:AES128\-SHA:AES256\-SHA:DES\-CBC3\-SHA:!DSS\fP
|
||||
Default: \fBECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-p, \-\-no\-tls\-proto=<PROTOID>
|
||||
Specify ALPN identifier of the protocol to be used when
|
||||
accessing http URI without SSL/TLS.
|
||||
Available protocols: spdy/2, spdy/3, spdy/3.1, h2c and
|
||||
http/1.1
|
||||
Available protocols: h2c and http/1.1
|
||||
.sp
|
||||
Default: \fBh2c\fP
|
||||
.UNINDENT
|
||||
@@ -157,7 +155,7 @@ example, with \fI\%\-t\fP2 and \fI\%\-r\fP4, each thread gets 2
|
||||
connections per period. When the rate is 0, the program
|
||||
will run as it normally does, creating connections at
|
||||
whatever variable rate it wants. The default value for
|
||||
this option is 0.
|
||||
this option is 0. \fI\%\-r\fP and \fI\%\-D\fP are mutually exclusive.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -170,6 +168,20 @@ option is 1s.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-D, \-\-duration=<N>
|
||||
Specifies the main duration for the measurements in case
|
||||
of timing\-based benchmarking. \fI\%\-D\fP and \fI\%\-r\fP are mutually
|
||||
exclusive.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-warm\-up\-time=<DURATION>
|
||||
Specifies the time period before starting the actual
|
||||
measurements, in case of timing\-based benchmarking.
|
||||
Needs to provided along with \fI\%\-D\fP option.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-T, \-\-connection\-active\-timeout=<DURATION>
|
||||
Specifies the maximum time that h2load is willing to
|
||||
keep a connection open, regardless of the activity on
|
||||
@@ -233,7 +245,7 @@ NPN. The parameter must be delimited by a single comma
|
||||
only and any white spaces are treated as a part of
|
||||
protocol string.
|
||||
.sp
|
||||
Default: \fBh2,h2\-16,h2\-14,spdy/3.1,spdy/3,spdy/2,http/1.1\fP
|
||||
Default: \fBh2,h2\-16,h2\-14,http/1.1\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -261,6 +273,17 @@ Default: \fB4K\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-log\-file=<PATH>
|
||||
Write per\-request information to a file as tab\-separated
|
||||
columns: start time as microseconds since epoch; HTTP
|
||||
status code; microseconds until end of response. More
|
||||
columns may be added later. Rows are ordered by end\-of\-
|
||||
response time when using one worker thread, but may
|
||||
appear slightly out of order with multiple threads due
|
||||
to buffering. Status code is \-1 for failed streams.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-v, \-\-verbose
|
||||
Output debug information.
|
||||
.UNINDENT
|
||||
@@ -335,8 +358,7 @@ compression. Let \fBdecompressed(headers)\fP to the number of bytes
|
||||
used for header fields after decompression. The \fBspace savings\fP
|
||||
is calculated by (1 \- \fBheaders\fP / \fBdecompressed(headers)\fP) *
|
||||
100. For HTTP/1.1, this is usually 0.00%, since it does not have
|
||||
header compression. For HTTP/2 and SPDY, it shows some insightful
|
||||
numbers.
|
||||
header compression. For HTTP/2, it shows some insightful numbers.
|
||||
.TP
|
||||
.B data
|
||||
The number of response body bytes received from the server.
|
||||
@@ -366,13 +388,16 @@ range (mean +/\- sd) against total number of successful requests.
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B min
|
||||
The minimum time taken to connect to a server.
|
||||
The minimum time taken to connect to a server including TLS
|
||||
handshake.
|
||||
.TP
|
||||
.B max
|
||||
The maximum time taken to connect to a server.
|
||||
The maximum time taken to connect to a server including TLS
|
||||
handshake.
|
||||
.TP
|
||||
.B mean
|
||||
The mean time taken to connect to a server.
|
||||
The mean time taken to connect to a server including TLS
|
||||
handshake.
|
||||
.TP
|
||||
.B sd
|
||||
The standard deviation of the time taken to connect to a server.
|
||||
@@ -433,7 +458,7 @@ h2load sets large flow control window by default, and effectively
|
||||
disables flow control to avoid under utilization of server
|
||||
performance. To set smaller flow control window, use \fI\%\-w\fP and
|
||||
\fI\%\-W\fP options. For example, use \fB\-w16 \-W16\fP to set default
|
||||
window size described in HTTP/2 and SPDY protocol specification.
|
||||
window size described in HTTP/2 protocol specification.
|
||||
.SH SEE ALSO
|
||||
.sp
|
||||
\fBnghttp(1)\fP, \fBnghttpd(1)\fP, \fBnghttpx(1)\fP
|
||||
|
||||
@@ -14,7 +14,7 @@ SYNOPSIS
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
benchmarking tool for HTTP/2 and SPDY server
|
||||
benchmarking tool for HTTP/2 server
|
||||
|
||||
.. describe:: <URI>
|
||||
|
||||
@@ -34,7 +34,9 @@ OPTIONS
|
||||
Number of requests across all clients. If it is used
|
||||
with :option:`--timing-script-file` option, this option specifies
|
||||
the number of requests each client performs rather than
|
||||
the number of requests across all clients.
|
||||
the number of requests across all clients. This option
|
||||
is ignored if timing-based benchmarking is enabled (see
|
||||
:option:`--duration` option).
|
||||
|
||||
Default: ``1``
|
||||
|
||||
@@ -74,16 +76,13 @@ OPTIONS
|
||||
.. option:: -w, --window-bits=<N>
|
||||
|
||||
Sets the stream level initial window size to (2\*\*<N>)-1.
|
||||
For SPDY, 2\*\*<N> is used instead.
|
||||
|
||||
Default: ``30``
|
||||
|
||||
.. option:: -W, --connection-window-bits=<N>
|
||||
|
||||
Sets the connection level initial window size to
|
||||
(2\*\*<N>)-1. For SPDY, if <N> is strictly less than 16,
|
||||
this option is ignored. Otherwise 2\*\*<N> is used for
|
||||
SPDY.
|
||||
(2\*\*<N>)-1.
|
||||
|
||||
Default: ``30``
|
||||
|
||||
@@ -96,14 +95,13 @@ OPTIONS
|
||||
Set allowed cipher list. The format of the string is
|
||||
described in OpenSSL ciphers(1).
|
||||
|
||||
Default: ``ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS``
|
||||
Default: ``ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256``
|
||||
|
||||
.. option:: -p, --no-tls-proto=<PROTOID>
|
||||
|
||||
Specify ALPN identifier of the protocol to be used when
|
||||
accessing http URI without SSL/TLS.
|
||||
Available protocols: spdy/2, spdy/3, spdy/3.1, h2c and
|
||||
http/1.1
|
||||
Available protocols: h2c and http/1.1
|
||||
|
||||
Default: ``h2c``
|
||||
|
||||
@@ -126,7 +124,7 @@ OPTIONS
|
||||
connections per period. When the rate is 0, the program
|
||||
will run as it normally does, creating connections at
|
||||
whatever variable rate it wants. The default value for
|
||||
this option is 0.
|
||||
this option is 0. :option:`-r` and :option:`\-D` are mutually exclusive.
|
||||
|
||||
.. option:: --rate-period=<DURATION>
|
||||
|
||||
@@ -136,6 +134,18 @@ OPTIONS
|
||||
the rate option is not used. The default value for this
|
||||
option is 1s.
|
||||
|
||||
.. option:: -D, --duration=<N>
|
||||
|
||||
Specifies the main duration for the measurements in case
|
||||
of timing-based benchmarking. :option:`-D` and :option:`\-r` are mutually
|
||||
exclusive.
|
||||
|
||||
.. option:: --warm-up-time=<DURATION>
|
||||
|
||||
Specifies the time period before starting the actual
|
||||
measurements, in case of timing-based benchmarking.
|
||||
Needs to provided along with :option:`-D` option.
|
||||
|
||||
.. option:: -T, --connection-active-timeout=<DURATION>
|
||||
|
||||
Specifies the maximum time that h2load is willing to
|
||||
@@ -196,7 +206,7 @@ OPTIONS
|
||||
only and any white spaces are treated as a part of
|
||||
protocol string.
|
||||
|
||||
Default: ``h2,h2-16,h2-14,spdy/3.1,spdy/3,spdy/2,http/1.1``
|
||||
Default: ``h2,h2-16,h2-14,http/1.1``
|
||||
|
||||
.. option:: --h1
|
||||
|
||||
@@ -219,6 +229,16 @@ OPTIONS
|
||||
|
||||
Default: ``4K``
|
||||
|
||||
.. option:: --log-file=<PATH>
|
||||
|
||||
Write per-request information to a file as tab-separated
|
||||
columns: start time as microseconds since epoch; HTTP
|
||||
status code; microseconds until end of response. More
|
||||
columns may be added later. Rows are ordered by end-of-
|
||||
response time when using one worker thread, but may
|
||||
appear slightly out of order with multiple threads due
|
||||
to buffering. Status code is -1 for failed streams.
|
||||
|
||||
.. option:: -v, --verbose
|
||||
|
||||
Output debug information.
|
||||
@@ -284,8 +304,7 @@ traffic
|
||||
used for header fields after decompression. The ``space savings``
|
||||
is calculated by (1 - ``headers`` / ``decompressed(headers)``) *
|
||||
100. For HTTP/1.1, this is usually 0.00%, since it does not have
|
||||
header compression. For HTTP/2 and SPDY, it shows some insightful
|
||||
numbers.
|
||||
header compression. For HTTP/2, it shows some insightful numbers.
|
||||
data
|
||||
The number of response body bytes received from the server.
|
||||
|
||||
@@ -304,11 +323,14 @@ time for request
|
||||
|
||||
time for connect
|
||||
min
|
||||
The minimum time taken to connect to a server.
|
||||
The minimum time taken to connect to a server including TLS
|
||||
handshake.
|
||||
max
|
||||
The maximum time taken to connect to a server.
|
||||
The maximum time taken to connect to a server including TLS
|
||||
handshake.
|
||||
mean
|
||||
The mean time taken to connect to a server.
|
||||
The mean time taken to connect to a server including TLS
|
||||
handshake.
|
||||
sd
|
||||
The standard deviation of the time taken to connect to a server.
|
||||
+/- sd
|
||||
@@ -353,7 +375,7 @@ h2load sets large flow control window by default, and effectively
|
||||
disables flow control to avoid under utilization of server
|
||||
performance. To set smaller flow control window, use :option:`-w` and
|
||||
:option:`-W` options. For example, use ``-w16 -W16`` to set default
|
||||
window size described in HTTP/2 and SPDY protocol specification.
|
||||
window size described in HTTP/2 protocol specification.
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
@@ -41,8 +41,7 @@ traffic
|
||||
used for header fields after decompression. The ``space savings``
|
||||
is calculated by (1 - ``headers`` / ``decompressed(headers)``) *
|
||||
100. For HTTP/1.1, this is usually 0.00%, since it does not have
|
||||
header compression. For HTTP/2 and SPDY, it shows some insightful
|
||||
numbers.
|
||||
header compression. For HTTP/2, it shows some insightful numbers.
|
||||
data
|
||||
The number of response body bytes received from the server.
|
||||
|
||||
@@ -61,11 +60,14 @@ time for request
|
||||
|
||||
time for connect
|
||||
min
|
||||
The minimum time taken to connect to a server.
|
||||
The minimum time taken to connect to a server including TLS
|
||||
handshake.
|
||||
max
|
||||
The maximum time taken to connect to a server.
|
||||
The maximum time taken to connect to a server including TLS
|
||||
handshake.
|
||||
mean
|
||||
The mean time taken to connect to a server.
|
||||
The mean time taken to connect to a server including TLS
|
||||
handshake.
|
||||
sd
|
||||
The standard deviation of the time taken to connect to a server.
|
||||
+/- sd
|
||||
@@ -110,7 +112,7 @@ h2load sets large flow control window by default, and effectively
|
||||
disables flow control to avoid under utilization of server
|
||||
performance. To set smaller flow control window, use :option:`-w` and
|
||||
:option:`-W` options. For example, use ``-w16 -W16`` to set default
|
||||
window size described in HTTP/2 and SPDY protocol specification.
|
||||
window size described in HTTP/2 protocol specification.
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "NGHTTP" "1" "Jan 25, 2017" "1.19.0" "nghttp2"
|
||||
.TH "NGHTTP" "1" "Mar 07, 2019" "1.37.0" "nghttp2"
|
||||
.SH NAME
|
||||
nghttp \- HTTP/2 client
|
||||
.
|
||||
@@ -236,6 +236,12 @@ combined with the \fI\%\-d\fP option.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-y, \-\-no\-verify\-peer
|
||||
Suppress warning on server certificate verification
|
||||
failure.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-version
|
||||
Display version information and exit.
|
||||
.UNINDENT
|
||||
|
||||
@@ -186,6 +186,11 @@ OPTIONS
|
||||
Continue interim response. This option is ignored unless
|
||||
combined with the :option:`-d` option.
|
||||
|
||||
.. option:: -y, --no-verify-peer
|
||||
|
||||
Suppress warning on server certificate verification
|
||||
failure.
|
||||
|
||||
.. option:: --version
|
||||
|
||||
Display version information and exit.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "NGHTTPD" "1" "Jan 25, 2017" "1.19.0" "nghttp2"
|
||||
.TH "NGHTTPD" "1" "Mar 07, 2019" "1.37.0" "nghttp2"
|
||||
.SH NAME
|
||||
nghttpd \- HTTP/2 server
|
||||
.
|
||||
|
||||
612
doc/nghttpx.1
612
doc/nghttpx.1
@@ -1,6 +1,6 @@
|
||||
.\" Man page generated from reStructuredText.
|
||||
.
|
||||
.TH "NGHTTPX" "1" "Jan 25, 2017" "1.19.0" "nghttp2"
|
||||
.TH "NGHTTPX" "1" "Mar 07, 2019" "1.37.0" "nghttp2"
|
||||
.SH NAME
|
||||
nghttpx \- HTTP/2 proxy
|
||||
.
|
||||
@@ -35,7 +35,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
||||
\fBnghttpx\fP [OPTIONS]... [<PRIVATE_KEY> <CERT>]
|
||||
.SH DESCRIPTION
|
||||
.sp
|
||||
A reverse proxy for HTTP/2, HTTP/1 and SPDY.
|
||||
A reverse proxy for HTTP/2, and HTTP/1.
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B <PRIVATE_KEY>
|
||||
@@ -62,8 +62,7 @@ domain socket can be specified by prefixing path name
|
||||
with "unix:" (e.g., unix:/var/run/backend.sock).
|
||||
.sp
|
||||
Optionally, if <PATTERN>s are given, the backend address
|
||||
is only used if request matches the pattern. If
|
||||
\fI\%\-\-http2\-proxy\fP is used, <PATTERN>s are ignored. The
|
||||
is only used if request matches the pattern. The
|
||||
pattern matching is closely designed to ServeMux in
|
||||
net/http package of Go programming language. <PATTERN>
|
||||
consists of path, host + path or just host. The path
|
||||
@@ -74,11 +73,16 @@ path which ends with "\fI/\fP" also matches the request path
|
||||
which only lacks trailing \(aq\fI/\fP\(aq (e.g., path "\fI/foo/\fP"
|
||||
matches request path "\fI/foo\fP"). If it does not end with
|
||||
"\fI/\fP", it performs exact match against the request path.
|
||||
If host is given, it performs exact match against the
|
||||
request host. If host alone is given, "\fI/\fP" is appended
|
||||
to it, so that it matches all request paths under the
|
||||
host (e.g., specifying "nghttp2.org" equals to
|
||||
"nghttp2.org/").
|
||||
If host is given, it performs a match against the
|
||||
request host. For a request received on the frontend
|
||||
listener with "sni\-fwd" parameter enabled, SNI host is
|
||||
used instead of a request host. If host alone is given,
|
||||
"\fI/\fP" is appended to it, so that it matches all request
|
||||
paths under the host (e.g., specifying "nghttp2.org"
|
||||
equals to "nghttp2.org/"). CONNECT method is treated
|
||||
specially. It does not have path, and we don\(aqt allow
|
||||
empty path. To workaround this, we assume that CONNECT
|
||||
method has "\fI/\fP" as path.
|
||||
.sp
|
||||
Patterns with host take precedence over patterns with
|
||||
just path. Then, longer patterns take precedence over
|
||||
@@ -92,6 +96,18 @@ host pattern "*.nghttp2.org" matches against
|
||||
match against "nghttp2.org". The exact hosts match
|
||||
takes precedence over the wildcard hosts match.
|
||||
.sp
|
||||
If path part ends with "*", it is treated as wildcard
|
||||
path. The wildcard path behaves differently from the
|
||||
normal path. For normal path, match is made around the
|
||||
boundary of path component separator,"\fI/\fP". On the other
|
||||
hand, the wildcard path does not take into account the
|
||||
path component separator. All paths which include the
|
||||
wildcard path without last "*" as prefix, and are
|
||||
strictly longer than wildcard path without last "*" are
|
||||
matched. "*" must match at least one character. For
|
||||
example, the pattern "\fI/foo*\fP" matches "\fI/foo/\fP" and
|
||||
"\fI/foobar\fP". But it does not match "\fI/foo\fP", or "\fI/fo\fP".
|
||||
.sp
|
||||
If <PATTERN> is omitted or empty string, "\fI/\fP" is used as
|
||||
pattern, which matches all request paths (catch\-all
|
||||
pattern). The catch\-all backend must be given.
|
||||
@@ -121,12 +137,15 @@ Several parameters <PARAM> are accepted after <PATTERN>.
|
||||
The parameters are delimited by ";". The available
|
||||
parameters are: "proto=<PROTO>", "tls",
|
||||
"sni=<SNI_HOST>", "fall=<N>", "rise=<N>",
|
||||
"affinity=<METHOD>", and "dns". The parameter consists
|
||||
of keyword, and optionally followed by "=" and value.
|
||||
For example, the parameter "proto=h2" consists of the
|
||||
keyword "proto" and value "h2". The parameter "tls"
|
||||
consists of the keyword "tls" without value. Each
|
||||
parameter is described as follows.
|
||||
"affinity=<METHOD>", "dns", "redirect\-if\-not\-tls",
|
||||
"upgrade\-scheme", "mruby=<PATH>",
|
||||
"read\-timeout=<DURATION>", "write\-timeout=<DURATION>",
|
||||
"group=<GROUP>", "group\-weight=<N>", and "weight=<N>".
|
||||
The parameter consists of keyword, and optionally
|
||||
followed by "=" and value. For example, the parameter
|
||||
"proto=h2" consists of the keyword "proto" and value
|
||||
"h2". The parameter "tls" consists of the keyword "tls"
|
||||
without value. Each parameter is described as follows.
|
||||
.sp
|
||||
The backend application protocol can be specified using
|
||||
optional "proto" parameter, and in the form of
|
||||
@@ -164,16 +183,32 @@ state, and this is the default behaviour.
|
||||
The session affinity is enabled using
|
||||
"affinity=<METHOD>" parameter. If "ip" is given in
|
||||
<METHOD>, client IP based session affinity is enabled.
|
||||
If "none" is given in <METHOD>, session affinity is
|
||||
disabled, and this is the default. The session affinity
|
||||
is enabled per <PATTERN>. If at least one backend has
|
||||
"affinity" parameter, and its <METHOD> is not "none",
|
||||
session affinity is enabled for all backend servers
|
||||
sharing the same <PATTERN>. It is advised to set
|
||||
"affinity" parameter to all backend explicitly if
|
||||
session affinity is desired. The session affinity may
|
||||
break if one of the backend gets unreachable, or backend
|
||||
settings are reloaded or replaced by API.
|
||||
If "cookie" is given in <METHOD>, cookie based session
|
||||
affinity is enabled. If "none" is given in <METHOD>,
|
||||
session affinity is disabled, and this is the default.
|
||||
The session affinity is enabled per <PATTERN>. If at
|
||||
least one backend has "affinity" parameter, and its
|
||||
<METHOD> is not "none", session affinity is enabled for
|
||||
all backend servers sharing the same <PATTERN>. It is
|
||||
advised to set "affinity" parameter to all backend
|
||||
explicitly if session affinity is desired. The session
|
||||
affinity may break if one of the backend gets
|
||||
unreachable, or backend settings are reloaded or
|
||||
replaced by API.
|
||||
.sp
|
||||
If "affinity=cookie" is used, the additional
|
||||
configuration is required.
|
||||
"affinity\-cookie\-name=<NAME>" must be used to specify a
|
||||
name of cookie to use. Optionally,
|
||||
"affinity\-cookie\-path=<PATH>" can be used to specify a
|
||||
path which cookie is applied. The optional
|
||||
"affinity\-cookie\-secure=<SECURE>" controls the Secure
|
||||
attribute of a cookie. The default value is "auto", and
|
||||
the Secure attribute is determined by a request scheme.
|
||||
If a request scheme is "https", then Secure attribute is
|
||||
set. Otherwise, it is not set. If <SECURE> is "yes",
|
||||
the Secure attribute is always set. If <SECURE> is
|
||||
"no", the Secure attribute is always omitted.
|
||||
.sp
|
||||
By default, name resolution of backend host name is done
|
||||
at start up, or reloading configuration. If "dns"
|
||||
@@ -183,6 +218,64 @@ frequently. If "dns" is given, name resolution of
|
||||
backend host name at start up, or reloading
|
||||
configuration is skipped.
|
||||
.sp
|
||||
If "redirect\-if\-not\-tls" parameter is used, the matched
|
||||
backend requires that frontend connection is TLS
|
||||
encrypted. If it isn\(aqt, nghttpx responds to the request
|
||||
with 308 status code, and https URI the client should
|
||||
use instead is included in Location header field. The
|
||||
port number in redirect URI is 443 by default, and can
|
||||
be changed using \fI\%\-\-redirect\-https\-port\fP option. If at
|
||||
least one backend has "redirect\-if\-not\-tls" parameter,
|
||||
this feature is enabled for all backend servers sharing
|
||||
the same <PATTERN>. It is advised to set
|
||||
"redirect\-if\-no\-tls" parameter to all backends
|
||||
explicitly if this feature is desired.
|
||||
.sp
|
||||
If "upgrade\-scheme" parameter is used along with "tls"
|
||||
parameter, HTTP/2 :scheme pseudo header field is changed
|
||||
to "https" from "http" when forwarding a request to this
|
||||
particular backend. This is a workaround for a backend
|
||||
server which requires "https" :scheme pseudo header
|
||||
field on TLS encrypted connection.
|
||||
.sp
|
||||
"mruby=<PATH>" parameter specifies a path to mruby
|
||||
script file which is invoked when this pattern is
|
||||
matched. All backends which share the same pattern must
|
||||
have the same mruby path.
|
||||
.sp
|
||||
"read\-timeout=<DURATION>" and "write\-timeout=<DURATION>"
|
||||
parameters specify the read and write timeout of the
|
||||
backend connection when this pattern is matched. All
|
||||
backends which share the same pattern must have the same
|
||||
timeouts. If these timeouts are entirely omitted for a
|
||||
pattern, \fI\%\-\-backend\-read\-timeout\fP and
|
||||
\fI\%\-\-backend\-write\-timeout\fP are used.
|
||||
.sp
|
||||
"group=<GROUP>" parameter specifies the name of group
|
||||
this backend address belongs to. By default, it belongs
|
||||
to the unnamed default group. The name of group is
|
||||
unique per pattern. "group\-weight=<N>" parameter
|
||||
specifies the weight of the group. The higher weight
|
||||
gets more frequently selected by the load balancing
|
||||
algorithm. <N> must be [1, 256] inclusive. The weight
|
||||
8 has 4 times more weight than 2. <N> must be the same
|
||||
for all addresses which share the same <GROUP>. If
|
||||
"group\-weight" is omitted in an address, but the other
|
||||
address which belongs to the same group specifies
|
||||
"group\-weight", its weight is used. If no
|
||||
"group\-weight" is specified for all addresses, the
|
||||
weight of a group becomes 1. "group" and "group\-weight"
|
||||
are ignored if session affinity is enabled.
|
||||
.sp
|
||||
"weight=<N>" parameter specifies the weight of the
|
||||
backend address inside a group which this address
|
||||
belongs to. The higher weight gets more frequently
|
||||
selected by the load balancing algorithm. <N> must be
|
||||
[1, 256] inclusive. The weight 8 has 4 times more
|
||||
weight than weight 2. If this parameter is omitted,
|
||||
weight becomes 1. "weight" is ignored if session
|
||||
affinity is enabled.
|
||||
.sp
|
||||
Since ";" and ":" are used as delimiter, <PATTERN> must
|
||||
not contain these characters. Since ";" has special
|
||||
meaning in shell, the option value must be quoted.
|
||||
@@ -206,6 +299,11 @@ parameters are mutually exclusive.
|
||||
Optionally, TLS can be disabled by specifying "no\-tls"
|
||||
parameter. TLS is enabled by default.
|
||||
.sp
|
||||
If "sni\-fwd" parameter is used, when performing a match
|
||||
to select a backend server, SNI host name received from
|
||||
the client is used instead of the request host. See
|
||||
\fI\%\-\-backend\fP option about the pattern match.
|
||||
.sp
|
||||
To make this frontend as API endpoint, specify "api"
|
||||
parameter. This is disabled by default. It is
|
||||
important to limit the access to the API frontend.
|
||||
@@ -267,6 +365,15 @@ Default: \fB1\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-single\-thread
|
||||
Run everything in one thread inside the worker process.
|
||||
This feature is provided for better debugging
|
||||
experience, or for the platforms which lack thread
|
||||
support. If threading is disabled, this option is
|
||||
always enabled.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-read\-rate=<SIZE>
|
||||
Set maximum average read rate on frontend connection.
|
||||
Setting 0 to this option means read rate is unlimited.
|
||||
@@ -412,8 +519,7 @@ this option will be simply ignored.
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-frontend\-http2\-read\-timeout=<DURATION>
|
||||
Specify read timeout for HTTP/2 and SPDY frontend
|
||||
connection.
|
||||
Specify read timeout for HTTP/2 frontend connection.
|
||||
.sp
|
||||
Default: \fB3m\fP
|
||||
.UNINDENT
|
||||
@@ -442,18 +548,18 @@ Default: \fB1m\fP
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-stream\-read\-timeout=<DURATION>
|
||||
Specify read timeout for HTTP/2 and SPDY streams. 0
|
||||
means no timeout.
|
||||
Specify read timeout for HTTP/2 streams. 0 means no
|
||||
timeout.
|
||||
.sp
|
||||
Default: \fB0\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-stream\-write\-timeout=<DURATION>
|
||||
Specify write timeout for HTTP/2 and SPDY streams. 0
|
||||
means no timeout.
|
||||
Specify write timeout for HTTP/2 streams. 0 means no
|
||||
timeout.
|
||||
.sp
|
||||
Default: \fB0\fP
|
||||
Default: \fB1m\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -530,16 +636,40 @@ Default: \fB2m\fP
|
||||
.B \-\-ciphers=<SUITE>
|
||||
Set allowed cipher list for frontend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.2 or earlier.
|
||||
Use \fI\%\-\-tls13\-ciphers\fP for TLSv1.3.
|
||||
.sp
|
||||
Default: \fBECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:DHE\-RSA\-AES128\-GCM\-SHA256:DHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256:ECDHE\-ECDSA\-AES128\-SHA:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-RSA\-AES128\-SHA:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES256\-SHA:ECDHE\-RSA\-AES256\-SHA:DHE\-RSA\-AES128\-SHA256:DHE\-RSA\-AES128\-SHA:DHE\-RSA\-AES256\-SHA256:DHE\-RSA\-AES256\-SHA:ECDHE\-ECDSA\-DES\-CBC3\-SHA:ECDHE\-RSA\-DES\-CBC3\-SHA:EDH\-RSA\-DES\-CBC3\-SHA:AES128\-GCM\-SHA256:AES256\-GCM\-SHA384:AES128\-SHA256:AES256\-SHA256:AES128\-SHA:AES256\-SHA:DES\-CBC3\-SHA:!DSS\fP
|
||||
Default: \fBECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-tls13\-ciphers=<SUITE>
|
||||
Set allowed cipher list for frontend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.3. Use
|
||||
\fI\%\-\-ciphers\fP for TLSv1.2 or earlier.
|
||||
.sp
|
||||
Default: \fBTLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-client\-ciphers=<SUITE>
|
||||
Set allowed cipher list for backend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.2 or earlier.
|
||||
Use \fI\%\-\-tls13\-client\-ciphers\fP for TLSv1.3.
|
||||
.sp
|
||||
Default: \fBECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:DHE\-RSA\-AES128\-GCM\-SHA256:DHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256:ECDHE\-ECDSA\-AES128\-SHA:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-RSA\-AES128\-SHA:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES256\-SHA:ECDHE\-RSA\-AES256\-SHA:DHE\-RSA\-AES128\-SHA256:DHE\-RSA\-AES128\-SHA:DHE\-RSA\-AES256\-SHA256:DHE\-RSA\-AES256\-SHA:ECDHE\-ECDSA\-DES\-CBC3\-SHA:ECDHE\-RSA\-DES\-CBC3\-SHA:EDH\-RSA\-DES\-CBC3\-SHA:AES128\-GCM\-SHA256:AES256\-GCM\-SHA384:AES128\-SHA256:AES256\-SHA256:AES128\-SHA:AES256\-SHA:DES\-CBC3\-SHA:!DSS\fP
|
||||
Default: \fBECDHE\-ECDSA\-AES256\-GCM\-SHA384:ECDHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-CHACHA20\-POLY1305:ECDHE\-RSA\-CHACHA20\-POLY1305:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA256\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-tls13\-client\-ciphers=<SUITE>
|
||||
Set allowed cipher list for backend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.3. Use
|
||||
\fI\%\-\-tls13\-client\-ciphers\fP for TLSv1.2 or earlier.
|
||||
.sp
|
||||
Default: \fBTLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -561,11 +691,14 @@ enabled for backend connections.
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-cacert=<PATH>
|
||||
Set path to trusted CA certificate file used in backend
|
||||
TLS connections. The file must be in PEM format. It
|
||||
can contain multiple certificates. If the linked
|
||||
OpenSSL is configured to load system wide certificates,
|
||||
they are loaded at startup regardless of this option.
|
||||
Set path to trusted CA certificate file. It is used in
|
||||
backend TLS connections to verify peer\(aqs certificate.
|
||||
It is also used to verify OCSP response from the script
|
||||
set by \fI\%\-\-fetch\-ocsp\-response\-file\fP\&. The file must be in
|
||||
PEM format. It can contain multiple certificates. If
|
||||
the linked OpenSSL is configured to load system wide
|
||||
certificates, they are loaded at startup regardless of
|
||||
this option.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -579,9 +712,14 @@ password protected it\(aqll be requested interactively.
|
||||
.B \-\-subcert=<KEYPATH>:<CERTPATH>[[;<PARAM>]...]
|
||||
Specify additional certificate and private key file.
|
||||
nghttpx will choose certificates based on the hostname
|
||||
indicated by client using TLS SNI extension. This
|
||||
option can be used multiple times. To make OCSP
|
||||
stapling work, <CERTPATH> must be absolute path.
|
||||
indicated by client using TLS SNI extension. If nghttpx
|
||||
is built with OpenSSL >= 1.0.2, the shared elliptic
|
||||
curves (e.g., P\-256) between client and server are also
|
||||
taken into consideration. This allows nghttpx to send
|
||||
ECDSA certificate to modern clients, while sending RSA
|
||||
based certificate to older clients. This option can be
|
||||
used multiple times. To make OCSP stapling work,
|
||||
<CERTPATH> must be absolute path.
|
||||
.sp
|
||||
Additional parameter can be specified in <PARAM>. The
|
||||
available <PARAM> is "sct\-dir=<DIR>".
|
||||
@@ -609,7 +747,7 @@ NPN. The parameter must be delimited by a single comma
|
||||
only and any white spaces are treated as a part of
|
||||
protocol string.
|
||||
.sp
|
||||
Default: \fBh2,h2\-16,h2\-14,spdy/3.1,http/1.1\fP
|
||||
Default: \fBh2,h2\-16,h2\-14,http/1.1\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -625,6 +763,14 @@ can contain multiple certificates.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-verify\-client\-tolerate\-expired
|
||||
Accept expired client certificate. Operator should
|
||||
handle the expired client certificate by some means
|
||||
(e.g., mruby script). Otherwise, this option might
|
||||
cause a security risk.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-client\-private\-key\-file=<PATH>
|
||||
Path to file that contains client private key used in
|
||||
backend client authentication.
|
||||
@@ -637,18 +783,33 @@ backend client authentication.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-tls\-proto\-list=<LIST>
|
||||
Comma delimited list of SSL/TLS protocol to be enabled.
|
||||
The following protocols are available: TLSv1.2, TLSv1.1
|
||||
and TLSv1.0. The name matching is done in
|
||||
case\-insensitive manner. The parameter must be
|
||||
delimited by a single comma only and any white spaces
|
||||
are treated as a part of protocol string. If the
|
||||
protocol list advertised by client does not overlap this
|
||||
list, you will receive the error message "unknown
|
||||
protocol".
|
||||
.B \-\-tls\-min\-proto\-version=<VER>
|
||||
Specify minimum SSL/TLS protocol. The name matching is
|
||||
done in case\-insensitive manner. The versions between
|
||||
\fI\%\-\-tls\-min\-proto\-version\fP and \fI\%\-\-tls\-max\-proto\-version\fP are
|
||||
enabled. If the protocol list advertised by client does
|
||||
not overlap this range, you will receive the error
|
||||
message "unknown protocol". If a protocol version lower
|
||||
than TLSv1.2 is specified, make sure that the compatible
|
||||
ciphers are included in \fI\%\-\-ciphers\fP option. The default
|
||||
cipher list only includes ciphers compatible with
|
||||
TLSv1.2 or above. The available versions are:
|
||||
TLSv1.3, TLSv1.2, TLSv1.1, and TLSv1.0
|
||||
.sp
|
||||
Default: \fBTLSv1.2,TLSv1.1\fP
|
||||
Default: \fBTLSv1.2\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-tls\-max\-proto\-version=<VER>
|
||||
Specify maximum SSL/TLS protocol. The name matching is
|
||||
done in case\-insensitive manner. The versions between
|
||||
\fI\%\-\-tls\-min\-proto\-version\fP and \fI\%\-\-tls\-max\-proto\-version\fP are
|
||||
enabled. If the protocol list advertised by client does
|
||||
not overlap this range, you will receive the error
|
||||
message "unknown protocol". The available versions are:
|
||||
TLSv1.3, TLSv1.2, TLSv1.1, and TLSv1.0
|
||||
.sp
|
||||
Default: \fBTLSv1.3\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -765,6 +926,20 @@ Default: \fB4h\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-ocsp\-startup
|
||||
Start accepting connections after initial attempts to
|
||||
get OCSP responses finish. It does not matter some of
|
||||
the attempts fail. This feature is useful if OCSP
|
||||
responses must be available before accepting
|
||||
connections.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-no\-verify\-ocsp
|
||||
nghttpx does not verify OCSP response.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-no\-ocsp
|
||||
Disable OCSP stapling.
|
||||
.UNINDENT
|
||||
@@ -887,14 +1062,32 @@ HTTP/2. To use those cipher suites with HTTP/2,
|
||||
consider to use \fI\%\-\-client\-no\-http2\-cipher\-black\-list\fP
|
||||
option. But be aware its implications.
|
||||
.UNINDENT
|
||||
.SS HTTP/2 and SPDY
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-tls\-no\-postpone\-early\-data
|
||||
By default, nghttpx postpones forwarding HTTP requests
|
||||
sent in early data, including those sent in partially in
|
||||
it, until TLS handshake finishes. If all backend server
|
||||
recognizes "Early\-Data" header field, using this option
|
||||
makes nghttpx not postpone forwarding request and get
|
||||
full potential of 0\-RTT data.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-tls\-max\-early\-data=<SIZE>
|
||||
Sets the maximum amount of 0\-RTT data that server
|
||||
accepts.
|
||||
.sp
|
||||
Default: \fB16K\fP
|
||||
.UNINDENT
|
||||
.SS HTTP/2
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-c, \-\-frontend\-http2\-max\-concurrent\-streams=<N>
|
||||
Set the maximum number of the concurrent streams in one
|
||||
frontend HTTP/2 and SPDY session.
|
||||
frontend HTTP/2 session.
|
||||
.sp
|
||||
Default: \(ga\(ga 100\(ga\(ga
|
||||
Default: \fB100\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -909,17 +1102,16 @@ Default: \fB100\fP
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-frontend\-http2\-window\-size=<SIZE>
|
||||
Sets the per\-stream initial window size of HTTP/2 and
|
||||
SPDY frontend connection.
|
||||
Sets the per\-stream initial window size of HTTP/2
|
||||
frontend connection.
|
||||
.sp
|
||||
Default: \fB65535\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-frontend\-http2\-connection\-window\-size=<SIZE>
|
||||
Sets the per\-connection window size of HTTP/2 and SPDY
|
||||
frontend connection. For SPDY connection, the value
|
||||
less than 64KiB is rounded up to 64KiB.
|
||||
Sets the per\-connection window size of HTTP/2 frontend
|
||||
connection.
|
||||
.sp
|
||||
Default: \fB65535\fP
|
||||
.UNINDENT
|
||||
@@ -960,8 +1152,7 @@ default mode and HTTP/2 frontend via Link header field.
|
||||
It is also supported if both frontend and backend are
|
||||
HTTP/2 in default mode. In this case, server push from
|
||||
backend session is relayed to frontend, and server push
|
||||
via Link header field is also supported. SPDY frontend
|
||||
does not support server push.
|
||||
via Link header field is also supported.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -1032,7 +1223,7 @@ Default: \fB4K\fP
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B (default mode)
|
||||
Accept HTTP/2, SPDY and HTTP/1.1 over SSL/TLS. "no\-tls"
|
||||
Accept HTTP/2, and HTTP/1.1 over SSL/TLS. "no\-tls"
|
||||
parameter is used in \fI\%\-\-frontend\fP option, accept HTTP/2
|
||||
and HTTP/1.1 over cleartext TCP. The incoming HTTP/1.1
|
||||
connection can be upgraded to HTTP/2 through HTTP
|
||||
@@ -1102,15 +1293,32 @@ $alpn: ALPN identifier of the protocol which generates
|
||||
the response. For HTTP/1, ALPN is always http/1.1,
|
||||
regardless of minor version.
|
||||
.IP \(bu 2
|
||||
$ssl_cipher: cipher used for SSL/TLS connection.
|
||||
$tls_cipher: cipher used for SSL/TLS connection.
|
||||
.IP \(bu 2
|
||||
$ssl_protocol: protocol for SSL/TLS connection.
|
||||
$tls_client_fingerprint_sha256: SHA\-256 fingerprint of
|
||||
client certificate.
|
||||
.IP \(bu 2
|
||||
$ssl_session_id: session ID for SSL/TLS connection.
|
||||
$tls_client_fingerprint_sha1: SHA\-1 fingerprint of
|
||||
client certificate.
|
||||
.IP \(bu 2
|
||||
$ssl_session_reused: "r" if SSL/TLS session was
|
||||
$tls_client_subject_name: subject name in client
|
||||
certificate.
|
||||
.IP \(bu 2
|
||||
$tls_client_issuer_name: issuer name in client
|
||||
certificate.
|
||||
.IP \(bu 2
|
||||
$tls_client_serial: serial number in client
|
||||
certificate.
|
||||
.IP \(bu 2
|
||||
$tls_protocol: protocol for SSL/TLS connection.
|
||||
.IP \(bu 2
|
||||
$tls_session_id: session ID for SSL/TLS connection.
|
||||
.IP \(bu 2
|
||||
$tls_session_reused: "r" if SSL/TLS session was
|
||||
reused. Otherwise, "."
|
||||
.IP \(bu 2
|
||||
$tls_sni: SNI server name for SSL/TLS connection.
|
||||
.IP \(bu 2
|
||||
$backend_host: backend host used to fulfill the
|
||||
request. "\-" if backend host is not available.
|
||||
.IP \(bu 2
|
||||
@@ -1167,6 +1375,21 @@ requests.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-no\-add\-x\-forwarded\-proto
|
||||
Don\(aqt append additional X\-Forwarded\-Proto header field
|
||||
to the backend request. If inbound client sets
|
||||
X\-Forwarded\-Proto, and
|
||||
\fI\%\-\-no\-strip\-incoming\-x\-forwarded\-proto\fP option is used,
|
||||
they are passed to the backend.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-no\-strip\-incoming\-x\-forwarded\-proto
|
||||
Don\(aqt strip X\-Forwarded\-Proto header field from inbound
|
||||
client requests.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-add\-forwarded=<LIST>
|
||||
Append RFC 7239 Forwarded header field with parameters
|
||||
specified in comma delimited list <LIST>. The supported
|
||||
@@ -1220,6 +1443,12 @@ is received, it is left unaltered.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-no\-strip\-incoming\-early\-data
|
||||
Don\(aqt strip Early\-Data header field from inbound client
|
||||
requests.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-no\-location\-rewrite
|
||||
Don\(aqt rewrite location header field in default mode.
|
||||
When \fI\%\-\-http2\-proxy\fP is used, location header field will
|
||||
@@ -1313,7 +1542,7 @@ backend server, the custom error pages are not used.
|
||||
.B \-\-server\-name=<NAME>
|
||||
Change server response header field value to <NAME>.
|
||||
.sp
|
||||
Default: \fBnghttpx nghttp2/1.19.0\fP
|
||||
Default: \fBnghttpx\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -1322,13 +1551,22 @@ Don\(aqt rewrite server header field in default mode. When
|
||||
\fI\%\-\-http2\-proxy\fP is used, these headers will not be altered
|
||||
regardless of this option.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-redirect\-https\-port=<PORT>
|
||||
Specify the port number which appears in Location header
|
||||
field when redirect to HTTPS URI is made due to
|
||||
"redirect\-if\-not\-tls" parameter in \fI\%\-\-backend\fP option.
|
||||
.sp
|
||||
Default: \fB443\fP
|
||||
.UNINDENT
|
||||
.SS API
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-api\-max\-request\-body=<SIZE>
|
||||
Set the maximum size of request body for API request.
|
||||
.sp
|
||||
Default: \fB16K\fP
|
||||
Default: \fB32M\fP
|
||||
.UNINDENT
|
||||
.SS DNS
|
||||
.INDENT 0.0
|
||||
@@ -1357,6 +1595,16 @@ lookup.
|
||||
.sp
|
||||
Default: \fB2\fP
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-frontend\-max\-requests=<N>
|
||||
The number of requests that single frontend connection
|
||||
can process. For HTTP/2, this is the number of streams
|
||||
in one HTTP/2 connection. For HTTP/1, this is the
|
||||
number of keep alive requests. This is hint to nghttpx,
|
||||
and it may allow additional few requests. The default
|
||||
value is unlimited.
|
||||
.UNINDENT
|
||||
.SS Debug
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -1401,17 +1649,37 @@ Set path to save PID of this program.
|
||||
Run this program as <USER>. This option is intended to
|
||||
be used to drop root privileges.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-single\-process
|
||||
Run this program in a single process mode for debugging
|
||||
purpose. Without this option, nghttpx creates at least
|
||||
2 processes: master and worker processes. If this
|
||||
option is used, master and worker are unified into a
|
||||
single process. nghttpx still spawns additional process
|
||||
if neverbleed is used. In the single process mode, the
|
||||
signal handling feature is disabled.
|
||||
.UNINDENT
|
||||
.SS Scripting
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-mruby\-file=<PATH>
|
||||
Set mruby script file
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-ignore\-per\-pattern\-mruby\-error
|
||||
Ignore mruby compile error for per\-pattern mruby script
|
||||
file. If error occurred, it is treated as if no mruby
|
||||
file were specified for the pattern.
|
||||
.UNINDENT
|
||||
.SS Misc
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B \-\-conf=<PATH>
|
||||
Load configuration from <PATH>.
|
||||
Load configuration from <PATH>. Please note that
|
||||
nghttpx always tries to read the default configuration
|
||||
file if \fI\%\-\-conf\fP is not given.
|
||||
.sp
|
||||
Default: \fB/etc/nghttpx/nghttpx.conf\fP
|
||||
.UNINDENT
|
||||
@@ -1505,7 +1773,7 @@ follows:
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B <datetime>
|
||||
It is a conbination of date and time when the log is written. It
|
||||
It is a combination of date and time when the log is written. It
|
||||
is in ISO 8601 format.
|
||||
.TP
|
||||
.B <master\-pid>
|
||||
@@ -1538,16 +1806,23 @@ Reload configuration file given in \fI\%\-\-conf\fP\&.
|
||||
.TP
|
||||
.B SIGUSR1
|
||||
Reopen log files.
|
||||
.TP
|
||||
.B SIGUSR2
|
||||
.UNINDENT
|
||||
.sp
|
||||
SIGUSR2
|
||||
.INDENT 0.0
|
||||
.INDENT 3.5
|
||||
Fork and execute nghttpx. It will execute the binary in the same
|
||||
path with same command\-line arguments and environment variables.
|
||||
After new process comes up, sending SIGQUIT to the original process
|
||||
to perform hot swapping. The difference between SIGUSR2 + SIGQUIT
|
||||
and SIGHUP is that former is usually used to execute new binary, and
|
||||
the master process is newly spawned. On the other hand, the latter
|
||||
just reloads configuration file, and the same master process
|
||||
continues to exist.
|
||||
path with same command\-line arguments and environment variables. As
|
||||
of nghttpx version 1.20.0, the new master process sends SIGQUIT to
|
||||
the original master process when it is ready to serve requests. For
|
||||
the earlier versions of nghttpx, user has to send SIGQUIT to the
|
||||
original master process.
|
||||
.sp
|
||||
The difference between SIGUSR2 (+ SIGQUIT) and SIGHUP is that former
|
||||
is usually used to execute new binary, and the master process is
|
||||
newly spawned. On the other hand, the latter just reloads
|
||||
configuration file, and the same master process continues to exist.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.sp
|
||||
\fBNOTE:\fP
|
||||
@@ -1627,6 +1902,22 @@ be customized using \fI\%\-\-fetch\-ocsp\-response\-file\fP option.
|
||||
.sp
|
||||
If OCSP query is failed, previous OCSP response, if any, is continued
|
||||
to be used.
|
||||
.sp
|
||||
\fI\%\-\-fetch\-ocsp\-response\-file\fP option provides wide range of
|
||||
possibility to manage OCSP response. It can take an arbitrary script
|
||||
or executable. The requirement is that it supports the command\-line
|
||||
interface of \fBfetch\-ocsp\-response\fP script, and it must return a
|
||||
valid DER encoded OCSP response on success. It must return exit code
|
||||
0 on success, and 75 for temporary error, and the other error code for
|
||||
generic failure. For large cluster of servers, it is not efficient
|
||||
for each server to perform OCSP query using \fBfetch\-ocsp\-response\fP\&.
|
||||
Instead, you can retrieve OCSP response in some way, and store it in a
|
||||
disk or a shared database. Then specify a program in
|
||||
\fI\%\-\-fetch\-ocsp\-response\-file\fP to fetch it from those stores.
|
||||
This could provide a way to share the OCSP response between fleet of
|
||||
servers, and also any OCSP query strategy can be applied which may be
|
||||
beyond the ability of nghttpx itself or \fBfetch\-ocsp\-response\fP
|
||||
script.
|
||||
.SH TLS SESSION RESUMPTION
|
||||
.sp
|
||||
nghttpx supports TLS session resumption through both session ID and
|
||||
@@ -1637,7 +1928,7 @@ By default, session ID is shared by all worker threads.
|
||||
.sp
|
||||
If \fI\%\-\-tls\-session\-cache\-memcached\fP is given, nghttpx will
|
||||
insert serialized session data to memcached with
|
||||
\fBnghttpx:tls\-session\-cache:\fP + lowercased hex string of session ID
|
||||
\fBnghttpx:tls\-session\-cache:\fP + lowercase hex string of session ID
|
||||
as a memcached entry key, with expiry time 12 hours. Session timeout
|
||||
is set to 12 hours.
|
||||
.sp
|
||||
@@ -1719,6 +2010,17 @@ API is subject to change in the future release.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.sp
|
||||
\fBWARNING:\fP
|
||||
.INDENT 0.0
|
||||
.INDENT 3.5
|
||||
Almost all string value returned from method, or attribute is a
|
||||
fresh new mruby string, which involves memory allocation, and
|
||||
copies. Therefore, it is strongly recommended to store a return
|
||||
value in a local variable, and use it, instead of calling method or
|
||||
accessing attribute repeatedly.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.sp
|
||||
nghttpx allows users to extend its capability using mruby scripts.
|
||||
nghttpx has 2 hook points to execute mruby script: request phase and
|
||||
response phase. The request phase hook is invoked after all request
|
||||
@@ -1728,9 +2030,28 @@ server. These hooks allows users to modify header fields, or common
|
||||
HTTP variables, like authority or request path, and even return custom
|
||||
response without forwarding request to backend servers.
|
||||
.sp
|
||||
To specify mruby script file, use \fI\%\-\-mruby\-file\fP option. The
|
||||
script will be evaluated once per thread on startup, and it must
|
||||
instantiate object and evaluate it as the return value (e.g.,
|
||||
There are 2 levels of mruby script invocations: global and
|
||||
per\-pattern. The global mruby script is set by \fI\%\-\-mruby\-file\fP
|
||||
option and is called for all requests. The per\-pattern mruby script
|
||||
is set by "mruby" parameter in \fI\%\-b\fP option. It is invoked for
|
||||
a request which matches the particular pattern. The order of hook
|
||||
invocation is: global request phase hook, per\-pattern request phase
|
||||
hook, per\-pattern response phase hook, and finally global response
|
||||
phase hook. If a hook returns a response, any later hooks are not
|
||||
invoked. The global request hook is invoked before the pattern
|
||||
matching is made and changing request path may affect the pattern
|
||||
matching.
|
||||
.sp
|
||||
Please note that request and response hooks of per\-pattern mruby
|
||||
script for a single request might not come from the same script. This
|
||||
might happen after a request hook is executed, backend failed for some
|
||||
reason, and at the same time, backend configuration is replaced by API
|
||||
request, and then the request uses new configuration on retry. The
|
||||
response hook from new configuration, if it is specified, will be
|
||||
invoked.
|
||||
.sp
|
||||
The all mruby script will be evaluated once per thread on startup, and
|
||||
it must instantiate object and evaluate it as the return value (e.g.,
|
||||
\fBApp.new\fP). This object is called app object. If app object
|
||||
defines \fBon_req\fP method, it is called with \fI\%Nghttpx::Env\fP
|
||||
object on request hook. Similarly, if app object defines \fBon_resp\fP
|
||||
@@ -1767,7 +2088,7 @@ Return \fI\%Response\fP object.
|
||||
.TP
|
||||
.B attribute [R] ctx
|
||||
Return Ruby hash object. It persists until request finishes.
|
||||
So values set in request phase hoo can be retrieved in
|
||||
So values set in request phase hook can be retrieved in
|
||||
response phase hook.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
@@ -1805,6 +2126,77 @@ Return true if TLS is used on the connection.
|
||||
.B attribute [R] tls_sni
|
||||
Return the TLS SNI value which client sent in this connection.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_fingerprint_sha256
|
||||
Return the SHA\-256 fingerprint of a client certificate.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_fingerprint_sha1
|
||||
Return the SHA\-1 fingerprint of a client certificate.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_issuer_name
|
||||
Return the issuer name of a client certificate.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_subject_name
|
||||
Return the subject name of a client certificate.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_serial
|
||||
Return the serial number of a client certificate.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_not_before
|
||||
Return the start date of a client certificate in seconds since
|
||||
the epoch.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_client_not_after
|
||||
Return the end date of a client certificate in seconds since
|
||||
the epoch.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_cipher
|
||||
Return a TLS cipher negotiated in this connection.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_protocol
|
||||
Return a TLS protocol version negotiated in this connection.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_session_id
|
||||
Return a session ID for this connection in hex string.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_session_reused
|
||||
Return true if, and only if a SSL/TLS session is reused.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] alpn
|
||||
Return ALPN identifier negotiated in this connection.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B attribute [R] tls_handshake_finished
|
||||
Return true if SSL/TLS handshake has finished. If it returns
|
||||
false in the request phase hook, the request is received in
|
||||
TLSv1.3 early data (0\-RTT) and might be vulnerable to the
|
||||
replay attack. nghttpx will send Early\-Data header field to
|
||||
backend servers to indicate this.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
@@ -1956,10 +2348,10 @@ to the backend, and response phase hook for this request will
|
||||
not be invoked. When this method is called in response phase
|
||||
hook, response from backend server is canceled and discarded.
|
||||
The status code and response header fields should be set
|
||||
before using this method. To set status code, use :rb:meth To
|
||||
set response header fields, use
|
||||
before using this method. To set status code, use
|
||||
\fI\%Nghttpx::Response#status\fP\&. If status code is not
|
||||
set, 200 is used. \fI\%Nghttpx::Response#add_header\fP and
|
||||
set, 200 is used. To set response header fields,
|
||||
\fI\%Nghttpx::Response#add_header\fP and
|
||||
\fI\%Nghttpx::Response#set_header\fP\&. When this method is
|
||||
invoked in response phase hook, the response headers are
|
||||
filled with the ones received from backend server. To send
|
||||
@@ -1968,6 +2360,19 @@ completely custom header fields, first call
|
||||
existing header fields, and then add required header fields.
|
||||
It is an error to call this method twice for a given request.
|
||||
.UNINDENT
|
||||
.INDENT 7.0
|
||||
.TP
|
||||
.B send_info(status, headers)
|
||||
Send non\-final (informational) response to a client. \fIstatus\fP
|
||||
must be in the range [100, 199], inclusive. \fIheaders\fP is a
|
||||
hash containing response header fields. Its key must be a
|
||||
string, and the associated value must be either string or
|
||||
array of strings. Since this is not a final response, even if
|
||||
this method is invoked, request is still forwarded to a
|
||||
backend unless \fI\%Nghttpx::Response#return\fP is called.
|
||||
This method can be called multiple times. It cannot be called
|
||||
after \fI\%Nghttpx::Response#return\fP is called.
|
||||
.UNINDENT
|
||||
.UNINDENT
|
||||
.SS MRUBY EXAMPLES
|
||||
.sp
|
||||
@@ -2043,15 +2448,18 @@ The request was failed. No change has been made.
|
||||
HTTP status code
|
||||
.UNINDENT
|
||||
.sp
|
||||
Additionally, depending on the API endpoint, \fBdata\fP key may be
|
||||
present, and its value contains the API endpoint specific data.
|
||||
.sp
|
||||
We wrote "normally", since nghttpx may return ordinal HTML response in
|
||||
some cases where the error has occurred before reaching API endpoint
|
||||
(e.g., header field is too large).
|
||||
.sp
|
||||
The following section describes available API endpoints.
|
||||
.SS PUT /api/v1beta1/backendconfig
|
||||
.SS POST /api/v1beta1/backendconfig
|
||||
.sp
|
||||
This API replaces the current backend server settings with the
|
||||
requested ones. The request method should be PUT, but POST is also
|
||||
requested ones. The request method should be POST, but PUT is also
|
||||
acceptable. The request body must be nghttpx configuration file
|
||||
format. For configuration file format, see \fI\%FILES\fP section. The
|
||||
line separator inside the request body must be single LF (0x0A).
|
||||
@@ -2066,10 +2474,28 @@ The replacement is done instantly without breaking existing
|
||||
connections or requests. It also avoids any process creation as is
|
||||
the case with hot swapping with signals.
|
||||
.sp
|
||||
The one limitation is that only numeric IP address is allowd in
|
||||
The one limitation is that only numeric IP address is allowed in
|
||||
\fI\%backend\fP in request body unless "dns" parameter
|
||||
is used while non numeric hostname is allowed in command\-line or
|
||||
configuration file is read using \fI\%\-\-conf\fP\&.
|
||||
.SS GET /api/v1beta1/configrevision
|
||||
.sp
|
||||
This API returns configuration revision of the current nghttpx. The
|
||||
configuration revision is opaque string, and it changes after each
|
||||
reloading by SIGHUP. With this API, an external application knows
|
||||
that whether nghttpx has finished reloading its configuration by
|
||||
comparing the configuration revisions between before and after
|
||||
reloading. It is recommended to disable persistent (keep\-alive)
|
||||
connection for this purpose in order to avoid to send a request using
|
||||
the reused connection which may bound to an old process.
|
||||
.sp
|
||||
This API returns response including \fBdata\fP key. Its value is JSON
|
||||
object, and it contains at least the following key:
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
.B configRevision
|
||||
The configuration revision of the current nghttpx
|
||||
.UNINDENT
|
||||
.SH SEE ALSO
|
||||
.sp
|
||||
\fBnghttp(1)\fP, \fBnghttpd(1)\fP, \fBh2load(1)\fP
|
||||
|
||||
@@ -14,7 +14,7 @@ SYNOPSIS
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
A reverse proxy for HTTP/2, HTTP/1 and SPDY.
|
||||
A reverse proxy for HTTP/2, and HTTP/1.
|
||||
|
||||
.. describe:: <PRIVATE_KEY>
|
||||
|
||||
@@ -46,8 +46,7 @@ Connections
|
||||
with "unix:" (e.g., unix:/var/run/backend.sock).
|
||||
|
||||
Optionally, if <PATTERN>s are given, the backend address
|
||||
is only used if request matches the pattern. If
|
||||
:option:`--http2-proxy` is used, <PATTERN>s are ignored. The
|
||||
is only used if request matches the pattern. The
|
||||
pattern matching is closely designed to ServeMux in
|
||||
net/http package of Go programming language. <PATTERN>
|
||||
consists of path, host + path or just host. The path
|
||||
@@ -58,11 +57,16 @@ Connections
|
||||
which only lacks trailing '*/*' (e.g., path "*/foo/*"
|
||||
matches request path "*/foo*"). If it does not end with
|
||||
"*/*", it performs exact match against the request path.
|
||||
If host is given, it performs exact match against the
|
||||
request host. If host alone is given, "*/*" is appended
|
||||
to it, so that it matches all request paths under the
|
||||
host (e.g., specifying "nghttp2.org" equals to
|
||||
"nghttp2.org/").
|
||||
If host is given, it performs a match against the
|
||||
request host. For a request received on the frontend
|
||||
listener with "sni-fwd" parameter enabled, SNI host is
|
||||
used instead of a request host. If host alone is given,
|
||||
"*/*" is appended to it, so that it matches all request
|
||||
paths under the host (e.g., specifying "nghttp2.org"
|
||||
equals to "nghttp2.org/"). CONNECT method is treated
|
||||
specially. It does not have path, and we don't allow
|
||||
empty path. To workaround this, we assume that CONNECT
|
||||
method has "*/*" as path.
|
||||
|
||||
Patterns with host take precedence over patterns with
|
||||
just path. Then, longer patterns take precedence over
|
||||
@@ -76,6 +80,18 @@ Connections
|
||||
match against "nghttp2.org". The exact hosts match
|
||||
takes precedence over the wildcard hosts match.
|
||||
|
||||
If path part ends with "\*", it is treated as wildcard
|
||||
path. The wildcard path behaves differently from the
|
||||
normal path. For normal path, match is made around the
|
||||
boundary of path component separator,"*/*". On the other
|
||||
hand, the wildcard path does not take into account the
|
||||
path component separator. All paths which include the
|
||||
wildcard path without last "\*" as prefix, and are
|
||||
strictly longer than wildcard path without last "\*" are
|
||||
matched. "\*" must match at least one character. For
|
||||
example, the pattern "*/foo\**" matches "*/foo/*" and
|
||||
"*/foobar*". But it does not match "*/foo*", or "*/fo*".
|
||||
|
||||
If <PATTERN> is omitted or empty string, "*/*" is used as
|
||||
pattern, which matches all request paths (catch-all
|
||||
pattern). The catch-all backend must be given.
|
||||
@@ -105,12 +121,15 @@ Connections
|
||||
The parameters are delimited by ";". The available
|
||||
parameters are: "proto=<PROTO>", "tls",
|
||||
"sni=<SNI_HOST>", "fall=<N>", "rise=<N>",
|
||||
"affinity=<METHOD>", and "dns". The parameter consists
|
||||
of keyword, and optionally followed by "=" and value.
|
||||
For example, the parameter "proto=h2" consists of the
|
||||
keyword "proto" and value "h2". The parameter "tls"
|
||||
consists of the keyword "tls" without value. Each
|
||||
parameter is described as follows.
|
||||
"affinity=<METHOD>", "dns", "redirect-if-not-tls",
|
||||
"upgrade-scheme", "mruby=<PATH>",
|
||||
"read-timeout=<DURATION>", "write-timeout=<DURATION>",
|
||||
"group=<GROUP>", "group-weight=<N>", and "weight=<N>".
|
||||
The parameter consists of keyword, and optionally
|
||||
followed by "=" and value. For example, the parameter
|
||||
"proto=h2" consists of the keyword "proto" and value
|
||||
"h2". The parameter "tls" consists of the keyword "tls"
|
||||
without value. Each parameter is described as follows.
|
||||
|
||||
The backend application protocol can be specified using
|
||||
optional "proto" parameter, and in the form of
|
||||
@@ -148,16 +167,32 @@ Connections
|
||||
The session affinity is enabled using
|
||||
"affinity=<METHOD>" parameter. If "ip" is given in
|
||||
<METHOD>, client IP based session affinity is enabled.
|
||||
If "none" is given in <METHOD>, session affinity is
|
||||
disabled, and this is the default. The session affinity
|
||||
is enabled per <PATTERN>. If at least one backend has
|
||||
"affinity" parameter, and its <METHOD> is not "none",
|
||||
session affinity is enabled for all backend servers
|
||||
sharing the same <PATTERN>. It is advised to set
|
||||
"affinity" parameter to all backend explicitly if
|
||||
session affinity is desired. The session affinity may
|
||||
break if one of the backend gets unreachable, or backend
|
||||
settings are reloaded or replaced by API.
|
||||
If "cookie" is given in <METHOD>, cookie based session
|
||||
affinity is enabled. If "none" is given in <METHOD>,
|
||||
session affinity is disabled, and this is the default.
|
||||
The session affinity is enabled per <PATTERN>. If at
|
||||
least one backend has "affinity" parameter, and its
|
||||
<METHOD> is not "none", session affinity is enabled for
|
||||
all backend servers sharing the same <PATTERN>. It is
|
||||
advised to set "affinity" parameter to all backend
|
||||
explicitly if session affinity is desired. The session
|
||||
affinity may break if one of the backend gets
|
||||
unreachable, or backend settings are reloaded or
|
||||
replaced by API.
|
||||
|
||||
If "affinity=cookie" is used, the additional
|
||||
configuration is required.
|
||||
"affinity-cookie-name=<NAME>" must be used to specify a
|
||||
name of cookie to use. Optionally,
|
||||
"affinity-cookie-path=<PATH>" can be used to specify a
|
||||
path which cookie is applied. The optional
|
||||
"affinity-cookie-secure=<SECURE>" controls the Secure
|
||||
attribute of a cookie. The default value is "auto", and
|
||||
the Secure attribute is determined by a request scheme.
|
||||
If a request scheme is "https", then Secure attribute is
|
||||
set. Otherwise, it is not set. If <SECURE> is "yes",
|
||||
the Secure attribute is always set. If <SECURE> is
|
||||
"no", the Secure attribute is always omitted.
|
||||
|
||||
By default, name resolution of backend host name is done
|
||||
at start up, or reloading configuration. If "dns"
|
||||
@@ -167,6 +202,64 @@ Connections
|
||||
backend host name at start up, or reloading
|
||||
configuration is skipped.
|
||||
|
||||
If "redirect-if-not-tls" parameter is used, the matched
|
||||
backend requires that frontend connection is TLS
|
||||
encrypted. If it isn't, nghttpx responds to the request
|
||||
with 308 status code, and https URI the client should
|
||||
use instead is included in Location header field. The
|
||||
port number in redirect URI is 443 by default, and can
|
||||
be changed using :option:`--redirect-https-port` option. If at
|
||||
least one backend has "redirect-if-not-tls" parameter,
|
||||
this feature is enabled for all backend servers sharing
|
||||
the same <PATTERN>. It is advised to set
|
||||
"redirect-if-no-tls" parameter to all backends
|
||||
explicitly if this feature is desired.
|
||||
|
||||
If "upgrade-scheme" parameter is used along with "tls"
|
||||
parameter, HTTP/2 :scheme pseudo header field is changed
|
||||
to "https" from "http" when forwarding a request to this
|
||||
particular backend. This is a workaround for a backend
|
||||
server which requires "https" :scheme pseudo header
|
||||
field on TLS encrypted connection.
|
||||
|
||||
"mruby=<PATH>" parameter specifies a path to mruby
|
||||
script file which is invoked when this pattern is
|
||||
matched. All backends which share the same pattern must
|
||||
have the same mruby path.
|
||||
|
||||
"read-timeout=<DURATION>" and "write-timeout=<DURATION>"
|
||||
parameters specify the read and write timeout of the
|
||||
backend connection when this pattern is matched. All
|
||||
backends which share the same pattern must have the same
|
||||
timeouts. If these timeouts are entirely omitted for a
|
||||
pattern, :option:`--backend-read-timeout` and
|
||||
:option:`--backend-write-timeout` are used.
|
||||
|
||||
"group=<GROUP>" parameter specifies the name of group
|
||||
this backend address belongs to. By default, it belongs
|
||||
to the unnamed default group. The name of group is
|
||||
unique per pattern. "group-weight=<N>" parameter
|
||||
specifies the weight of the group. The higher weight
|
||||
gets more frequently selected by the load balancing
|
||||
algorithm. <N> must be [1, 256] inclusive. The weight
|
||||
8 has 4 times more weight than 2. <N> must be the same
|
||||
for all addresses which share the same <GROUP>. If
|
||||
"group-weight" is omitted in an address, but the other
|
||||
address which belongs to the same group specifies
|
||||
"group-weight", its weight is used. If no
|
||||
"group-weight" is specified for all addresses, the
|
||||
weight of a group becomes 1. "group" and "group-weight"
|
||||
are ignored if session affinity is enabled.
|
||||
|
||||
"weight=<N>" parameter specifies the weight of the
|
||||
backend address inside a group which this address
|
||||
belongs to. The higher weight gets more frequently
|
||||
selected by the load balancing algorithm. <N> must be
|
||||
[1, 256] inclusive. The weight 8 has 4 times more
|
||||
weight than weight 2. If this parameter is omitted,
|
||||
weight becomes 1. "weight" is ignored if session
|
||||
affinity is enabled.
|
||||
|
||||
Since ";" and ":" are used as delimiter, <PATTERN> must
|
||||
not contain these characters. Since ";" has special
|
||||
meaning in shell, the option value must be quoted.
|
||||
@@ -190,6 +283,11 @@ Connections
|
||||
Optionally, TLS can be disabled by specifying "no-tls"
|
||||
parameter. TLS is enabled by default.
|
||||
|
||||
If "sni-fwd" parameter is used, when performing a match
|
||||
to select a backend server, SNI host name received from
|
||||
the client is used instead of the request host. See
|
||||
:option:`--backend` option about the pattern match.
|
||||
|
||||
To make this frontend as API endpoint, specify "api"
|
||||
parameter. This is disabled by default. It is
|
||||
important to limit the access to the API frontend.
|
||||
@@ -249,6 +347,14 @@ Performance
|
||||
|
||||
Default: ``1``
|
||||
|
||||
.. option:: --single-thread
|
||||
|
||||
Run everything in one thread inside the worker process.
|
||||
This feature is provided for better debugging
|
||||
experience, or for the platforms which lack thread
|
||||
support. If threading is disabled, this option is
|
||||
always enabled.
|
||||
|
||||
.. option:: --read-rate=<SIZE>
|
||||
|
||||
Set maximum average read rate on frontend connection.
|
||||
@@ -382,8 +488,7 @@ Timeout
|
||||
|
||||
.. option:: --frontend-http2-read-timeout=<DURATION>
|
||||
|
||||
Specify read timeout for HTTP/2 and SPDY frontend
|
||||
connection.
|
||||
Specify read timeout for HTTP/2 frontend connection.
|
||||
|
||||
Default: ``3m``
|
||||
|
||||
@@ -408,17 +513,17 @@ Timeout
|
||||
|
||||
.. option:: --stream-read-timeout=<DURATION>
|
||||
|
||||
Specify read timeout for HTTP/2 and SPDY streams. 0
|
||||
means no timeout.
|
||||
Specify read timeout for HTTP/2 streams. 0 means no
|
||||
timeout.
|
||||
|
||||
Default: ``0``
|
||||
|
||||
.. option:: --stream-write-timeout=<DURATION>
|
||||
|
||||
Specify write timeout for HTTP/2 and SPDY streams. 0
|
||||
means no timeout.
|
||||
Specify write timeout for HTTP/2 streams. 0 means no
|
||||
timeout.
|
||||
|
||||
Default: ``0``
|
||||
Default: ``1m``
|
||||
|
||||
.. option:: --backend-read-timeout=<DURATION>
|
||||
|
||||
@@ -489,15 +594,37 @@ SSL/TLS
|
||||
|
||||
Set allowed cipher list for frontend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.2 or earlier.
|
||||
Use :option:`--tls13-ciphers` for TLSv1.3.
|
||||
|
||||
Default: ``ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS``
|
||||
Default: ``ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256``
|
||||
|
||||
.. option:: --tls13-ciphers=<SUITE>
|
||||
|
||||
Set allowed cipher list for frontend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.3. Use
|
||||
:option:`--ciphers` for TLSv1.2 or earlier.
|
||||
|
||||
Default: ``TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256``
|
||||
|
||||
.. option:: --client-ciphers=<SUITE>
|
||||
|
||||
Set allowed cipher list for backend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.2 or earlier.
|
||||
Use :option:`--tls13-client-ciphers` for TLSv1.3.
|
||||
|
||||
Default: ``ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS``
|
||||
Default: ``ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256``
|
||||
|
||||
.. option:: --tls13-client-ciphers=<SUITE>
|
||||
|
||||
Set allowed cipher list for backend connection. The
|
||||
format of the string is described in OpenSSL ciphers(1).
|
||||
This option sets cipher suites for TLSv1.3. Use
|
||||
:option:`--tls13-client-ciphers` for TLSv1.2 or earlier.
|
||||
|
||||
Default: ``TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256``
|
||||
|
||||
.. option:: --ecdh-curves=<LIST>
|
||||
|
||||
@@ -516,11 +643,14 @@ SSL/TLS
|
||||
|
||||
.. option:: --cacert=<PATH>
|
||||
|
||||
Set path to trusted CA certificate file used in backend
|
||||
TLS connections. The file must be in PEM format. It
|
||||
can contain multiple certificates. If the linked
|
||||
OpenSSL is configured to load system wide certificates,
|
||||
they are loaded at startup regardless of this option.
|
||||
Set path to trusted CA certificate file. It is used in
|
||||
backend TLS connections to verify peer's certificate.
|
||||
It is also used to verify OCSP response from the script
|
||||
set by :option:`--fetch-ocsp-response-file`\. The file must be in
|
||||
PEM format. It can contain multiple certificates. If
|
||||
the linked OpenSSL is configured to load system wide
|
||||
certificates, they are loaded at startup regardless of
|
||||
this option.
|
||||
|
||||
.. option:: --private-key-passwd-file=<PATH>
|
||||
|
||||
@@ -532,9 +662,14 @@ SSL/TLS
|
||||
|
||||
Specify additional certificate and private key file.
|
||||
nghttpx will choose certificates based on the hostname
|
||||
indicated by client using TLS SNI extension. This
|
||||
option can be used multiple times. To make OCSP
|
||||
stapling work, <CERTPATH> must be absolute path.
|
||||
indicated by client using TLS SNI extension. If nghttpx
|
||||
is built with OpenSSL >= 1.0.2, the shared elliptic
|
||||
curves (e.g., P-256) between client and server are also
|
||||
taken into consideration. This allows nghttpx to send
|
||||
ECDSA certificate to modern clients, while sending RSA
|
||||
based certificate to older clients. This option can be
|
||||
used multiple times. To make OCSP stapling work,
|
||||
<CERTPATH> must be absolute path.
|
||||
|
||||
Additional parameter can be specified in <PARAM>. The
|
||||
available <PARAM> is "sct-dir=<DIR>".
|
||||
@@ -560,7 +695,7 @@ SSL/TLS
|
||||
only and any white spaces are treated as a part of
|
||||
protocol string.
|
||||
|
||||
Default: ``h2,h2-16,h2-14,spdy/3.1,http/1.1``
|
||||
Default: ``h2,h2-16,h2-14,http/1.1``
|
||||
|
||||
.. option:: --verify-client
|
||||
|
||||
@@ -572,6 +707,13 @@ SSL/TLS
|
||||
client certificate. The file must be in PEM format. It
|
||||
can contain multiple certificates.
|
||||
|
||||
.. option:: --verify-client-tolerate-expired
|
||||
|
||||
Accept expired client certificate. Operator should
|
||||
handle the expired client certificate by some means
|
||||
(e.g., mruby script). Otherwise, this option might
|
||||
cause a security risk.
|
||||
|
||||
.. option:: --client-private-key-file=<PATH>
|
||||
|
||||
Path to file that contains client private key used in
|
||||
@@ -582,19 +724,33 @@ SSL/TLS
|
||||
Path to file that contains client certificate used in
|
||||
backend client authentication.
|
||||
|
||||
.. option:: --tls-proto-list=<LIST>
|
||||
.. option:: --tls-min-proto-version=<VER>
|
||||
|
||||
Comma delimited list of SSL/TLS protocol to be enabled.
|
||||
The following protocols are available: TLSv1.2, TLSv1.1
|
||||
and TLSv1.0. The name matching is done in
|
||||
case-insensitive manner. The parameter must be
|
||||
delimited by a single comma only and any white spaces
|
||||
are treated as a part of protocol string. If the
|
||||
protocol list advertised by client does not overlap this
|
||||
list, you will receive the error message "unknown
|
||||
protocol".
|
||||
Specify minimum SSL/TLS protocol. The name matching is
|
||||
done in case-insensitive manner. The versions between
|
||||
:option:`--tls-min-proto-version` and :option:`\--tls-max-proto-version` are
|
||||
enabled. If the protocol list advertised by client does
|
||||
not overlap this range, you will receive the error
|
||||
message "unknown protocol". If a protocol version lower
|
||||
than TLSv1.2 is specified, make sure that the compatible
|
||||
ciphers are included in :option:`--ciphers` option. The default
|
||||
cipher list only includes ciphers compatible with
|
||||
TLSv1.2 or above. The available versions are:
|
||||
TLSv1.3, TLSv1.2, TLSv1.1, and TLSv1.0
|
||||
|
||||
Default: ``TLSv1.2,TLSv1.1``
|
||||
Default: ``TLSv1.2``
|
||||
|
||||
.. option:: --tls-max-proto-version=<VER>
|
||||
|
||||
Specify maximum SSL/TLS protocol. The name matching is
|
||||
done in case-insensitive manner. The versions between
|
||||
:option:`--tls-min-proto-version` and :option:`\--tls-max-proto-version` are
|
||||
enabled. If the protocol list advertised by client does
|
||||
not overlap this range, you will receive the error
|
||||
message "unknown protocol". The available versions are:
|
||||
TLSv1.3, TLSv1.2, TLSv1.1, and TLSv1.0
|
||||
|
||||
Default: ``TLSv1.3``
|
||||
|
||||
.. option:: --tls-ticket-key-file=<PATH>
|
||||
|
||||
@@ -698,6 +854,18 @@ SSL/TLS
|
||||
|
||||
Default: ``4h``
|
||||
|
||||
.. option:: --ocsp-startup
|
||||
|
||||
Start accepting connections after initial attempts to
|
||||
get OCSP responses finish. It does not matter some of
|
||||
the attempts fail. This feature is useful if OCSP
|
||||
responses must be available before accepting
|
||||
connections.
|
||||
|
||||
.. option:: --no-verify-ocsp
|
||||
|
||||
nghttpx does not verify OCSP response.
|
||||
|
||||
.. option:: --no-ocsp
|
||||
|
||||
Disable OCSP stapling.
|
||||
@@ -810,16 +978,32 @@ SSL/TLS
|
||||
consider to use :option:`--client-no-http2-cipher-black-list`
|
||||
option. But be aware its implications.
|
||||
|
||||
.. option:: --tls-no-postpone-early-data
|
||||
|
||||
HTTP/2 and SPDY
|
||||
~~~~~~~~~~~~~~~
|
||||
By default, nghttpx postpones forwarding HTTP requests
|
||||
sent in early data, including those sent in partially in
|
||||
it, until TLS handshake finishes. If all backend server
|
||||
recognizes "Early-Data" header field, using this option
|
||||
makes nghttpx not postpone forwarding request and get
|
||||
full potential of 0-RTT data.
|
||||
|
||||
.. option:: --tls-max-early-data=<SIZE>
|
||||
|
||||
Sets the maximum amount of 0-RTT data that server
|
||||
accepts.
|
||||
|
||||
Default: ``16K``
|
||||
|
||||
|
||||
HTTP/2
|
||||
~~~~~~
|
||||
|
||||
.. option:: -c, --frontend-http2-max-concurrent-streams=<N>
|
||||
|
||||
Set the maximum number of the concurrent streams in one
|
||||
frontend HTTP/2 and SPDY session.
|
||||
frontend HTTP/2 session.
|
||||
|
||||
Default: `` 100``
|
||||
Default: ``100``
|
||||
|
||||
.. option:: --backend-http2-max-concurrent-streams=<N>
|
||||
|
||||
@@ -832,16 +1016,15 @@ HTTP/2 and SPDY
|
||||
|
||||
.. option:: --frontend-http2-window-size=<SIZE>
|
||||
|
||||
Sets the per-stream initial window size of HTTP/2 and
|
||||
SPDY frontend connection.
|
||||
Sets the per-stream initial window size of HTTP/2
|
||||
frontend connection.
|
||||
|
||||
Default: ``65535``
|
||||
|
||||
.. option:: --frontend-http2-connection-window-size=<SIZE>
|
||||
|
||||
Sets the per-connection window size of HTTP/2 and SPDY
|
||||
frontend connection. For SPDY connection, the value
|
||||
less than 64KiB is rounded up to 64KiB.
|
||||
Sets the per-connection window size of HTTP/2 frontend
|
||||
connection.
|
||||
|
||||
Default: ``65535``
|
||||
|
||||
@@ -877,8 +1060,7 @@ HTTP/2 and SPDY
|
||||
It is also supported if both frontend and backend are
|
||||
HTTP/2 in default mode. In this case, server push from
|
||||
backend session is relayed to frontend, and server push
|
||||
via Link header field is also supported. SPDY frontend
|
||||
does not support server push.
|
||||
via Link header field is also supported.
|
||||
|
||||
.. option:: --frontend-http2-optimize-write-buffer-size
|
||||
|
||||
@@ -946,7 +1128,7 @@ Mode
|
||||
.. describe:: (default mode)
|
||||
|
||||
|
||||
Accept HTTP/2, SPDY and HTTP/1.1 over SSL/TLS. "no-tls"
|
||||
Accept HTTP/2, and HTTP/1.1 over SSL/TLS. "no-tls"
|
||||
parameter is used in :option:`--frontend` option, accept HTTP/2
|
||||
and HTTP/1.1 over cleartext TCP. The incoming HTTP/1.1
|
||||
connection can be upgraded to HTTP/2 through HTTP
|
||||
@@ -1001,11 +1183,22 @@ Logging
|
||||
* $alpn: ALPN identifier of the protocol which generates
|
||||
the response. For HTTP/1, ALPN is always http/1.1,
|
||||
regardless of minor version.
|
||||
* $ssl_cipher: cipher used for SSL/TLS connection.
|
||||
* $ssl_protocol: protocol for SSL/TLS connection.
|
||||
* $ssl_session_id: session ID for SSL/TLS connection.
|
||||
* $ssl_session_reused: "r" if SSL/TLS session was
|
||||
* $tls_cipher: cipher used for SSL/TLS connection.
|
||||
* $tls_client_fingerprint_sha256: SHA-256 fingerprint of
|
||||
client certificate.
|
||||
* $tls_client_fingerprint_sha1: SHA-1 fingerprint of
|
||||
client certificate.
|
||||
* $tls_client_subject_name: subject name in client
|
||||
certificate.
|
||||
* $tls_client_issuer_name: issuer name in client
|
||||
certificate.
|
||||
* $tls_client_serial: serial number in client
|
||||
certificate.
|
||||
* $tls_protocol: protocol for SSL/TLS connection.
|
||||
* $tls_session_id: session ID for SSL/TLS connection.
|
||||
* $tls_session_reused: "r" if SSL/TLS session was
|
||||
reused. Otherwise, "."
|
||||
* $tls_sni: SNI server name for SSL/TLS connection.
|
||||
* $backend_host: backend host used to fulfill the
|
||||
request. "-" if backend host is not available.
|
||||
* $backend_port: backend port used to fulfill the
|
||||
@@ -1056,6 +1249,19 @@ HTTP
|
||||
Strip X-Forwarded-For header field from inbound client
|
||||
requests.
|
||||
|
||||
.. option:: --no-add-x-forwarded-proto
|
||||
|
||||
Don't append additional X-Forwarded-Proto header field
|
||||
to the backend request. If inbound client sets
|
||||
X-Forwarded-Proto, and
|
||||
:option:`--no-strip-incoming-x-forwarded-proto` option is used,
|
||||
they are passed to the backend.
|
||||
|
||||
.. option:: --no-strip-incoming-x-forwarded-proto
|
||||
|
||||
Don't strip X-Forwarded-Proto header field from inbound
|
||||
client requests.
|
||||
|
||||
.. option:: --add-forwarded=<LIST>
|
||||
|
||||
Append RFC 7239 Forwarded header field with parameters
|
||||
@@ -1104,6 +1310,11 @@ HTTP
|
||||
Don't append to Via header field. If Via header field
|
||||
is received, it is left unaltered.
|
||||
|
||||
.. option:: --no-strip-incoming-early-data
|
||||
|
||||
Don't strip Early-Data header field from inbound client
|
||||
requests.
|
||||
|
||||
.. option:: --no-location-rewrite
|
||||
|
||||
Don't rewrite location header field in default mode.
|
||||
@@ -1188,7 +1399,7 @@ HTTP
|
||||
|
||||
Change server response header field value to <NAME>.
|
||||
|
||||
Default: ``nghttpx nghttp2/1.19.0``
|
||||
Default: ``nghttpx``
|
||||
|
||||
.. option:: --no-server-rewrite
|
||||
|
||||
@@ -1196,6 +1407,14 @@ HTTP
|
||||
:option:`--http2-proxy` is used, these headers will not be altered
|
||||
regardless of this option.
|
||||
|
||||
.. option:: --redirect-https-port=<PORT>
|
||||
|
||||
Specify the port number which appears in Location header
|
||||
field when redirect to HTTPS URI is made due to
|
||||
"redirect-if-not-tls" parameter in :option:`--backend` option.
|
||||
|
||||
Default: ``443``
|
||||
|
||||
|
||||
API
|
||||
~~~
|
||||
@@ -1204,7 +1423,7 @@ API
|
||||
|
||||
Set the maximum size of request body for API request.
|
||||
|
||||
Default: ``16K``
|
||||
Default: ``32M``
|
||||
|
||||
|
||||
DNS
|
||||
@@ -1233,6 +1452,15 @@ DNS
|
||||
|
||||
Default: ``2``
|
||||
|
||||
.. option:: --frontend-max-requests=<N>
|
||||
|
||||
The number of requests that single frontend connection
|
||||
can process. For HTTP/2, this is the number of streams
|
||||
in one HTTP/2 connection. For HTTP/1, this is the
|
||||
number of keep alive requests. This is hint to nghttpx,
|
||||
and it may allow additional few requests. The default
|
||||
value is unlimited.
|
||||
|
||||
|
||||
Debug
|
||||
~~~~~
|
||||
@@ -1277,6 +1505,16 @@ Process
|
||||
Run this program as <USER>. This option is intended to
|
||||
be used to drop root privileges.
|
||||
|
||||
.. option:: --single-process
|
||||
|
||||
Run this program in a single process mode for debugging
|
||||
purpose. Without this option, nghttpx creates at least
|
||||
2 processes: master and worker processes. If this
|
||||
option is used, master and worker are unified into a
|
||||
single process. nghttpx still spawns additional process
|
||||
if neverbleed is used. In the single process mode, the
|
||||
signal handling feature is disabled.
|
||||
|
||||
|
||||
Scripting
|
||||
~~~~~~~~~
|
||||
@@ -1285,13 +1523,21 @@ Scripting
|
||||
|
||||
Set mruby script file
|
||||
|
||||
.. option:: --ignore-per-pattern-mruby-error
|
||||
|
||||
Ignore mruby compile error for per-pattern mruby script
|
||||
file. If error occurred, it is treated as if no mruby
|
||||
file were specified for the pattern.
|
||||
|
||||
|
||||
Misc
|
||||
~~~~
|
||||
|
||||
.. option:: --conf=<PATH>
|
||||
|
||||
Load configuration from <PATH>.
|
||||
Load configuration from <PATH>. Please note that
|
||||
nghttpx always tries to read the default configuration
|
||||
file if :option:`--conf` is not given.
|
||||
|
||||
Default: ``/etc/nghttpx/nghttpx.conf``
|
||||
|
||||
@@ -1371,7 +1617,7 @@ Error log
|
||||
<datetime> <master-pid> <current-pid> <thread-id> <level> (<filename>:<line>) <msg>
|
||||
|
||||
<datetime>
|
||||
It is a conbination of date and time when the log is written. It
|
||||
It is a combination of date and time when the log is written. It
|
||||
is in ISO 8601 format.
|
||||
|
||||
<master-pid>
|
||||
@@ -1405,14 +1651,18 @@ SIGUSR1
|
||||
Reopen log files.
|
||||
|
||||
SIGUSR2
|
||||
|
||||
Fork and execute nghttpx. It will execute the binary in the same
|
||||
path with same command-line arguments and environment variables.
|
||||
After new process comes up, sending SIGQUIT to the original process
|
||||
to perform hot swapping. The difference between SIGUSR2 + SIGQUIT
|
||||
and SIGHUP is that former is usually used to execute new binary, and
|
||||
the master process is newly spawned. On the other hand, the latter
|
||||
just reloads configuration file, and the same master process
|
||||
continues to exist.
|
||||
path with same command-line arguments and environment variables. As
|
||||
of nghttpx version 1.20.0, the new master process sends SIGQUIT to
|
||||
the original master process when it is ready to serve requests. For
|
||||
the earlier versions of nghttpx, user has to send SIGQUIT to the
|
||||
original master process.
|
||||
|
||||
The difference between SIGUSR2 (+ SIGQUIT) and SIGHUP is that former
|
||||
is usually used to execute new binary, and the master process is
|
||||
newly spawned. On the other hand, the latter just reloads
|
||||
configuration file, and the same master process continues to exist.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -1489,6 +1739,22 @@ be customized using :option:`--fetch-ocsp-response-file` option.
|
||||
If OCSP query is failed, previous OCSP response, if any, is continued
|
||||
to be used.
|
||||
|
||||
:option:`--fetch-ocsp-response-file` option provides wide range of
|
||||
possibility to manage OCSP response. It can take an arbitrary script
|
||||
or executable. The requirement is that it supports the command-line
|
||||
interface of ``fetch-ocsp-response`` script, and it must return a
|
||||
valid DER encoded OCSP response on success. It must return exit code
|
||||
0 on success, and 75 for temporary error, and the other error code for
|
||||
generic failure. For large cluster of servers, it is not efficient
|
||||
for each server to perform OCSP query using ``fetch-ocsp-response``.
|
||||
Instead, you can retrieve OCSP response in some way, and store it in a
|
||||
disk or a shared database. Then specify a program in
|
||||
:option:`--fetch-ocsp-response-file` to fetch it from those stores.
|
||||
This could provide a way to share the OCSP response between fleet of
|
||||
servers, and also any OCSP query strategy can be applied which may be
|
||||
beyond the ability of nghttpx itself or ``fetch-ocsp-response``
|
||||
script.
|
||||
|
||||
TLS SESSION RESUMPTION
|
||||
----------------------
|
||||
|
||||
@@ -1502,7 +1768,7 @@ By default, session ID is shared by all worker threads.
|
||||
|
||||
If :option:`--tls-session-cache-memcached` is given, nghttpx will
|
||||
insert serialized session data to memcached with
|
||||
``nghttpx:tls-session-cache:`` + lowercased hex string of session ID
|
||||
``nghttpx:tls-session-cache:`` + lowercase hex string of session ID
|
||||
as a memcached entry key, with expiry time 12 hours. Session timeout
|
||||
is set to 12 hours.
|
||||
|
||||
@@ -1584,6 +1850,14 @@ MRUBY SCRIPTING
|
||||
The current mruby extension API is experimental and not frozen. The
|
||||
API is subject to change in the future release.
|
||||
|
||||
.. warning::
|
||||
|
||||
Almost all string value returned from method, or attribute is a
|
||||
fresh new mruby string, which involves memory allocation, and
|
||||
copies. Therefore, it is strongly recommended to store a return
|
||||
value in a local variable, and use it, instead of calling method or
|
||||
accessing attribute repeatedly.
|
||||
|
||||
nghttpx allows users to extend its capability using mruby scripts.
|
||||
nghttpx has 2 hook points to execute mruby script: request phase and
|
||||
response phase. The request phase hook is invoked after all request
|
||||
@@ -1593,9 +1867,28 @@ server. These hooks allows users to modify header fields, or common
|
||||
HTTP variables, like authority or request path, and even return custom
|
||||
response without forwarding request to backend servers.
|
||||
|
||||
To specify mruby script file, use :option:`--mruby-file` option. The
|
||||
script will be evaluated once per thread on startup, and it must
|
||||
instantiate object and evaluate it as the return value (e.g.,
|
||||
There are 2 levels of mruby script invocations: global and
|
||||
per-pattern. The global mruby script is set by :option:`--mruby-file`
|
||||
option and is called for all requests. The per-pattern mruby script
|
||||
is set by "mruby" parameter in :option:`-b` option. It is invoked for
|
||||
a request which matches the particular pattern. The order of hook
|
||||
invocation is: global request phase hook, per-pattern request phase
|
||||
hook, per-pattern response phase hook, and finally global response
|
||||
phase hook. If a hook returns a response, any later hooks are not
|
||||
invoked. The global request hook is invoked before the pattern
|
||||
matching is made and changing request path may affect the pattern
|
||||
matching.
|
||||
|
||||
Please note that request and response hooks of per-pattern mruby
|
||||
script for a single request might not come from the same script. This
|
||||
might happen after a request hook is executed, backend failed for some
|
||||
reason, and at the same time, backend configuration is replaced by API
|
||||
request, and then the request uses new configuration on retry. The
|
||||
response hook from new configuration, if it is specified, will be
|
||||
invoked.
|
||||
|
||||
The all mruby script will be evaluated once per thread on startup, and
|
||||
it must instantiate object and evaluate it as the return value (e.g.,
|
||||
``App.new``). This object is called app object. If app object
|
||||
defines ``on_req`` method, it is called with :rb:class:`Nghttpx::Env`
|
||||
object on request hook. Similarly, if app object defines ``on_resp``
|
||||
@@ -1630,7 +1923,7 @@ respectively.
|
||||
.. rb:attr_reader:: ctx
|
||||
|
||||
Return Ruby hash object. It persists until request finishes.
|
||||
So values set in request phase hoo can be retrieved in
|
||||
So values set in request phase hook can be retrieved in
|
||||
response phase hook.
|
||||
|
||||
.. rb:attr_reader:: phase
|
||||
@@ -1662,6 +1955,64 @@ respectively.
|
||||
|
||||
Return the TLS SNI value which client sent in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_client_fingerprint_sha256
|
||||
|
||||
Return the SHA-256 fingerprint of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_fingerprint_sha1
|
||||
|
||||
Return the SHA-1 fingerprint of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_issuer_name
|
||||
|
||||
Return the issuer name of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_subject_name
|
||||
|
||||
Return the subject name of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_serial
|
||||
|
||||
Return the serial number of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_not_before
|
||||
|
||||
Return the start date of a client certificate in seconds since
|
||||
the epoch.
|
||||
|
||||
.. rb:attr_reader:: tls_client_not_after
|
||||
|
||||
Return the end date of a client certificate in seconds since
|
||||
the epoch.
|
||||
|
||||
.. rb:attr_reader:: tls_cipher
|
||||
|
||||
Return a TLS cipher negotiated in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_protocol
|
||||
|
||||
Return a TLS protocol version negotiated in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_session_id
|
||||
|
||||
Return a session ID for this connection in hex string.
|
||||
|
||||
.. rb:attr_reader:: tls_session_reused
|
||||
|
||||
Return true if, and only if a SSL/TLS session is reused.
|
||||
|
||||
.. rb:attr_reader:: alpn
|
||||
|
||||
Return ALPN identifier negotiated in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_handshake_finished
|
||||
|
||||
Return true if SSL/TLS handshake has finished. If it returns
|
||||
false in the request phase hook, the request is received in
|
||||
TLSv1.3 early data (0-RTT) and might be vulnerable to the
|
||||
replay attack. nghttpx will send Early-Data header field to
|
||||
backend servers to indicate this.
|
||||
|
||||
.. rb:class:: Request
|
||||
|
||||
Object to represent request from client. The modification to
|
||||
@@ -1792,10 +2143,10 @@ respectively.
|
||||
not be invoked. When this method is called in response phase
|
||||
hook, response from backend server is canceled and discarded.
|
||||
The status code and response header fields should be set
|
||||
before using this method. To set status code, use :rb:meth To
|
||||
set response header fields, use
|
||||
before using this method. To set status code, use
|
||||
:rb:attr:`Nghttpx::Response#status`. If status code is not
|
||||
set, 200 is used. :rb:meth:`Nghttpx::Response#add_header` and
|
||||
set, 200 is used. To set response header fields,
|
||||
:rb:meth:`Nghttpx::Response#add_header` and
|
||||
:rb:meth:`Nghttpx::Response#set_header`. When this method is
|
||||
invoked in response phase hook, the response headers are
|
||||
filled with the ones received from backend server. To send
|
||||
@@ -1804,6 +2155,18 @@ respectively.
|
||||
existing header fields, and then add required header fields.
|
||||
It is an error to call this method twice for a given request.
|
||||
|
||||
.. rb:method:: send_info(status, headers)
|
||||
|
||||
Send non-final (informational) response to a client. *status*
|
||||
must be in the range [100, 199], inclusive. *headers* is a
|
||||
hash containing response header fields. Its key must be a
|
||||
string, and the associated value must be either string or
|
||||
array of strings. Since this is not a final response, even if
|
||||
this method is invoked, request is still forwarded to a
|
||||
backend unless :rb:meth:`Nghttpx::Response#return` is called.
|
||||
This method can be called multiple times. It cannot be called
|
||||
after :rb:meth:`Nghttpx::Response#return` is called.
|
||||
|
||||
MRUBY EXAMPLES
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
@@ -1865,17 +2228,20 @@ status
|
||||
code
|
||||
HTTP status code
|
||||
|
||||
Additionally, depending on the API endpoint, ``data`` key may be
|
||||
present, and its value contains the API endpoint specific data.
|
||||
|
||||
We wrote "normally", since nghttpx may return ordinal HTML response in
|
||||
some cases where the error has occurred before reaching API endpoint
|
||||
(e.g., header field is too large).
|
||||
|
||||
The following section describes available API endpoints.
|
||||
|
||||
PUT /api/v1beta1/backendconfig
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
POST /api/v1beta1/backendconfig
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This API replaces the current backend server settings with the
|
||||
requested ones. The request method should be PUT, but POST is also
|
||||
requested ones. The request method should be POST, but PUT is also
|
||||
acceptable. The request body must be nghttpx configuration file
|
||||
format. For configuration file format, see `FILES`_ section. The
|
||||
line separator inside the request body must be single LF (0x0A).
|
||||
@@ -1891,11 +2257,30 @@ The replacement is done instantly without breaking existing
|
||||
connections or requests. It also avoids any process creation as is
|
||||
the case with hot swapping with signals.
|
||||
|
||||
The one limitation is that only numeric IP address is allowd in
|
||||
The one limitation is that only numeric IP address is allowed in
|
||||
:option:`backend <--backend>` in request body unless "dns" parameter
|
||||
is used while non numeric hostname is allowed in command-line or
|
||||
configuration file is read using :option:`--conf`.
|
||||
|
||||
GET /api/v1beta1/configrevision
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This API returns configuration revision of the current nghttpx. The
|
||||
configuration revision is opaque string, and it changes after each
|
||||
reloading by SIGHUP. With this API, an external application knows
|
||||
that whether nghttpx has finished reloading its configuration by
|
||||
comparing the configuration revisions between before and after
|
||||
reloading. It is recommended to disable persistent (keep-alive)
|
||||
connection for this purpose in order to avoid to send a request using
|
||||
the reused connection which may bound to an old process.
|
||||
|
||||
This API returns response including ``data`` key. Its value is JSON
|
||||
object, and it contains at least the following key:
|
||||
|
||||
configRevision
|
||||
The configuration revision of the current nghttpx
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
|
||||
161
doc/nghttpx.h2r
161
doc/nghttpx.h2r
@@ -49,7 +49,7 @@ Error log
|
||||
<datetime> <master-pid> <current-pid> <thread-id> <level> (<filename>:<line>) <msg>
|
||||
|
||||
<datetime>
|
||||
It is a conbination of date and time when the log is written. It
|
||||
It is a combination of date and time when the log is written. It
|
||||
is in ISO 8601 format.
|
||||
|
||||
<master-pid>
|
||||
@@ -83,14 +83,18 @@ SIGUSR1
|
||||
Reopen log files.
|
||||
|
||||
SIGUSR2
|
||||
|
||||
Fork and execute nghttpx. It will execute the binary in the same
|
||||
path with same command-line arguments and environment variables.
|
||||
After new process comes up, sending SIGQUIT to the original process
|
||||
to perform hot swapping. The difference between SIGUSR2 + SIGQUIT
|
||||
and SIGHUP is that former is usually used to execute new binary, and
|
||||
the master process is newly spawned. On the other hand, the latter
|
||||
just reloads configuration file, and the same master process
|
||||
continues to exist.
|
||||
path with same command-line arguments and environment variables. As
|
||||
of nghttpx version 1.20.0, the new master process sends SIGQUIT to
|
||||
the original master process when it is ready to serve requests. For
|
||||
the earlier versions of nghttpx, user has to send SIGQUIT to the
|
||||
original master process.
|
||||
|
||||
The difference between SIGUSR2 (+ SIGQUIT) and SIGHUP is that former
|
||||
is usually used to execute new binary, and the master process is
|
||||
newly spawned. On the other hand, the latter just reloads
|
||||
configuration file, and the same master process continues to exist.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -167,6 +171,22 @@ be customized using :option:`--fetch-ocsp-response-file` option.
|
||||
If OCSP query is failed, previous OCSP response, if any, is continued
|
||||
to be used.
|
||||
|
||||
:option:`--fetch-ocsp-response-file` option provides wide range of
|
||||
possibility to manage OCSP response. It can take an arbitrary script
|
||||
or executable. The requirement is that it supports the command-line
|
||||
interface of ``fetch-ocsp-response`` script, and it must return a
|
||||
valid DER encoded OCSP response on success. It must return exit code
|
||||
0 on success, and 75 for temporary error, and the other error code for
|
||||
generic failure. For large cluster of servers, it is not efficient
|
||||
for each server to perform OCSP query using ``fetch-ocsp-response``.
|
||||
Instead, you can retrieve OCSP response in some way, and store it in a
|
||||
disk or a shared database. Then specify a program in
|
||||
:option:`--fetch-ocsp-response-file` to fetch it from those stores.
|
||||
This could provide a way to share the OCSP response between fleet of
|
||||
servers, and also any OCSP query strategy can be applied which may be
|
||||
beyond the ability of nghttpx itself or ``fetch-ocsp-response``
|
||||
script.
|
||||
|
||||
TLS SESSION RESUMPTION
|
||||
----------------------
|
||||
|
||||
@@ -180,7 +200,7 @@ By default, session ID is shared by all worker threads.
|
||||
|
||||
If :option:`--tls-session-cache-memcached` is given, nghttpx will
|
||||
insert serialized session data to memcached with
|
||||
``nghttpx:tls-session-cache:`` + lowercased hex string of session ID
|
||||
``nghttpx:tls-session-cache:`` + lowercase hex string of session ID
|
||||
as a memcached entry key, with expiry time 12 hours. Session timeout
|
||||
is set to 12 hours.
|
||||
|
||||
@@ -262,6 +282,14 @@ MRUBY SCRIPTING
|
||||
The current mruby extension API is experimental and not frozen. The
|
||||
API is subject to change in the future release.
|
||||
|
||||
.. warning::
|
||||
|
||||
Almost all string value returned from method, or attribute is a
|
||||
fresh new mruby string, which involves memory allocation, and
|
||||
copies. Therefore, it is strongly recommended to store a return
|
||||
value in a local variable, and use it, instead of calling method or
|
||||
accessing attribute repeatedly.
|
||||
|
||||
nghttpx allows users to extend its capability using mruby scripts.
|
||||
nghttpx has 2 hook points to execute mruby script: request phase and
|
||||
response phase. The request phase hook is invoked after all request
|
||||
@@ -271,9 +299,28 @@ server. These hooks allows users to modify header fields, or common
|
||||
HTTP variables, like authority or request path, and even return custom
|
||||
response without forwarding request to backend servers.
|
||||
|
||||
To specify mruby script file, use :option:`--mruby-file` option. The
|
||||
script will be evaluated once per thread on startup, and it must
|
||||
instantiate object and evaluate it as the return value (e.g.,
|
||||
There are 2 levels of mruby script invocations: global and
|
||||
per-pattern. The global mruby script is set by :option:`--mruby-file`
|
||||
option and is called for all requests. The per-pattern mruby script
|
||||
is set by "mruby" parameter in :option:`-b` option. It is invoked for
|
||||
a request which matches the particular pattern. The order of hook
|
||||
invocation is: global request phase hook, per-pattern request phase
|
||||
hook, per-pattern response phase hook, and finally global response
|
||||
phase hook. If a hook returns a response, any later hooks are not
|
||||
invoked. The global request hook is invoked before the pattern
|
||||
matching is made and changing request path may affect the pattern
|
||||
matching.
|
||||
|
||||
Please note that request and response hooks of per-pattern mruby
|
||||
script for a single request might not come from the same script. This
|
||||
might happen after a request hook is executed, backend failed for some
|
||||
reason, and at the same time, backend configuration is replaced by API
|
||||
request, and then the request uses new configuration on retry. The
|
||||
response hook from new configuration, if it is specified, will be
|
||||
invoked.
|
||||
|
||||
The all mruby script will be evaluated once per thread on startup, and
|
||||
it must instantiate object and evaluate it as the return value (e.g.,
|
||||
``App.new``). This object is called app object. If app object
|
||||
defines ``on_req`` method, it is called with :rb:class:`Nghttpx::Env`
|
||||
object on request hook. Similarly, if app object defines ``on_resp``
|
||||
@@ -308,7 +355,7 @@ respectively.
|
||||
.. rb:attr_reader:: ctx
|
||||
|
||||
Return Ruby hash object. It persists until request finishes.
|
||||
So values set in request phase hoo can be retrieved in
|
||||
So values set in request phase hook can be retrieved in
|
||||
response phase hook.
|
||||
|
||||
.. rb:attr_reader:: phase
|
||||
@@ -340,6 +387,64 @@ respectively.
|
||||
|
||||
Return the TLS SNI value which client sent in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_client_fingerprint_sha256
|
||||
|
||||
Return the SHA-256 fingerprint of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_fingerprint_sha1
|
||||
|
||||
Return the SHA-1 fingerprint of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_issuer_name
|
||||
|
||||
Return the issuer name of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_subject_name
|
||||
|
||||
Return the subject name of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_serial
|
||||
|
||||
Return the serial number of a client certificate.
|
||||
|
||||
.. rb:attr_reader:: tls_client_not_before
|
||||
|
||||
Return the start date of a client certificate in seconds since
|
||||
the epoch.
|
||||
|
||||
.. rb:attr_reader:: tls_client_not_after
|
||||
|
||||
Return the end date of a client certificate in seconds since
|
||||
the epoch.
|
||||
|
||||
.. rb:attr_reader:: tls_cipher
|
||||
|
||||
Return a TLS cipher negotiated in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_protocol
|
||||
|
||||
Return a TLS protocol version negotiated in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_session_id
|
||||
|
||||
Return a session ID for this connection in hex string.
|
||||
|
||||
.. rb:attr_reader:: tls_session_reused
|
||||
|
||||
Return true if, and only if a SSL/TLS session is reused.
|
||||
|
||||
.. rb:attr_reader:: alpn
|
||||
|
||||
Return ALPN identifier negotiated in this connection.
|
||||
|
||||
.. rb:attr_reader:: tls_handshake_finished
|
||||
|
||||
Return true if SSL/TLS handshake has finished. If it returns
|
||||
false in the request phase hook, the request is received in
|
||||
TLSv1.3 early data (0-RTT) and might be vulnerable to the
|
||||
replay attack. nghttpx will send Early-Data header field to
|
||||
backend servers to indicate this.
|
||||
|
||||
.. rb:class:: Request
|
||||
|
||||
Object to represent request from client. The modification to
|
||||
@@ -470,10 +575,10 @@ respectively.
|
||||
not be invoked. When this method is called in response phase
|
||||
hook, response from backend server is canceled and discarded.
|
||||
The status code and response header fields should be set
|
||||
before using this method. To set status code, use :rb:meth To
|
||||
set response header fields, use
|
||||
before using this method. To set status code, use
|
||||
:rb:attr:`Nghttpx::Response#status`. If status code is not
|
||||
set, 200 is used. :rb:meth:`Nghttpx::Response#add_header` and
|
||||
set, 200 is used. To set response header fields,
|
||||
:rb:meth:`Nghttpx::Response#add_header` and
|
||||
:rb:meth:`Nghttpx::Response#set_header`. When this method is
|
||||
invoked in response phase hook, the response headers are
|
||||
filled with the ones received from backend server. To send
|
||||
@@ -555,6 +660,9 @@ status
|
||||
code
|
||||
HTTP status code
|
||||
|
||||
Additionally, depending on the API endpoint, ``data`` key may be
|
||||
present, and its value contains the API endpoint specific data.
|
||||
|
||||
We wrote "normally", since nghttpx may return ordinal HTML response in
|
||||
some cases where the error has occurred before reaching API endpoint
|
||||
(e.g., header field is too large).
|
||||
@@ -581,11 +689,30 @@ The replacement is done instantly without breaking existing
|
||||
connections or requests. It also avoids any process creation as is
|
||||
the case with hot swapping with signals.
|
||||
|
||||
The one limitation is that only numeric IP address is allowd in
|
||||
The one limitation is that only numeric IP address is allowed in
|
||||
:option:`backend <--backend>` in request body unless "dns" parameter
|
||||
is used while non numeric hostname is allowed in command-line or
|
||||
configuration file is read using :option:`--conf`.
|
||||
|
||||
GET /api/v1beta1/configrevision
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This API returns configuration revision of the current nghttpx. The
|
||||
configuration revision is opaque string, and it changes after each
|
||||
reloading by SIGHUP. With this API, an external application knows
|
||||
that whether nghttpx has finished reloading its configuration by
|
||||
comparing the configuration revisions between before and after
|
||||
reloading. It is recommended to disable persistent (keep-alive)
|
||||
connection for this purpose in order to avoid to send a request using
|
||||
the reused connection which may bound to an old process.
|
||||
|
||||
This API returns response including ``data`` key. Its value is JSON
|
||||
object, and it contains at least the following key:
|
||||
|
||||
configRevision
|
||||
The configuration revision of the current nghttpx
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
|
||||
|
||||
@@ -110,13 +110,16 @@ HTTP Messaging
|
||||
|
||||
By default, nghttp2 library checks HTTP messaging rules described in
|
||||
`HTTP/2 specification, section 8
|
||||
<https://tools.ietf.org/html/draft-ietf-httpbis-http2-17#section-8>`_.
|
||||
Everything described in that section is not validated however. We
|
||||
briefly describe what the library does in this area. In the following
|
||||
<https://tools.ietf.org/html/rfc7540#section-8>`_. Everything
|
||||
described in that section is not validated however. We briefly
|
||||
describe what the library does in this area. In the following
|
||||
description, without loss of generality we omit CONTINUATION frame
|
||||
since they must follow HEADERS frame and are processed atomically. In
|
||||
other words, they are just one big HEADERS frame. To disable these
|
||||
validations, use `nghttp2_option_set_no_http_messaging()`.
|
||||
validations, use `nghttp2_option_set_no_http_messaging()`. Please
|
||||
note that disabling this feature does not change the fundamental
|
||||
client and server model of HTTP. That is, even if the validation is
|
||||
disabled, only client can send requests.
|
||||
|
||||
For HTTP request, including those carried by PUSH_PROMISE, HTTP
|
||||
message starts with one HEADERS frame containing request headers. It
|
||||
@@ -149,13 +152,11 @@ header fields must not appear: "Connection", "Keep-Alive",
|
||||
Each header field name and value must obey the field-name and
|
||||
field-value production rules described in `RFC 7230, section
|
||||
3.2. <https://tools.ietf.org/html/rfc7230#section-3.2>`_.
|
||||
Additionally, all field name must be lower cased. While the pseudo
|
||||
header fields must satisfy these rules, we just ignore illegal regular
|
||||
headers (this means that these header fields are not passed to
|
||||
application callback). This is because these illegal header fields
|
||||
are floating around in existing internet and resetting stream just
|
||||
because of this may break many web sites. This is especially true if
|
||||
we forward to or translate from HTTP/1 traffic.
|
||||
Additionally, all field name must be lower cased. The invalid header
|
||||
fields are treated as stream error, and that stream is reset. If
|
||||
application wants to treat these headers in their own way, use
|
||||
`nghttp2_on_invalid_header_callback
|
||||
<https://nghttp2.org/documentation/types.html#c.nghttp2_on_invalid_header_callback>`_.
|
||||
|
||||
For "http" or "https" URIs, ":path" pseudo header fields must start
|
||||
with "/". The only exception is OPTIONS request, in that case, "*" is
|
||||
@@ -248,7 +249,7 @@ set to :type:`nghttp2_session_callbacks` using
|
||||
`nghttp2_session_callbacks_set_pack_extension_callback()`.
|
||||
|
||||
For example, we will illustrate how to send `ALTSVC
|
||||
<https://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-14>`_ frame.
|
||||
<https://tools.ietf.org/html/rfc7838>`_ frame.
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ Building Android binary
|
||||
=======================
|
||||
|
||||
In this article, we briefly describe how to build Android binary using
|
||||
`Android NDK <http://developer.android.com/tools/sdk/ndk/index.html>`_
|
||||
`Android NDK <https://developer.android.com/ndk/index.html>`_
|
||||
cross-compiler on Debian Linux.
|
||||
|
||||
The easiest way to build android binary is use Dockerfile.android.
|
||||
@@ -38,9 +38,6 @@ Although zlib comes with Android NDK, it seems not to be a part of
|
||||
public API, so we have to built it for our own. That also provides us
|
||||
proper .pc file as a bonus.
|
||||
|
||||
If SPDY support is required for nghttpx and h2load, build and install
|
||||
spdylay as well.
|
||||
|
||||
Before running ``android-config`` and ``android-make``,
|
||||
``ANDROID_HOME`` environment variable must be set to point to the
|
||||
correct path. Also add ``$ANDROID_HOME/toolchain/bin`` to ``PATH``:
|
||||
@@ -146,34 +143,6 @@ To configure zlib, use the following script:
|
||||
|
||||
And run ``make install`` to build and install.
|
||||
|
||||
To configure spdylay, use the following script:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
#!/bin/sh -e
|
||||
|
||||
if [ -z "$ANDROID_HOME" ]; then
|
||||
echo 'No $ANDROID_HOME specified.'
|
||||
exit 1
|
||||
fi
|
||||
PREFIX=$ANDROID_HOME/usr/local
|
||||
TOOLCHAIN=$ANDROID_HOME/toolchain
|
||||
PATH=$TOOLCHAIN/bin:$PATH
|
||||
|
||||
./configure \
|
||||
--disable-shared \
|
||||
--host=arm-linux-androideabi \
|
||||
--build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
|
||||
--prefix=$PREFIX \
|
||||
--without-libxml2 \
|
||||
--disable-src \
|
||||
--disable-examples \
|
||||
CPPFLAGS="-I$PREFIX/include" \
|
||||
PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
|
||||
LDFLAGS="-L$PREFIX/lib"
|
||||
|
||||
And run ``make install`` to build and install.
|
||||
|
||||
After prerequisite libraries are prepared, run ``android-config`` and
|
||||
then ``android-make`` to compile nghttp2 source files.
|
||||
|
||||
|
||||
@@ -26,17 +26,16 @@ Coding style
|
||||
We use clang-format to format source code consistently. The
|
||||
clang-format configuration file .clang-format is located at the root
|
||||
directory. Since clang-format produces slightly different results
|
||||
between versions, we currently use clang-format which comes with
|
||||
clang-3.9.
|
||||
between versions, we currently use clang-format-7.
|
||||
|
||||
To detect any violation to the coding style, we recommend to setup git
|
||||
pre-commit hook to check coding style of the changes you introduced.
|
||||
The pre-commit file is located at the root directory. Copy it under
|
||||
.git/hooks and make sure that it is executable. The pre-commit script
|
||||
uses clang-format-diff.py to detect any style errors. If it is not in
|
||||
your PATH or it exists under different name (e.g.,
|
||||
clang-format-diff-3.9 in debian), either add it to PATH variable or
|
||||
add git option ``clangformatdiff.binary`` to point to the script.
|
||||
your PATH or it exists under different name (e.g., clang-format-diff-7
|
||||
in debian), either add it to PATH variable or add git option
|
||||
``clangformatdiff.binary`` to point to the script.
|
||||
|
||||
For emacs users, integrating clang-format to emacs is very easy.
|
||||
clang-format.el should come with clang distribution. If it is not
|
||||
|
||||
@@ -3,16 +3,14 @@
|
||||
h2load - HTTP/2 benchmarking tool - HOW-TO
|
||||
==========================================
|
||||
|
||||
:doc:`h2load.1` is benchmarking tool for HTTP/2 and HTTP/1.1. If
|
||||
built with spdylay (http://tatsuhiro-t.github.io/spdylay/) library, it
|
||||
also supports SPDY protocol. It supports SSL/TLS and clear text for
|
||||
all supported protocols.
|
||||
:doc:`h2load.1` is benchmarking tool for HTTP/2 and HTTP/1.1. It
|
||||
supports SSL/TLS and clear text for all supported protocols.
|
||||
|
||||
Compiling from source
|
||||
---------------------
|
||||
|
||||
h2load is compiled alongside nghttp2 and requires that the
|
||||
``--enable-apps`` flag is passed to ``./configure`` and `required
|
||||
``--enable-app`` flag is passed to ``./configure`` and `required
|
||||
dependencies <https://github.com/nghttp2/nghttp2#requirements>`_ are
|
||||
available during compilation. For details on compiling, see `nghttp2:
|
||||
Building from Git
|
||||
@@ -64,23 +62,40 @@ The benchmarking result looks like this:
|
||||
See the h2load manual page :ref:`h2load-1-output` section for the
|
||||
explanation of the above numbers.
|
||||
|
||||
Timing-based load-testing
|
||||
-------------------------
|
||||
|
||||
As of v1.26.0, h2load supports timing-based load-testing. This method
|
||||
performs load-testing in terms of a given duration instead of a
|
||||
pre-defined number of requests. The new option :option:`--duration`
|
||||
specifies how long the load-testing takes. For example,
|
||||
``--duration=10`` makes h2load perform load-testing against a server
|
||||
for 10 seconds. You can also specify a “warming-up” period with
|
||||
:option:`--warm-up-time`. If :option:`--duration` is used,
|
||||
:option:`-n` option is ignored.
|
||||
|
||||
The following command performs load-testing for 10 seconds after 5
|
||||
seconds warming up period:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ h2load -c100 -m100 --duration=10 --warm-up-time=5 https://localhost
|
||||
|
||||
Flow Control
|
||||
------------
|
||||
|
||||
HTTP/2 and SPDY/3 or later employ flow control and it may affect
|
||||
benchmarking results. By default, h2load uses large enough flow
|
||||
control window, which effectively disables flow control. To adjust
|
||||
receiver flow control window size, there are following options:
|
||||
HTTP/2 has flow control and it may affect benchmarking results. By
|
||||
default, h2load uses large enough flow control window, which
|
||||
effectively disables flow control. To adjust receiver flow control
|
||||
window size, there are following options:
|
||||
|
||||
:option:`-w`
|
||||
Sets the stream level initial window size to
|
||||
(2**<N>)-1. For SPDY, 2**<N> is used instead.
|
||||
(2**<N>)-1.
|
||||
|
||||
:option:`-W`
|
||||
Sets the connection level initial window size to
|
||||
(2**<N>)-1. For SPDY, if <N> is strictly less
|
||||
than 16, this option is ignored. Otherwise
|
||||
2**<N> is used for SPDY.
|
||||
(2**<N>)-1.
|
||||
|
||||
Multi-Threading
|
||||
---------------
|
||||
|
||||
@@ -290,7 +290,7 @@ Normally, client does not stop even after all requests are done unless
|
||||
connection is lost. To stop client, call
|
||||
``nghttp2::asio_http2::server::session::shutdown()``.
|
||||
|
||||
Recieve server push and enable SSL/TLS
|
||||
Receive server push and enable SSL/TLS
|
||||
++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@@ -4,10 +4,10 @@ nghttpx - HTTP/2 proxy - HOW-TO
|
||||
===============================
|
||||
|
||||
:doc:`nghttpx.1` is a proxy translating protocols between HTTP/2 and
|
||||
other protocols (e.g., HTTP/1, SPDY). It operates in several modes
|
||||
and each mode may require additional programs to work with. This
|
||||
article describes each operation mode and explains the intended
|
||||
use-cases. It also covers some useful options later.
|
||||
other protocols (e.g., HTTP/1). It operates in several modes and each
|
||||
mode may require additional programs to work with. This article
|
||||
describes each operation mode and explains the intended use-cases. It
|
||||
also covers some useful options later.
|
||||
|
||||
Default mode
|
||||
------------
|
||||
@@ -15,9 +15,7 @@ Default mode
|
||||
If nghttpx is invoked without :option:`--http2-proxy`, it operates in
|
||||
default mode. In this mode, it works as reverse proxy (gateway) for
|
||||
both HTTP/2 and HTTP/1 clients to backend servers. This is also known
|
||||
as "HTTP/2 router". If nghttpx is linked with spdylay library and
|
||||
frontend connection is SSL/TLS, the frontend also supports SPDY
|
||||
protocol.
|
||||
as "HTTP/2 router".
|
||||
|
||||
By default, frontend connection is encrypted using SSL/TLS. So
|
||||
server's private key and certificate must be supplied to the command
|
||||
@@ -25,11 +23,10 @@ line (or through configuration file). In this case, the frontend
|
||||
protocol selection will be done via ALPN or NPN.
|
||||
|
||||
To turn off encryption on frontend connection, use ``no-tls`` keyword
|
||||
in :option:`--frontend` option. In this case, SPDY protocol is not
|
||||
available even if spdylay library is liked to nghttpx. HTTP/2 and
|
||||
HTTP/1 are available on the frontend, and an HTTP/1 connection can be
|
||||
upgraded to HTTP/2 using HTTP Upgrade. Starting HTTP/2 connection by
|
||||
sending HTTP/2 connection preface is also supported.
|
||||
in :option:`--frontend` option. HTTP/2 and HTTP/1 are available on
|
||||
the frontend, and an HTTP/1 connection can be upgraded to HTTP/2 using
|
||||
HTTP Upgrade. Starting HTTP/2 connection by sending HTTP/2 connection
|
||||
preface is also supported.
|
||||
|
||||
nghttpx can listen on multiple frontend addresses. This is achieved
|
||||
by using multiple :option:`--frontend` options. For each frontend
|
||||
@@ -45,17 +42,17 @@ that default backend protocol is HTTP/1.1. To use HTTP/2 in backend,
|
||||
you have to specify ``h2`` in ``proto`` keyword in :option:`--backend`
|
||||
explicitly.
|
||||
|
||||
The backend is supposed to be Web server. For example, to make
|
||||
The backend is supposed to be a Web server. For example, to make
|
||||
nghttpx listen to encrypted HTTP/2 requests at port 8443, and a
|
||||
backend Web server is configured to listen to HTTP request at port
|
||||
8080 in the same host, run nghttpx command-line like this:
|
||||
backend Web server is configured to listen to HTTP requests at port
|
||||
8080 on the same host, run nghttpx command-line like this:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
$ nghttpx -f0.0.0.0,8443 -b127.0.0.1,8080 /path/to/server.key /path/to/server.crt
|
||||
|
||||
Then HTTP/2 enabled client can access to the nghttpx in HTTP/2. For
|
||||
example, you can send GET request to the server using nghttp:
|
||||
Then an HTTP/2 enabled client can access the nghttpx server using HTTP/2. For
|
||||
example, you can send a GET request using nghttp:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
@@ -66,19 +63,18 @@ HTTP/2 proxy mode
|
||||
|
||||
If nghttpx is invoked with :option:`--http2-proxy` (or its shorthand
|
||||
:option:`-s`) option, it operates in HTTP/2 proxy mode. The supported
|
||||
protocols in frontend and backend connections are the same in `default
|
||||
mode`_. The difference is that this mode acts like forward proxy and
|
||||
assumes the backend is HTTP proxy server (e.g., Squid, Apache Traffic
|
||||
Server). HTTP/1 request must include absolute URI in request line.
|
||||
protocols in frontend and backend connections are the same as in `default
|
||||
mode`_. The difference is that this mode acts like a forward proxy and
|
||||
assumes the backend is an HTTP proxy server (e.g., Squid, Apache Traffic
|
||||
Server). HTTP/1 requests must include an absolute URI in request line.
|
||||
|
||||
By default, frontend connection is encrypted. So this mode is also
|
||||
called secure proxy. If nghttpx is linked with spdylay, it supports
|
||||
SPDY protocols and it works as so called SPDY proxy.
|
||||
By default, the frontend connection is encrypted. So this mode is
|
||||
also called secure proxy.
|
||||
|
||||
To turn off encryption on frontend connection, use ``no-tls`` keyword
|
||||
To turn off encryption on the frontend connection, use ``no-tls`` keyword
|
||||
in :option:`--frontend` option.
|
||||
|
||||
The backend must be HTTP proxy server. nghttpx supports multiple
|
||||
The backend must be an HTTP proxy server. nghttpx supports multiple
|
||||
backend server addresses. It translates incoming requests to HTTP
|
||||
request to backend server. The backend server performs real proxy
|
||||
work for each request, for example, dispatching requests to the origin
|
||||
@@ -92,7 +88,7 @@ connection, use :option:`--backend` option, and specify ``h2`` in
|
||||
|
||||
For example, to make nghttpx listen to encrypted HTTP/2 requests at
|
||||
port 8443, and a backend HTTP proxy server is configured to listen to
|
||||
HTTP/1 request at port 8080 in the same host, run nghttpx command-line
|
||||
HTTP/1 requests at port 8080 on the same host, run nghttpx command-line
|
||||
like this:
|
||||
|
||||
.. code-block:: text
|
||||
@@ -102,8 +98,8 @@ like this:
|
||||
At the time of this writing, Firefox 41 and Chromium v46 can use
|
||||
nghttpx as HTTP/2 proxy.
|
||||
|
||||
To make Firefox or Chromium use nghttpx as HTTP/2 or SPDY proxy, user
|
||||
has to create proxy.pac script file like this:
|
||||
To make Firefox or Chromium use nghttpx as HTTP/2 proxy, user has to
|
||||
create proxy.pac script file like this:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
@@ -229,12 +225,18 @@ Hot swapping
|
||||
nghttpx supports hot swapping using signals. The hot swapping in
|
||||
nghttpx is multi step process. First send USR2 signal to nghttpx
|
||||
process. It will do fork and execute new executable, using same
|
||||
command-line arguments and environment variables. At this point, both
|
||||
current and new processes can accept requests. To gracefully shutdown
|
||||
current process, send QUIT signal to current nghttpx process. When
|
||||
all existing frontend connections are done, the current process will
|
||||
exit. At this point, only new nghttpx process exists and serves
|
||||
incoming requests.
|
||||
command-line arguments and environment variables.
|
||||
|
||||
As of nghttpx version 1.20.0, that is all you have to do. The new
|
||||
master process sends QUIT signal to the original process, when it is
|
||||
ready to serve requests, to shut it down gracefully.
|
||||
|
||||
For earlier versions of nghttpx, you have to do one more thing. At
|
||||
this point, both current and new processes can accept requests. To
|
||||
gracefully shutdown current process, send QUIT signal to current
|
||||
nghttpx process. When all existing frontend connections are done, the
|
||||
current process will exit. At this point, only new nghttpx process
|
||||
exists and serves incoming requests.
|
||||
|
||||
If you want to just reload configuration file without executing new
|
||||
binary, send SIGHUP to nghttpx master process.
|
||||
@@ -291,13 +293,31 @@ When you write this option in command-line, you should enclose
|
||||
argument with single or double quotes, since the character ``;`` has a
|
||||
special meaning in shell.
|
||||
|
||||
To route, request to request path whose prefix is ``/foo`` to backend
|
||||
server ``[::1]:8080``, you can write like so:
|
||||
To route, request to request path ``/foo`` to backend server
|
||||
``[::1]:8080``, you can write like so:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
backend=::1,8080;/foo
|
||||
|
||||
If the last character of path pattern is ``/``, all request paths
|
||||
which start with that pattern match:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
backend=::1,8080;/bar/
|
||||
|
||||
The request path ``/bar/buzz`` matches the ``/bar/``.
|
||||
|
||||
You can use ``*`` at the end of the path pattern to make it wildcard
|
||||
pattern. ``*`` must match at least one character:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
backend=::1,8080;/sample*
|
||||
|
||||
The request path ``/sample1/foo`` matches the ``/sample*`` pattern.
|
||||
|
||||
Of course, you can specify both host and request path at the same
|
||||
time:
|
||||
|
||||
@@ -365,7 +385,7 @@ parameter in :option:`--backend` option, like so:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
backend=foo.example.com;;dns
|
||||
backend=foo.example.com,80;;dns
|
||||
|
||||
nghttpx will cache resolved addresses for certain period of time. To
|
||||
change this cache period, use :option:`--dns-cache-timeout`.
|
||||
@@ -381,6 +401,28 @@ like so:
|
||||
|
||||
frontend=*,443;proxyproto
|
||||
|
||||
Session affinity
|
||||
----------------
|
||||
|
||||
Two kinds of session affinity are available: client IP, and HTTP
|
||||
Cookie.
|
||||
|
||||
To enable client IP based affinity, specify ``affinity=ip`` parameter
|
||||
in :option:`--backend` option. If PROXY protocol is enabled, then an
|
||||
address obtained from PROXY protocol is taken into consideration.
|
||||
|
||||
To enable HTTP Cookie based affinity, specify ``affinity=cookie``
|
||||
parameter, and specify a name of cookie in ``affinity-cookie-name``
|
||||
parameter. Optionally, a Path attribute can be specified in
|
||||
``affinity-cookie-path`` parameter:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
backend=127.0.0.1,3000;;affinity=cookie;affinity-cookie-name=nghttpxlb;affinity-cookie-path=/
|
||||
|
||||
Secure attribute of cookie is set if client connection is protected by
|
||||
TLS.
|
||||
|
||||
PSK cipher suites
|
||||
-----------------
|
||||
|
||||
@@ -429,6 +471,33 @@ such PSK cipher suite with HTTP/2, disable HTTP/2 cipher black list by
|
||||
using :option:`--client-no-http2-cipher-black-list` option. But you
|
||||
should understand its implications.
|
||||
|
||||
TLSv1.3
|
||||
-------
|
||||
|
||||
As of nghttpx v1.34.0, if it is built with OpenSSL 1.1.1 or later, it
|
||||
supports TLSv1.3. 0-RTT data is supported, but by default its
|
||||
processing is postponed until TLS handshake completes to mitigate
|
||||
replay attack. This costs extra round trip and reduces effectiveness
|
||||
of 0-RTT data. :option:`--tls-no-postpone-early-data` makes nghttpx
|
||||
not wait for handshake to complete before forwarding request included
|
||||
in 0-RTT to get full potential of 0-RTT data. In this case, nghttpx
|
||||
adds ``Early-Data: 1`` header field when forwarding a request to a
|
||||
backend server. All backend servers should recognize this header
|
||||
field and understand that there is a risk for replay attack. See `RFC
|
||||
8470 <https://tools.ietf.org/html/rfc8470>`_ for ``Early-Data`` header
|
||||
field.
|
||||
|
||||
nghttpx disables anti replay protection provided by OpenSSL. The anti
|
||||
replay protection of OpenSSL requires that a resumed request must hit
|
||||
the same server which generates the session ticket. Therefore it
|
||||
might not work nicely in a deployment where there are multiple nghttpx
|
||||
instances sharing ticket encryption keys via memcached.
|
||||
|
||||
Because TLSv1.3 completely changes the semantics of cipher suite
|
||||
naming scheme and structure, nghttpx provides the new option
|
||||
:option:`--tls13-ciphers` and :option:`--tls13-client-ciphers` to
|
||||
change preferred cipher list for TLSv1.3.
|
||||
|
||||
Migration from nghttpx v1.18.x or earlier
|
||||
-----------------------------------------
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ remote server. It's defined as::
|
||||
bev = bufferevent_openssl_socket_new(
|
||||
evbase, -1, ssl, BUFFEREVENT_SSL_CONNECTING,
|
||||
BEV_OPT_DEFER_CALLBACKS | BEV_OPT_CLOSE_ON_FREE);
|
||||
bufferevent_enable(bev, EV_READ | EV_WRITE);
|
||||
bufferevent_setcb(bev, readcb, writecb, eventcb, session_data);
|
||||
rv = bufferevent_socket_connect_hostname(bev, session_data->dnsbase,
|
||||
AF_UNSPEC, host, port);
|
||||
|
||||
@@ -7,11 +7,8 @@ if(ENABLE_EXAMPLES)
|
||||
COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/lib/includes
|
||||
${CMAKE_BINARY_DIR}/lib/includes
|
||||
${CMAKE_SOURCE_DIR}/src/includes
|
||||
${CMAKE_SOURCE_DIR}/third-party
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../third-party"
|
||||
|
||||
${LIBEVENT_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIRS}
|
||||
|
||||
@@ -62,11 +62,11 @@ ASIOCPPFLAGS = ${AM_CPPFLAGS} ${BOOST_CPPFLAGS}
|
||||
ASIOLDADD = $(top_builddir)/lib/libnghttp2.la \
|
||||
$(top_builddir)/src/libnghttp2_asio.la @JEMALLOC_LIBS@ \
|
||||
$(top_builddir)/third-party/libhttp-parser.la \
|
||||
@OPENSSL_LIBS@ \
|
||||
${BOOST_LDFLAGS} \
|
||||
${BOOST_ASIO_LIB} \
|
||||
${BOOST_THREAD_LIB} \
|
||||
${BOOST_SYSTEM_LIB} \
|
||||
@OPENSSL_LIBS@ \
|
||||
@APPLDFLAGS@
|
||||
|
||||
asio_sv_SOURCES = asio-sv.cc
|
||||
|
||||
@@ -67,14 +67,14 @@ int main(int argc, char *argv[]) {
|
||||
return;
|
||||
}
|
||||
|
||||
req->on_response([&sess](const response &res) {
|
||||
req->on_response([](const response &res) {
|
||||
std::cerr << "HTTP/2 " << res.status_code() << std::endl;
|
||||
for (auto &kv : res.header()) {
|
||||
std::cerr << kv.first << ": " << kv.second.value << "\n";
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
|
||||
res.on_data([&sess](const uint8_t *data, std::size_t len) {
|
||||
res.on_data([](const uint8_t *data, std::size_t len) {
|
||||
std::cerr.write(reinterpret_cast<const char *>(data), len);
|
||||
std::cerr << std::endl;
|
||||
});
|
||||
|
||||
@@ -91,17 +91,17 @@ int main(int argc, char *argv[]) {
|
||||
return;
|
||||
}
|
||||
|
||||
req->on_response([&sess, req](const response &res) {
|
||||
req->on_response([](const response &res) {
|
||||
std::cerr << "response header was received" << std::endl;
|
||||
print_header(res);
|
||||
|
||||
res.on_data([&sess](const uint8_t *data, std::size_t len) {
|
||||
res.on_data([](const uint8_t *data, std::size_t len) {
|
||||
std::cerr.write(reinterpret_cast<const char *>(data), len);
|
||||
std::cerr << std::endl;
|
||||
});
|
||||
});
|
||||
|
||||
req->on_close([&sess](uint32_t error_code) {
|
||||
req->on_close([](uint32_t error_code) {
|
||||
std::cerr << "request done with error_code=" << error_code << std::endl;
|
||||
});
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif // HAVE_UNISTD_H
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
# include <fcntl.h>
|
||||
#endif // HAVE_FCNTL_H
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
@@ -27,26 +27,26 @@
|
||||
* intentionally made simple.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
# include <fcntl.h>
|
||||
#endif /* HAVE_FCNTL_H */
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
# include <sys/socket.h>
|
||||
#endif /* HAVE_SYS_SOCKET_H */
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
# include <netdb.h>
|
||||
#endif /* HAVE_NETDB_H */
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
# include <netinet/in.h>
|
||||
#endif /* HAVE_NETINET_IN_H */
|
||||
#include <netinet/tcp.h>
|
||||
#include <poll.h>
|
||||
@@ -159,10 +159,13 @@ static void diec(const char *func, int error_code) {
|
||||
* bytes actually written. See the documentation of
|
||||
* nghttp2_send_callback for the details.
|
||||
*/
|
||||
static ssize_t send_callback(nghttp2_session *session _U_, const uint8_t *data,
|
||||
size_t length, int flags _U_, void *user_data) {
|
||||
static ssize_t send_callback(nghttp2_session *session, const uint8_t *data,
|
||||
size_t length, int flags, void *user_data) {
|
||||
struct Connection *connection;
|
||||
int rv;
|
||||
(void)session;
|
||||
(void)flags;
|
||||
|
||||
connection = (struct Connection *)user_data;
|
||||
connection->want_io = IO_NONE;
|
||||
ERR_clear_error();
|
||||
@@ -186,10 +189,13 @@ static ssize_t send_callback(nghttp2_session *session _U_, const uint8_t *data,
|
||||
* |length| bytes. Returns the number of bytes stored in |buf|. See
|
||||
* the documentation of nghttp2_recv_callback for the details.
|
||||
*/
|
||||
static ssize_t recv_callback(nghttp2_session *session _U_, uint8_t *buf,
|
||||
size_t length, int flags _U_, void *user_data) {
|
||||
static ssize_t recv_callback(nghttp2_session *session, uint8_t *buf,
|
||||
size_t length, int flags, void *user_data) {
|
||||
struct Connection *connection;
|
||||
int rv;
|
||||
(void)session;
|
||||
(void)flags;
|
||||
|
||||
connection = (struct Connection *)user_data;
|
||||
connection->want_io = IO_NONE;
|
||||
ERR_clear_error();
|
||||
@@ -210,9 +216,10 @@ static ssize_t recv_callback(nghttp2_session *session _U_, uint8_t *buf,
|
||||
}
|
||||
|
||||
static int on_frame_send_callback(nghttp2_session *session,
|
||||
const nghttp2_frame *frame,
|
||||
void *user_data _U_) {
|
||||
const nghttp2_frame *frame, void *user_data) {
|
||||
size_t i;
|
||||
(void)user_data;
|
||||
|
||||
switch (frame->hd.type) {
|
||||
case NGHTTP2_HEADERS:
|
||||
if (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)) {
|
||||
@@ -237,9 +244,10 @@ static int on_frame_send_callback(nghttp2_session *session,
|
||||
}
|
||||
|
||||
static int on_frame_recv_callback(nghttp2_session *session,
|
||||
const nghttp2_frame *frame,
|
||||
void *user_data _U_) {
|
||||
const nghttp2_frame *frame, void *user_data) {
|
||||
size_t i;
|
||||
(void)user_data;
|
||||
|
||||
switch (frame->hd.type) {
|
||||
case NGHTTP2_HEADERS:
|
||||
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE) {
|
||||
@@ -274,9 +282,11 @@ static int on_frame_recv_callback(nghttp2_session *session,
|
||||
* we submit GOAWAY and close the session.
|
||||
*/
|
||||
static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
|
||||
uint32_t error_code _U_,
|
||||
void *user_data _U_) {
|
||||
uint32_t error_code, void *user_data) {
|
||||
struct Request *req;
|
||||
(void)error_code;
|
||||
(void)user_data;
|
||||
|
||||
req = nghttp2_session_get_stream_user_data(session, stream_id);
|
||||
if (req) {
|
||||
int rv;
|
||||
@@ -293,11 +303,13 @@ static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
|
||||
* The implementation of nghttp2_on_data_chunk_recv_callback type. We
|
||||
* use this function to print the received response body.
|
||||
*/
|
||||
static int on_data_chunk_recv_callback(nghttp2_session *session,
|
||||
uint8_t flags _U_, int32_t stream_id,
|
||||
const uint8_t *data, size_t len,
|
||||
void *user_data _U_) {
|
||||
static int on_data_chunk_recv_callback(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id, const uint8_t *data,
|
||||
size_t len, void *user_data) {
|
||||
struct Request *req;
|
||||
(void)flags;
|
||||
(void)user_data;
|
||||
|
||||
req = nghttp2_session_get_stream_user_data(session, stream_id);
|
||||
if (req) {
|
||||
printf("[INFO] C <---------------------------- S (DATA chunk)\n"
|
||||
@@ -333,15 +345,19 @@ static void setup_nghttp2_callbacks(nghttp2_session_callbacks *callbacks) {
|
||||
callbacks, on_data_chunk_recv_callback);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
/*
|
||||
* Callback function for TLS NPN. Since this program only supports
|
||||
* HTTP/2 protocol, if server does not offer HTTP/2 the nghttp2
|
||||
* library supports, we terminate program.
|
||||
*/
|
||||
static int select_next_proto_cb(SSL *ssl _U_, unsigned char **out,
|
||||
static int select_next_proto_cb(SSL *ssl, unsigned char **out,
|
||||
unsigned char *outlen, const unsigned char *in,
|
||||
unsigned int inlen, void *arg _U_) {
|
||||
unsigned int inlen, void *arg) {
|
||||
int rv;
|
||||
(void)ssl;
|
||||
(void)arg;
|
||||
|
||||
/* nghttp2_select_next_protocol() selects HTTP/2 protocol the
|
||||
nghttp2 library supports. */
|
||||
rv = nghttp2_select_next_protocol(out, outlen, in, inlen);
|
||||
@@ -350,6 +366,7 @@ static int select_next_proto_cb(SSL *ssl _U_, unsigned char **out,
|
||||
}
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
|
||||
/*
|
||||
* Setup SSL/TLS context.
|
||||
@@ -360,7 +377,9 @@ static void init_ssl_ctx(SSL_CTX *ssl_ctx) {
|
||||
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_AUTO_RETRY);
|
||||
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
|
||||
/* Set NPN callback */
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
SSL_CTX_set_next_proto_select_cb(ssl_ctx, select_next_proto_cb, NULL);
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
}
|
||||
|
||||
static void ssl_handshake(SSL *ssl, int fd) {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* !HAVE_CONFIG_H */
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -44,7 +44,7 @@ static void deflate(nghttp2_hd_deflater *deflater,
|
||||
static int inflate_header_block(nghttp2_hd_inflater *inflater, uint8_t *in,
|
||||
size_t inlen, int final);
|
||||
|
||||
int main(int argc _U_, char **argv _U_) {
|
||||
int main() {
|
||||
int rv;
|
||||
nghttp2_hd_deflater *deflater;
|
||||
nghttp2_hd_inflater *inflater;
|
||||
|
||||
@@ -23,33 +23,33 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifdef __sgi
|
||||
#include <string.h>
|
||||
#define errx(exitcode, format, args...) \
|
||||
{ \
|
||||
warnx(format, ##args); \
|
||||
exit(exitcode); \
|
||||
}
|
||||
#define warnx(format, args...) fprintf(stderr, format "\n", ##args)
|
||||
# include <string.h>
|
||||
# define errx(exitcode, format, args...) \
|
||||
{ \
|
||||
warnx(format, ##args); \
|
||||
exit(exitcode); \
|
||||
}
|
||||
# define warnx(format, args...) fprintf(stderr, format "\n", ##args)
|
||||
char *strndup(const char *s, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
# include <sys/socket.h>
|
||||
#endif /* HAVE_SYS_SOCKET_H */
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
# include <netinet/in.h>
|
||||
#endif /* HAVE_NETINET_IN_H */
|
||||
#include <netinet/tcp.h>
|
||||
#ifndef __sgi
|
||||
#include <err.h>
|
||||
# include <err.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
@@ -199,22 +199,27 @@ static void print_headers(FILE *f, nghttp2_nv *nva, size_t nvlen) {
|
||||
/* nghttp2_send_callback. Here we transmit the |data|, |length| bytes,
|
||||
to the network. Because we are using libevent bufferevent, we just
|
||||
write those bytes into bufferevent buffer. */
|
||||
static ssize_t send_callback(nghttp2_session *session _U_, const uint8_t *data,
|
||||
size_t length, int flags _U_, void *user_data) {
|
||||
static ssize_t send_callback(nghttp2_session *session, const uint8_t *data,
|
||||
size_t length, int flags, void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
struct bufferevent *bev = session_data->bev;
|
||||
(void)session;
|
||||
(void)flags;
|
||||
|
||||
bufferevent_write(bev, data, length);
|
||||
return (ssize_t)length;
|
||||
}
|
||||
|
||||
/* nghttp2_on_header_callback: Called when nghttp2 library emits
|
||||
single header name/value pair. */
|
||||
static int on_header_callback(nghttp2_session *session _U_,
|
||||
static int on_header_callback(nghttp2_session *session,
|
||||
const nghttp2_frame *frame, const uint8_t *name,
|
||||
size_t namelen, const uint8_t *value,
|
||||
size_t valuelen, uint8_t flags _U_,
|
||||
void *user_data) {
|
||||
size_t valuelen, uint8_t flags, void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
(void)session;
|
||||
(void)flags;
|
||||
|
||||
switch (frame->hd.type) {
|
||||
case NGHTTP2_HEADERS:
|
||||
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE &&
|
||||
@@ -229,10 +234,12 @@ static int on_header_callback(nghttp2_session *session _U_,
|
||||
|
||||
/* nghttp2_on_begin_headers_callback: Called when nghttp2 library gets
|
||||
started to receive header block. */
|
||||
static int on_begin_headers_callback(nghttp2_session *session _U_,
|
||||
static int on_begin_headers_callback(nghttp2_session *session,
|
||||
const nghttp2_frame *frame,
|
||||
void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
(void)session;
|
||||
|
||||
switch (frame->hd.type) {
|
||||
case NGHTTP2_HEADERS:
|
||||
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE &&
|
||||
@@ -247,9 +254,11 @@ static int on_begin_headers_callback(nghttp2_session *session _U_,
|
||||
|
||||
/* nghttp2_on_frame_recv_callback: Called when nghttp2 library
|
||||
received a complete frame from the remote peer. */
|
||||
static int on_frame_recv_callback(nghttp2_session *session _U_,
|
||||
static int on_frame_recv_callback(nghttp2_session *session,
|
||||
const nghttp2_frame *frame, void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
(void)session;
|
||||
|
||||
switch (frame->hd.type) {
|
||||
case NGHTTP2_HEADERS:
|
||||
if (frame->headers.cat == NGHTTP2_HCAT_RESPONSE &&
|
||||
@@ -266,11 +275,13 @@ static int on_frame_recv_callback(nghttp2_session *session _U_,
|
||||
is meant to the stream we initiated, print the received data in
|
||||
stdout, so that the user can redirect its output to the file
|
||||
easily. */
|
||||
static int on_data_chunk_recv_callback(nghttp2_session *session _U_,
|
||||
uint8_t flags _U_, int32_t stream_id,
|
||||
const uint8_t *data, size_t len,
|
||||
void *user_data) {
|
||||
static int on_data_chunk_recv_callback(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id, const uint8_t *data,
|
||||
size_t len, void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
(void)session;
|
||||
(void)flags;
|
||||
|
||||
if (session_data->stream_data->stream_id == stream_id) {
|
||||
fwrite(data, 1, len, stdout);
|
||||
}
|
||||
@@ -297,17 +308,22 @@ static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
/* NPN TLS extension client callback. We check that server advertised
|
||||
the HTTP/2 protocol the nghttp2 library supports. If not, exit
|
||||
the program. */
|
||||
static int select_next_proto_cb(SSL *ssl _U_, unsigned char **out,
|
||||
static int select_next_proto_cb(SSL *ssl, unsigned char **out,
|
||||
unsigned char *outlen, const unsigned char *in,
|
||||
unsigned int inlen, void *arg _U_) {
|
||||
unsigned int inlen, void *arg) {
|
||||
(void)ssl;
|
||||
(void)arg;
|
||||
|
||||
if (nghttp2_select_next_protocol(out, outlen, in, inlen) <= 0) {
|
||||
errx(1, "Server did not advertise " NGHTTP2_PROTO_VERSION_ID);
|
||||
}
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
|
||||
/* Create SSL_CTX. */
|
||||
static SSL_CTX *create_ssl_ctx(void) {
|
||||
@@ -321,11 +337,13 @@ static SSL_CTX *create_ssl_ctx(void) {
|
||||
SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 |
|
||||
SSL_OP_NO_COMPRESSION |
|
||||
SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
SSL_CTX_set_next_proto_select_cb(ssl_ctx, select_next_proto_cb, NULL);
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
SSL_CTX_set_alpn_protos(ssl_ctx, (const unsigned char *)"\x02h2", 3);
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
#endif /* OPENSSL_VERSION_NUMBER >= 0x10002000L */
|
||||
|
||||
return ssl_ctx;
|
||||
}
|
||||
@@ -461,8 +479,10 @@ static void readcb(struct bufferevent *bev, void *ptr) {
|
||||
receiving GOAWAY, we check the some conditions on the nghttp2
|
||||
library and output buffer of bufferevent. If it indicates we have
|
||||
no business to this session, tear down the connection. */
|
||||
static void writecb(struct bufferevent *bev _U_, void *ptr) {
|
||||
static void writecb(struct bufferevent *bev, void *ptr) {
|
||||
http2_session_data *session_data = (http2_session_data *)ptr;
|
||||
(void)bev;
|
||||
|
||||
if (nghttp2_session_want_read(session_data->session) == 0 &&
|
||||
nghttp2_session_want_write(session_data->session) == 0 &&
|
||||
evbuffer_get_length(bufferevent_get_output(session_data->bev)) == 0) {
|
||||
@@ -488,12 +508,14 @@ static void eventcb(struct bufferevent *bev, short events, void *ptr) {
|
||||
|
||||
ssl = bufferevent_openssl_get_ssl(session_data->bev);
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
SSL_get0_next_proto_negotiated(ssl, &alpn, &alpnlen);
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
if (alpn == NULL) {
|
||||
SSL_get0_alpn_selected(ssl, &alpn, &alpnlen);
|
||||
}
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
#endif /* OPENSSL_VERSION_NUMBER >= 0x10002000L */
|
||||
|
||||
if (alpn == NULL || alpnlen != 2 || memcmp("h2", alpn, 2) != 0) {
|
||||
fprintf(stderr, "h2 is not negotiated\n");
|
||||
@@ -532,6 +554,7 @@ static void initiate_connection(struct event_base *evbase, SSL_CTX *ssl_ctx,
|
||||
bev = bufferevent_openssl_socket_new(
|
||||
evbase, -1, ssl, BUFFEREVENT_SSL_CONNECTING,
|
||||
BEV_OPT_DEFER_CALLBACKS | BEV_OPT_CLOSE_ON_FREE);
|
||||
bufferevent_enable(bev, EV_READ | EV_WRITE);
|
||||
bufferevent_setcb(bev, readcb, writecb, eventcb, session_data);
|
||||
rv = bufferevent_socket_connect_hostname(bev, session_data->dnsbase,
|
||||
AF_UNSPEC, host, port);
|
||||
|
||||
@@ -23,41 +23,41 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifdef __sgi
|
||||
#define errx(exitcode, format, args...) \
|
||||
{ \
|
||||
warnx(format, ##args); \
|
||||
exit(exitcode); \
|
||||
}
|
||||
#define warn(format, args...) warnx(format ": %s", ##args, strerror(errno))
|
||||
#define warnx(format, args...) fprintf(stderr, format "\n", ##args)
|
||||
# define errx(exitcode, format, args...) \
|
||||
{ \
|
||||
warnx(format, ##args); \
|
||||
exit(exitcode); \
|
||||
}
|
||||
# define warn(format, args...) warnx(format ": %s", ##args, strerror(errno))
|
||||
# define warnx(format, args...) fprintf(stderr, format "\n", ##args)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
# include <sys/socket.h>
|
||||
#endif /* HAVE_SYS_SOCKET_H */
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
# include <netdb.h>
|
||||
#endif /* HAVE_NETDB_H */
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
# include <fcntl.h>
|
||||
#endif /* HAVE_FCNTL_H */
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
# include <netinet/in.h>
|
||||
#endif /* HAVE_NETINET_IN_H */
|
||||
#include <netinet/tcp.h>
|
||||
#ifndef __sgi
|
||||
#include <err.h>
|
||||
# include <err.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@@ -109,18 +109,25 @@ struct app_context {
|
||||
static unsigned char next_proto_list[256];
|
||||
static size_t next_proto_list_len;
|
||||
|
||||
static int next_proto_cb(SSL *s _U_, const unsigned char **data,
|
||||
unsigned int *len, void *arg _U_) {
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
static int next_proto_cb(SSL *ssl, const unsigned char **data,
|
||||
unsigned int *len, void *arg) {
|
||||
(void)ssl;
|
||||
(void)arg;
|
||||
|
||||
*data = next_proto_list;
|
||||
*len = (unsigned int)next_proto_list_len;
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
static int alpn_select_proto_cb(SSL *ssl _U_, const unsigned char **out,
|
||||
static int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
|
||||
unsigned char *outlen, const unsigned char *in,
|
||||
unsigned int inlen, void *arg _U_) {
|
||||
unsigned int inlen, void *arg) {
|
||||
int rv;
|
||||
(void)ssl;
|
||||
(void)arg;
|
||||
|
||||
rv = nghttp2_select_next_protocol((unsigned char **)out, outlen, in, inlen);
|
||||
|
||||
@@ -130,7 +137,7 @@ static int alpn_select_proto_cb(SSL *ssl _U_, const unsigned char **out,
|
||||
|
||||
return SSL_TLSEXT_ERR_OK;
|
||||
}
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
#endif /* OPENSSL_VERSION_NUMBER >= 0x10002000L */
|
||||
|
||||
/* Create SSL_CTX. */
|
||||
static SSL_CTX *create_ssl_ctx(const char *key_file, const char *cert_file) {
|
||||
@@ -167,11 +174,13 @@ static SSL_CTX *create_ssl_ctx(const char *key_file, const char *cert_file) {
|
||||
NGHTTP2_PROTO_VERSION_ID_LEN);
|
||||
next_proto_list_len = 1 + NGHTTP2_PROTO_VERSION_ID_LEN;
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
SSL_CTX_set_next_protos_advertised_cb(ssl_ctx, next_proto_cb, NULL);
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
SSL_CTX_set_alpn_select_cb(ssl_ctx, alpn_select_proto_cb, NULL);
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
#endif /* OPENSSL_VERSION_NUMBER >= 0x10002000L */
|
||||
|
||||
return ssl_ctx;
|
||||
}
|
||||
@@ -197,8 +206,10 @@ static void add_stream(http2_session_data *session_data,
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_stream(http2_session_data *session_data _U_,
|
||||
static void remove_stream(http2_session_data *session_data,
|
||||
http2_stream_data *stream_data) {
|
||||
(void)session_data;
|
||||
|
||||
stream_data->prev->next = stream_data->next;
|
||||
if (stream_data->next) {
|
||||
stream_data->next->prev = stream_data->prev;
|
||||
@@ -243,6 +254,7 @@ static http2_session_data *create_http2_session_data(app_context *app_ctx,
|
||||
session_data->bev = bufferevent_openssl_socket_new(
|
||||
app_ctx->evbase, fd, ssl, BUFFEREVENT_SSL_ACCEPTING,
|
||||
BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS);
|
||||
bufferevent_enable(session_data->bev, EV_READ | EV_WRITE);
|
||||
rv = getnameinfo(addr, (socklen_t)addrlen, host, sizeof(host), NULL, 0,
|
||||
NI_NUMERICHOST);
|
||||
if (rv != 0) {
|
||||
@@ -309,10 +321,13 @@ static int session_recv(http2_session_data *session_data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t send_callback(nghttp2_session *session _U_, const uint8_t *data,
|
||||
size_t length, int flags _U_, void *user_data) {
|
||||
static ssize_t send_callback(nghttp2_session *session, const uint8_t *data,
|
||||
size_t length, int flags, void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
struct bufferevent *bev = session_data->bev;
|
||||
(void)session;
|
||||
(void)flags;
|
||||
|
||||
/* Avoid excessive buffering in server side. */
|
||||
if (evbuffer_get_length(bufferevent_get_output(session_data->bev)) >=
|
||||
OUTPUT_WOULDBLOCK_THRESHOLD) {
|
||||
@@ -375,13 +390,17 @@ static char *percent_decode(const uint8_t *value, size_t valuelen) {
|
||||
return res;
|
||||
}
|
||||
|
||||
static ssize_t file_read_callback(nghttp2_session *session _U_,
|
||||
int32_t stream_id _U_, uint8_t *buf,
|
||||
size_t length, uint32_t *data_flags,
|
||||
static ssize_t file_read_callback(nghttp2_session *session, int32_t stream_id,
|
||||
uint8_t *buf, size_t length,
|
||||
uint32_t *data_flags,
|
||||
nghttp2_data_source *source,
|
||||
void *user_data _U_) {
|
||||
void *user_data) {
|
||||
int fd = source->fd;
|
||||
ssize_t r;
|
||||
(void)session;
|
||||
(void)stream_id;
|
||||
(void)user_data;
|
||||
|
||||
while ((r = read(fd, buf, length)) == -1 && errno == EINTR)
|
||||
;
|
||||
if (r == -1) {
|
||||
@@ -454,10 +473,12 @@ static int error_reply(nghttp2_session *session,
|
||||
static int on_header_callback(nghttp2_session *session,
|
||||
const nghttp2_frame *frame, const uint8_t *name,
|
||||
size_t namelen, const uint8_t *value,
|
||||
size_t valuelen, uint8_t flags _U_,
|
||||
void *user_data _U_) {
|
||||
size_t valuelen, uint8_t flags, void *user_data) {
|
||||
http2_stream_data *stream_data;
|
||||
const char PATH[] = ":path";
|
||||
(void)flags;
|
||||
(void)user_data;
|
||||
|
||||
switch (frame->hd.type) {
|
||||
case NGHTTP2_HEADERS:
|
||||
if (frame->headers.cat != NGHTTP2_HCAT_REQUEST) {
|
||||
@@ -570,9 +591,10 @@ static int on_frame_recv_callback(nghttp2_session *session,
|
||||
}
|
||||
|
||||
static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
|
||||
uint32_t error_code _U_, void *user_data) {
|
||||
uint32_t error_code, void *user_data) {
|
||||
http2_session_data *session_data = (http2_session_data *)user_data;
|
||||
http2_stream_data *stream_data;
|
||||
(void)error_code;
|
||||
|
||||
stream_data = nghttp2_session_get_stream_user_data(session, stream_id);
|
||||
if (!stream_data) {
|
||||
@@ -625,8 +647,10 @@ static int send_server_connection_header(http2_session_data *session_data) {
|
||||
|
||||
/* readcb for bufferevent after client connection header was
|
||||
checked. */
|
||||
static void readcb(struct bufferevent *bev _U_, void *ptr) {
|
||||
static void readcb(struct bufferevent *bev, void *ptr) {
|
||||
http2_session_data *session_data = (http2_session_data *)ptr;
|
||||
(void)bev;
|
||||
|
||||
if (session_recv(session_data) != 0) {
|
||||
delete_http2_session_data(session_data);
|
||||
return;
|
||||
@@ -658,23 +682,26 @@ static void writecb(struct bufferevent *bev, void *ptr) {
|
||||
}
|
||||
|
||||
/* eventcb for bufferevent */
|
||||
static void eventcb(struct bufferevent *bev _U_, short events, void *ptr) {
|
||||
static void eventcb(struct bufferevent *bev, short events, void *ptr) {
|
||||
http2_session_data *session_data = (http2_session_data *)ptr;
|
||||
if (events & BEV_EVENT_CONNECTED) {
|
||||
const unsigned char *alpn = NULL;
|
||||
unsigned int alpnlen = 0;
|
||||
SSL *ssl;
|
||||
(void)bev;
|
||||
|
||||
fprintf(stderr, "%s connected\n", session_data->client_addr);
|
||||
|
||||
ssl = bufferevent_openssl_get_ssl(session_data->bev);
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
SSL_get0_next_proto_negotiated(ssl, &alpn, &alpnlen);
|
||||
#endif /* !OPENSSL_NO_NEXTPROTONEG */
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
if (alpn == NULL) {
|
||||
SSL_get0_alpn_selected(ssl, &alpn, &alpnlen);
|
||||
}
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L
|
||||
#endif /* OPENSSL_VERSION_NUMBER >= 0x10002000L */
|
||||
|
||||
if (alpn == NULL || alpnlen != 2 || memcmp("h2", alpn, 2) != 0) {
|
||||
fprintf(stderr, "%s h2 is not negotiated\n", session_data->client_addr);
|
||||
@@ -703,10 +730,11 @@ static void eventcb(struct bufferevent *bev _U_, short events, void *ptr) {
|
||||
}
|
||||
|
||||
/* callback for evconnlistener */
|
||||
static void acceptcb(struct evconnlistener *listener _U_, int fd,
|
||||
static void acceptcb(struct evconnlistener *listener, int fd,
|
||||
struct sockaddr *addr, int addrlen, void *arg) {
|
||||
app_context *app_ctx = (app_context *)arg;
|
||||
http2_session_data *session_data;
|
||||
(void)listener;
|
||||
|
||||
session_data = create_http2_session_data(app_ctx, fd, addr, addrlen);
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ following compiler/linker flags:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
CPPFLAGS="-fsanitize-coverage=edge -fsanitize=addres"
|
||||
LDFLAGS="-fsanitize-coverage=edge -fsanitize=addres"
|
||||
CPPFLAGS="-fsanitize-coverage=edge -fsanitize=address"
|
||||
LDFLAGS="-fsanitize-coverage=edge -fsanitize=address"
|
||||
|
||||
Then, fuzz_target.cc can be built using the following command:
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ HEADERS = [
|
||||
':scheme',
|
||||
':status',
|
||||
':host', # for spdy
|
||||
':protocol',
|
||||
'expect',
|
||||
'host',
|
||||
'if-modified-since',
|
||||
@@ -31,6 +32,9 @@ HEADERS = [
|
||||
"user-agent",
|
||||
"date",
|
||||
"content-type",
|
||||
"early-data",
|
||||
"sec-websocket-accept",
|
||||
"sec-websocket-key",
|
||||
# disallowed h1 headers
|
||||
'connection',
|
||||
'keep-alive',
|
||||
@@ -40,4 +44,4 @@ HEADERS = [
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
gentokenlookup(HEADERS, 'HD')
|
||||
gentokenlookup(HEADERS, 'HD_')
|
||||
|
||||
@@ -67,6 +67,7 @@ HEADERS = [
|
||||
('keep-alive',None),
|
||||
('proxy-connection', None),
|
||||
('upgrade', None),
|
||||
(':protocol', None),
|
||||
]
|
||||
|
||||
def to_enum_hd(k):
|
||||
|
||||
@@ -50,4 +50,4 @@ if __name__ == '__main__':
|
||||
continue
|
||||
_, m, _ = line.split(',', 2)
|
||||
methods.append(m.strip())
|
||||
gentokenlookup(methods, 'HTTP')
|
||||
gentokenlookup(methods, 'HTTP_')
|
||||
|
||||
@@ -158,6 +158,23 @@ OPTIONS = [
|
||||
"client-no-http2-cipher-black-list",
|
||||
"client-ciphers",
|
||||
"accesslog-write-early",
|
||||
"tls-min-proto-version",
|
||||
"tls-max-proto-version",
|
||||
"redirect-https-port",
|
||||
"frontend-max-requests",
|
||||
"single-thread",
|
||||
"single-process",
|
||||
"no-add-x-forwarded-proto",
|
||||
"no-strip-incoming-x-forwarded-proto",
|
||||
"ocsp-startup",
|
||||
"no-verify-ocsp",
|
||||
"verify-client-tolerate-expired",
|
||||
"ignore-per-pattern-mruby-error",
|
||||
"tls-no-postpone-early-data",
|
||||
"tls-max-early-data",
|
||||
"tls13-ciphers",
|
||||
"tls13-client-ciphers",
|
||||
"no-strip-incoming-early-data",
|
||||
]
|
||||
|
||||
LOGVARS = [
|
||||
@@ -176,10 +193,20 @@ LOGVARS = [
|
||||
"ssl_protocol",
|
||||
"ssl_session_id",
|
||||
"ssl_session_reused",
|
||||
"tls_cipher",
|
||||
"tls_protocol",
|
||||
"tls_session_id",
|
||||
"tls_session_reused",
|
||||
"tls_sni",
|
||||
"tls_client_fingerprint_sha256",
|
||||
"tls_client_fingerprint_sha1",
|
||||
"tls_client_subject_name",
|
||||
"tls_client_issuer_name",
|
||||
"tls_client_serial",
|
||||
"backend_host",
|
||||
"backend_port",
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
gentokenlookup(OPTIONS, 'SHRPX_OPTID', value_type='char', comp_fun='util::strieq_l')
|
||||
gentokenlookup(LOGVARS, 'SHRPX_LOGF', value_type='char', comp_fun='util::strieq_l', return_type='LogFragmentType', fail_value='SHRPX_LOGF_NONE')
|
||||
gentokenlookup(OPTIONS, 'SHRPX_OPTID_', value_type='char', comp_fun='util::strieq_l')
|
||||
gentokenlookup(LOGVARS, 'LogFragmentType::', value_type='char', comp_fun='util::strieq_l', return_type='LogFragmentType', fail_value='LogFragmentType::NONE')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
def to_enum_hd(k, prefix):
|
||||
res = prefix + '_'
|
||||
res = prefix
|
||||
for c in k.upper():
|
||||
if c == ':' or c == '-':
|
||||
res += '_'
|
||||
@@ -30,7 +30,7 @@ enum {'''
|
||||
print '''\
|
||||
{},'''.format(to_enum_hd(k, prefix))
|
||||
print '''\
|
||||
{}_MAXIDX,
|
||||
{}MAXIDX,
|
||||
}};'''.format(prefix)
|
||||
|
||||
def gen_index_header(tokens, prefix, value_type, comp_fun, return_type, fail_value):
|
||||
|
||||
@@ -167,7 +167,7 @@ def format_text(text):
|
||||
else:
|
||||
text = re.sub(r'\*', r'\*', text)
|
||||
# markup option reference
|
||||
text = re.sub(r'(^|\s)(-[a-zA-Z0-9]|--[a-zA-Z0-9-]+)',
|
||||
text = re.sub(r'(^|\s)(-[a-zA-Z]|--[a-zA-Z0-9-]+)',
|
||||
r'\1:option:`\2`', text)
|
||||
# sphinx does not like markup like ':option:`-f`='. We need
|
||||
# backslash between ` and =.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
set(GO_FILES
|
||||
nghttpx_http1_test.go
|
||||
nghttpx_http2_test.go
|
||||
nghttpx_spdy_test.go
|
||||
server_tester.go
|
||||
)
|
||||
|
||||
@@ -22,7 +21,6 @@ set(EXTRA_DIST
|
||||
add_custom_target(itprep
|
||||
COMMAND go get -d -v golang.org/x/net/http2
|
||||
COMMAND go get -d -v github.com/tatsuhiro-t/go-nghttp2
|
||||
COMMAND go get -d -v github.com/tatsuhiro-t/spdy
|
||||
COMMAND go get -d -v golang.org/x/net/websocket
|
||||
)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
GO_FILES = \
|
||||
nghttpx_http1_test.go \
|
||||
nghttpx_http2_test.go \
|
||||
nghttpx_spdy_test.go \
|
||||
server_tester.go
|
||||
|
||||
EXTRA_DIST = \
|
||||
@@ -43,7 +42,6 @@ EXTRA_DIST = \
|
||||
itprep:
|
||||
go get -d -v golang.org/x/net/http2
|
||||
go get -d -v github.com/tatsuhiro-t/go-nghttp2
|
||||
go get -d -v github.com/tatsuhiro-t/spdy
|
||||
go get -d -v golang.org/x/net/websocket
|
||||
|
||||
it:
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"golang.org/x/net/websocket"
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -125,6 +126,54 @@ Content-Length: 0
|
||||
// }
|
||||
// }
|
||||
|
||||
// TestH1H1AffinityCookie tests that affinity cookie is sent back in
|
||||
// cleartext http.
|
||||
func TestH1H1AffinityCookie(t *testing.T) {
|
||||
st := newServerTester([]string{"--affinity-cookie"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http1(requestParam{
|
||||
name: "TestH1H1AffinityCookie",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http1() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
const pattern = `affinity=[0-9a-f]{8}; Path=/foo/bar`
|
||||
validCookie := regexp.MustCompile(pattern)
|
||||
if got := res.header.Get("Set-Cookie"); !validCookie.MatchString(got) {
|
||||
t.Errorf("Set-Cookie: %v; want pattern %v", got, pattern)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH1H1AffinityCookieTLS tests that affinity cookie is sent back
|
||||
// in https.
|
||||
func TestH1H1AffinityCookieTLS(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--alpn-h1", "--affinity-cookie"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http1(requestParam{
|
||||
name: "TestH1H1AffinityCookieTLS",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http1() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
const pattern = `affinity=[0-9a-f]{8}; Path=/foo/bar; Secure`
|
||||
validCookie := regexp.MustCompile(pattern)
|
||||
if got := res.header.Get("Set-Cookie"); !validCookie.MatchString(got) {
|
||||
t.Errorf("Set-Cookie: %v; want pattern %v", got, pattern)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH1H1GracefulShutdown tests graceful shutdown.
|
||||
func TestH1H1GracefulShutdown(t *testing.T) {
|
||||
st := newServerTester(nil, t, noopHandler)
|
||||
@@ -162,7 +211,7 @@ func TestH1H1GracefulShutdown(t *testing.T) {
|
||||
want := io.EOF
|
||||
b := make([]byte, 256)
|
||||
if _, err := st.conn.Read(b); err == nil || err != want {
|
||||
t.Errorf("st.conn.Read(): %v; want %v, %v", err, want)
|
||||
t.Errorf("st.conn.Read(): %v; want %v", err, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +388,7 @@ func TestH1H1HeaderFieldBufferPath(t *testing.T) {
|
||||
// The value 100 is chosen so that sum of header fields bytes
|
||||
// does not exceed it. We use > 100 bytes URI to exceed this
|
||||
// limit.
|
||||
st := newServerTester([]string{"--header-field-buffer=100"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--request-header-field-buffer=100"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
@@ -359,7 +408,7 @@ func TestH1H1HeaderFieldBufferPath(t *testing.T) {
|
||||
// TestH1H1HeaderFieldBuffer tests that request with header fields
|
||||
// larger than configured buffer size is rejected.
|
||||
func TestH1H1HeaderFieldBuffer(t *testing.T) {
|
||||
st := newServerTester([]string{"--header-field-buffer=10"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--request-header-field-buffer=10"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
@@ -378,7 +427,7 @@ func TestH1H1HeaderFieldBuffer(t *testing.T) {
|
||||
// TestH1H1HeaderFields tests that request with header fields more
|
||||
// than configured number is rejected.
|
||||
func TestH1H1HeaderFields(t *testing.T) {
|
||||
st := newServerTester([]string{"--max-header-fields=1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--max-request-header-fields=1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
@@ -533,6 +582,49 @@ func TestH1H1RespPhaseReturn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestH1H1HTTPSRedirect tests that the request to the backend which
|
||||
// requires TLS is redirected to https URI.
|
||||
func TestH1H1HTTPSRedirect(t *testing.T) {
|
||||
st := newServerTester([]string{"--redirect-if-not-tls"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http1(requestParam{
|
||||
name: "TestH1H1HTTPSRedirect",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http1() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 308; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
if got, want := res.header.Get("location"), "https://127.0.0.1/"; got != want {
|
||||
t.Errorf("location: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH1H1HTTPSRedirectPort tests that the request to the backend
|
||||
// which requires TLS is redirected to https URI with given port.
|
||||
func TestH1H1HTTPSRedirectPort(t *testing.T) {
|
||||
st := newServerTester([]string{"--redirect-if-not-tls", "--redirect-https-port=8443"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http1(requestParam{
|
||||
path: "/foo?bar",
|
||||
name: "TestH1H1HTTPSRedirectPort",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http1() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 308; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
if got, want := res.header.Get("location"), "https://127.0.0.1:8443/foo?bar"; got != want {
|
||||
t.Errorf("location: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// // TestH1H2ConnectFailure tests that server handles the situation that
|
||||
// // connection attempt to HTTP/2 backend failed.
|
||||
// func TestH1H2ConnectFailure(t *testing.T) {
|
||||
@@ -931,6 +1023,43 @@ backend=127.0.0.1,3011
|
||||
}
|
||||
}
|
||||
|
||||
// TestH1APIConfigrevision tests configrevision API.
|
||||
func TestH1APIConfigrevision(t *testing.T) {
|
||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3010)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http1(requestParam{
|
||||
name: "TestH1APIConfigrevision",
|
||||
path: "/api/v1beta1/configrevision",
|
||||
method: "GET",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http1() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("res.status: %v; want = %v", got, want)
|
||||
}
|
||||
|
||||
var apiResp APIResponse
|
||||
d := json.NewDecoder(bytes.NewBuffer(res.body))
|
||||
d.UseNumber()
|
||||
err = d.Decode(&apiResp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshalling API response: %v", err)
|
||||
}
|
||||
if got, want := apiResp.Status, "Success"; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Code, 200; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Data["configRevision"], json.Number("0"); got != want {
|
||||
t.Errorf(`apiResp.Data["configRevision"]: %v %t; want %v`, got, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH1APINotFound exercise backendconfig API endpoint routine when
|
||||
// API endpoint is not found.
|
||||
func TestH1APINotFound(t *testing.T) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package nghttp2
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -34,6 +35,105 @@ func TestH2H1PlainGET(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1AddXfp tests that server appends :scheme to the existing
|
||||
// x-forwarded-proto header field.
|
||||
func TestH2H1AddXfp(t *testing.T) {
|
||||
st := newServerTester([]string{"--no-strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
xfp := r.Header.Get("X-Forwarded-Proto")
|
||||
if got, want := xfp, "foo, http"; got != want {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want %q", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1AddXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1NoAddXfp tests that server does not append :scheme to the
|
||||
// existing x-forwarded-proto header field.
|
||||
func TestH2H1NoAddXfp(t *testing.T) {
|
||||
st := newServerTester([]string{"--no-add-x-forwarded-proto", "--no-strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
xfp := r.Header.Get("X-Forwarded-Proto")
|
||||
if got, want := xfp, "foo"; got != want {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want %q", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1NoAddXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1StripXfp tests that server strips incoming
|
||||
// x-forwarded-proto header field.
|
||||
func TestH2H1StripXfp(t *testing.T) {
|
||||
st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
xfp := r.Header.Get("X-Forwarded-Proto")
|
||||
if got, want := xfp, "http"; got != want {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want %q", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1StripXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1StripNoAddXfp tests that server strips incoming
|
||||
// x-forwarded-proto header field, and does not add another.
|
||||
func TestH2H1StripNoAddXfp(t *testing.T) {
|
||||
st := newServerTester([]string{"--no-add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, found := r.Header["X-Forwarded-Proto"]; found {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want nothing", got)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1StripNoAddXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1AddXff tests that server generates X-Forwarded-For header
|
||||
// field when forwarding request to backend.
|
||||
func TestH2H1AddXff(t *testing.T) {
|
||||
@@ -829,7 +929,7 @@ func TestH2H1RequestTrailer(t *testing.T) {
|
||||
// TestH2H1HeaderFieldBuffer tests that request with header fields
|
||||
// larger than configured buffer size is rejected.
|
||||
func TestH2H1HeaderFieldBuffer(t *testing.T) {
|
||||
st := newServerTester([]string{"--header-field-buffer=10"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--request-header-field-buffer=10"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
@@ -848,7 +948,7 @@ func TestH2H1HeaderFieldBuffer(t *testing.T) {
|
||||
// TestH2H1HeaderFields tests that request with header fields more
|
||||
// than configured number is rejected.
|
||||
func TestH2H1HeaderFields(t *testing.T) {
|
||||
st := newServerTester([]string{"--max-header-fields=1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--max-request-header-fields=1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
@@ -1013,14 +1113,45 @@ func TestH2H1Upgrade(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1ProxyProtocolV1ForwardedForObfuscated tests that Forwarded
|
||||
// header field includes obfuscated address even if PROXY protocol
|
||||
// version 1 containing TCP4 entry is accepted.
|
||||
func TestH2H1ProxyProtocolV1ForwardedForObfuscated(t *testing.T) {
|
||||
pattern := fmt.Sprintf(`^for=_[^;]+$`)
|
||||
validFwd := regexp.MustCompile(pattern)
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for", "--add-forwarded=for", "--forwarded-for=obfuscated"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got := r.Header.Get("Forwarded"); !validFwd.MatchString(got) {
|
||||
t.Errorf("Forwarded: %v; want pattern %v", got, pattern)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
st.conn.Write([]byte("PROXY TCP4 192.168.0.2 192.168.0.100 12345 8080\r\n"))
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1ProxyProtocolV1ForwardedForObfuscated",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1ProxyProtocolV1TCP4 tests PROXY protocol version 1
|
||||
// containing TCP4 entry is accepted and X-Forwarded-For contains
|
||||
// advertised src address.
|
||||
func TestH2H1ProxyProtocolV1TCP4(t *testing.T) {
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for", "--add-forwarded=for", "--forwarded-for=ip"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, want := r.Header.Get("X-Forwarded-For"), "192.168.0.2"; got != want {
|
||||
t.Errorf("X-Forwarded-For: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := r.Header.Get("Forwarded"), "for=192.168.0.2"; got != want {
|
||||
t.Errorf("Forwarded: %v; want %v", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
@@ -1043,10 +1174,13 @@ func TestH2H1ProxyProtocolV1TCP4(t *testing.T) {
|
||||
// containing TCP6 entry is accepted and X-Forwarded-For contains
|
||||
// advertised src address.
|
||||
func TestH2H1ProxyProtocolV1TCP6(t *testing.T) {
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for", "--add-forwarded=for", "--forwarded-for=ip"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, want := r.Header.Get("X-Forwarded-For"), "2001:0db8:85a3:0000:0000:8a2e:0370:7334"; got != want {
|
||||
t.Errorf("X-Forwarded-For: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := r.Header.Get("Forwarded"), `for="[2001:0db8:85a3:0000:0000:8a2e:0370:7334]"`; got != want {
|
||||
t.Errorf("Forwarded: %v; want %v", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
@@ -1068,9 +1202,12 @@ func TestH2H1ProxyProtocolV1TCP6(t *testing.T) {
|
||||
// TestH2H1ProxyProtocolV1Unknown tests PROXY protocol version 1
|
||||
// containing UNKNOWN entry is accepted.
|
||||
func TestH2H1ProxyProtocolV1Unknown(t *testing.T) {
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
st := newServerTester([]string{"--accept-proxy-protocol", "--add-x-forwarded-for", "--add-forwarded=for", "--forwarded-for=ip"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, notWant := r.Header.Get("X-Forwarded-For"), "192.168.0.2"; got == notWant {
|
||||
t.Errorf("X-Forwarded-For: %v")
|
||||
t.Errorf("X-Forwarded-For: %v; want something else", got)
|
||||
}
|
||||
if got, notWant := r.Header.Get("Forwarded"), "for=192.168.0.2"; got == notWant {
|
||||
t.Errorf("Forwarded: %v; want something else", got)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
@@ -1405,6 +1542,218 @@ func TestH2H1DNS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1HTTPSRedirect tests that the request to the backend which
|
||||
// requires TLS is redirected to https URI.
|
||||
func TestH2H1HTTPSRedirect(t *testing.T) {
|
||||
st := newServerTester([]string{"--redirect-if-not-tls"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1HTTPSRedirect",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 308; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
if got, want := res.header.Get("location"), "https://127.0.0.1/"; got != want {
|
||||
t.Errorf("location: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1HTTPSRedirectPort tests that the request to the backend
|
||||
// which requires TLS is redirected to https URI with given port.
|
||||
func TestH2H1HTTPSRedirectPort(t *testing.T) {
|
||||
st := newServerTester([]string{"--redirect-if-not-tls", "--redirect-https-port=8443"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
path: "/foo?bar",
|
||||
name: "TestH2H1HTTPSRedirectPort",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 308; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
if got, want := res.header.Get("location"), "https://127.0.0.1:8443/foo?bar"; got != want {
|
||||
t.Errorf("location: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1Code204 tests that 204 response without content-length, and
|
||||
// transfer-encoding is valid.
|
||||
func TestH2H1Code204(t *testing.T) {
|
||||
st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1Code204",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 204; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1Code204CL0 tests that 204 response with content-length: 0
|
||||
// is allowed.
|
||||
func TestH2H1Code204CL0(t *testing.T) {
|
||||
st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
hj, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
http.Error(w, "Could not hijack the connection", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
conn, bufrw, err := hj.Hijack()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
bufrw.WriteString("HTTP/1.1 204\r\nContent-Length: 0\r\n\r\n")
|
||||
bufrw.Flush()
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1Code204CL0",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 204; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
if got, found := res.header["Content-Length"]; found {
|
||||
t.Errorf("Content-Length = %v, want nothing", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1Code204CLNonzero tests that 204 response with nonzero
|
||||
// content-length is not allowed.
|
||||
func TestH2H1Code204CLNonzero(t *testing.T) {
|
||||
st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
hj, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
http.Error(w, "Could not hijack the connection", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
conn, bufrw, err := hj.Hijack()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
bufrw.WriteString("HTTP/1.1 204\r\nContent-Length: 1\r\n\r\n")
|
||||
bufrw.Flush()
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1Code204CLNonzero",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 502; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1Code204TE tests that 204 response with transfer-encoding is
|
||||
// not allowed.
|
||||
func TestH2H1Code204TE(t *testing.T) {
|
||||
st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
hj, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
http.Error(w, "Could not hijack the connection", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
conn, bufrw, err := hj.Hijack()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
bufrw.WriteString("HTTP/1.1 204\r\nTransfer-Encoding: chunked\r\n\r\n")
|
||||
bufrw.Flush()
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1Code204TE",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 502; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1AffinityCookie tests that affinity cookie is sent back in
|
||||
// cleartext http.
|
||||
func TestH2H1AffinityCookie(t *testing.T) {
|
||||
st := newServerTester([]string{"--affinity-cookie"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1AffinityCookie",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
const pattern = `affinity=[0-9a-f]{8}; Path=/foo/bar`
|
||||
validCookie := regexp.MustCompile(pattern)
|
||||
if got := res.header.Get("Set-Cookie"); !validCookie.MatchString(got) {
|
||||
t.Errorf("Set-Cookie: %v; want pattern %v", got, pattern)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1AffinityCookieTLS tests that affinity cookie is sent back
|
||||
// in https.
|
||||
func TestH2H1AffinityCookieTLS(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--affinity-cookie"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H1AffinityCookieTLS",
|
||||
scheme: "https",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
const pattern = `affinity=[0-9a-f]{8}; Path=/foo/bar; Secure`
|
||||
validCookie := regexp.MustCompile(pattern)
|
||||
if got := res.header.Get("Set-Cookie"); !validCookie.MatchString(got) {
|
||||
t.Errorf("Set-Cookie: %v; want pattern %v", got, pattern)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H1GracefulShutdown tests graceful shutdown.
|
||||
func TestH2H1GracefulShutdown(t *testing.T) {
|
||||
st := newServerTester(nil, t, noopHandler)
|
||||
@@ -1609,6 +1958,105 @@ func TestH2H2TLSXfp(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H2AddXfp tests that server appends :scheme to the existing
|
||||
// x-forwarded-proto header field.
|
||||
func TestH2H2AddXfp(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--http2-bridge", "--no-strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
xfp := r.Header.Get("X-Forwarded-Proto")
|
||||
if got, want := xfp, "foo, http"; got != want {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want %q", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H2AddXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H2NoAddXfp tests that server does not append :scheme to the
|
||||
// existing x-forwarded-proto header field.
|
||||
func TestH2H2NoAddXfp(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--http2-bridge", "--no-add-x-forwarded-proto", "--no-strip-incoming-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
xfp := r.Header.Get("X-Forwarded-Proto")
|
||||
if got, want := xfp, "foo"; got != want {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want %q", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H2NoAddXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H2StripXfp tests that server strips incoming
|
||||
// x-forwarded-proto header field.
|
||||
func TestH2H2StripXfp(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--http2-bridge"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
xfp := r.Header.Get("X-Forwarded-Proto")
|
||||
if got, want := xfp, "http"; got != want {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want %q", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H2StripXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H2StripNoAddXfp tests that server strips incoming
|
||||
// x-forwarded-proto header field, and does not add another.
|
||||
func TestH2H2StripNoAddXfp(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--http2-bridge", "--no-add-x-forwarded-proto"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, found := r.Header["X-Forwarded-Proto"]; found {
|
||||
t.Errorf("X-Forwarded-Proto = %q; want nothing", got)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H2StripNoAddXfp",
|
||||
header: []hpack.HeaderField{
|
||||
pair("x-forwarded-proto", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H2AddXff tests that server generates X-Forwarded-For header
|
||||
// field when forwarding request to backend.
|
||||
func TestH2H2AddXff(t *testing.T) {
|
||||
@@ -1917,6 +2365,26 @@ func TestH2H2DNS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2H2Code204 tests that 204 response without content-length, and
|
||||
// transfer-encoding is valid.
|
||||
func TestH2H2Code204(t *testing.T) {
|
||||
st := newServerTester([]string{"--http2-bridge"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2H2Code204",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 204; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2APIBackendconfig exercise backendconfig API endpoint routine
|
||||
// for successful case.
|
||||
func TestH2APIBackendconfig(t *testing.T) {
|
||||
@@ -2028,6 +2496,43 @@ backend=127.0.0.1,3011
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2APIConfigrevision tests configrevision API.
|
||||
func TestH2APIConfigrevision(t *testing.T) {
|
||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3010)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.http2(requestParam{
|
||||
name: "TestH2APIConfigrevision",
|
||||
path: "/api/v1beta1/configrevision",
|
||||
method: "GET",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.http2() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("res.status: %v; want = %v", got, want)
|
||||
}
|
||||
|
||||
var apiResp APIResponse
|
||||
d := json.NewDecoder(bytes.NewBuffer(res.body))
|
||||
d.UseNumber()
|
||||
err = d.Decode(&apiResp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshalling API response: %v", err)
|
||||
}
|
||||
if got, want := apiResp.Status, "Success"; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Code, 200; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Data["configRevision"], json.Number("0"); got != want {
|
||||
t.Errorf(`apiResp.Data["configRevision"]: %v %t; want %v`, got, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestH2APINotFound exercise backendconfig API endpoint routine when
|
||||
// API endpoint is not found.
|
||||
func TestH2APINotFound(t *testing.T) {
|
||||
|
||||
@@ -1,664 +0,0 @@
|
||||
package nghttp2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/tatsuhiro-t/spdy"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestS3H1PlainGET tests whether simple SPDY GET request works.
|
||||
func TestS3H1PlainGET(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1PlainGET",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
want := 200
|
||||
if got := res.status; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1BadRequestCL tests that server rejects request whose
|
||||
// content-length header field value does not match its request body
|
||||
// size.
|
||||
func TestS3H1BadRequestCL(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
// we set content-length: 1024, but the actual request body is
|
||||
// 3 bytes.
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1BadRequestCL",
|
||||
method: "POST",
|
||||
header: []hpack.HeaderField{
|
||||
pair("content-length", "1024"),
|
||||
},
|
||||
body: []byte("foo"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
want := spdy.ProtocolError
|
||||
if got := res.spdyRstErrCode; got != want {
|
||||
t.Errorf("res.spdyRstErrCode = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1MultipleRequestCL tests that server rejects request with
|
||||
// multiple Content-Length request header fields.
|
||||
func TestS3H1MultipleRequestCL(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Errorf("server should not forward bad request")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1MultipleRequestCL",
|
||||
header: []hpack.HeaderField{
|
||||
pair("content-length", "1"),
|
||||
pair("content-length", "1"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
want := 400
|
||||
if got := res.status; got != want {
|
||||
t.Errorf("status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1InvalidRequestCL tests that server rejects request with
|
||||
// Content-Length which cannot be parsed as a number.
|
||||
func TestS3H1InvalidRequestCL(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Errorf("server should not forward bad request")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1InvalidRequestCL",
|
||||
header: []hpack.HeaderField{
|
||||
pair("content-length", ""),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
want := 400
|
||||
if got := res.status; got != want {
|
||||
t.Errorf("status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1GenerateVia tests that server generates Via header field to and
|
||||
// from backend server.
|
||||
func TestS3H1GenerateVia(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, want := r.Header.Get("Via"), "1.1 nghttpx"; got != want {
|
||||
t.Errorf("Via: %v; want %v", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1GenerateVia",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.header.Get("Via"), "1.1 nghttpx"; got != want {
|
||||
t.Errorf("Via: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1AppendVia tests that server adds value to existing Via
|
||||
// header field to and from backend server.
|
||||
func TestS3H1AppendVia(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, want := r.Header.Get("Via"), "foo, 1.1 nghttpx"; got != want {
|
||||
t.Errorf("Via: %v; want %v", got, want)
|
||||
}
|
||||
w.Header().Add("Via", "bar")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1AppendVia",
|
||||
header: []hpack.HeaderField{
|
||||
pair("via", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.header.Get("Via"), "bar, 1.1 nghttpx"; got != want {
|
||||
t.Errorf("Via: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1NoVia tests that server does not add value to existing Via
|
||||
// header field to and from backend server.
|
||||
func TestS3H1NoVia(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--no-via"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, want := r.Header.Get("Via"), "foo"; got != want {
|
||||
t.Errorf("Via: %v; want %v", got, want)
|
||||
}
|
||||
w.Header().Add("Via", "bar")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1NoVia",
|
||||
header: []hpack.HeaderField{
|
||||
pair("via", "foo"),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.header.Get("Via"), "bar"; got != want {
|
||||
t.Errorf("Via: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1HeaderFieldBuffer tests that request with header fields
|
||||
// larger than configured buffer size is rejected.
|
||||
func TestS3H1HeaderFieldBuffer(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--header-field-buffer=10"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1HeaderFieldBuffer",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.spdyRstErrCode, spdy.InternalError; got != want {
|
||||
t.Errorf("res.spdyRstErrCode: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1HeaderFields tests that request with header fields more
|
||||
// than configured number is rejected.
|
||||
func TestS3H1HeaderFields(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--max-header-fields=1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("execution path should not be here")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1HeaderFields",
|
||||
// we have at least 5 pseudo-header fields sent, and
|
||||
// that ensures that buffer limit exceeds.
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.spdyRstErrCode, spdy.InternalError; got != want {
|
||||
t.Errorf("res.spdyRstErrCode: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1InvalidMethod tests that server rejects invalid method with
|
||||
// 501.
|
||||
func TestS3H1InvalidMethod(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Errorf("server should not forward this request")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1InvalidMethod",
|
||||
method: "get",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 501; got != want {
|
||||
t.Errorf("status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1BadHost tests that server rejects request including bad
|
||||
// character in :host header field.
|
||||
func TestS3H1BadHost(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Errorf("server should not forward this request")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1BadHost",
|
||||
authority: `foo\bar`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 400; got != want {
|
||||
t.Errorf("status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1BadScheme tests that server rejects request including bad
|
||||
// character in :scheme header field.
|
||||
func TestS3H1BadScheme(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Errorf("server should not forward this request")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1BadScheme",
|
||||
scheme: `http*`,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 400; got != want {
|
||||
t.Errorf("status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1ReqPhaseSetHeader tests mruby request phase hook
|
||||
// modifies request header fields.
|
||||
func TestS3H1ReqPhaseSetHeader(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--mruby-file=" + testDir + "/req-set-header.rb"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if got, want := r.Header.Get("User-Agent"), "mruby"; got != want {
|
||||
t.Errorf("User-Agent = %v; want %v", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1ReqPhaseSetHeader",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1ReqPhaseReturn tests mruby request phase hook returns
|
||||
// custom response.
|
||||
func TestS3H1ReqPhaseReturn(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--mruby-file=" + testDir + "/req-return.rb"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1ReqPhaseReturn",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 404; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
hdtests := []struct {
|
||||
k, v string
|
||||
}{
|
||||
{"content-length", "20"},
|
||||
{"from", "mruby"},
|
||||
}
|
||||
for _, tt := range hdtests {
|
||||
if got, want := res.header.Get(tt.k), tt.v; got != want {
|
||||
t.Errorf("%v = %v; want %v", tt.k, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
if got, want := string(res.body), "Hello World from req"; got != want {
|
||||
t.Errorf("body = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1RespPhaseSetHeader tests mruby response phase hook modifies
|
||||
// response header fields.
|
||||
func TestS3H1RespPhaseSetHeader(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--mruby-file=" + testDir + "/resp-set-header.rb"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1RespPhaseSetHeader",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
if got, want := res.header.Get("alpha"), "bravo"; got != want {
|
||||
t.Errorf("alpha = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H1RespPhaseReturn tests mruby response phase hook returns
|
||||
// custom response.
|
||||
func TestS3H1RespPhaseReturn(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--mruby-file=" + testDir + "/resp-return.rb"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H1RespPhaseReturn",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 404; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
hdtests := []struct {
|
||||
k, v string
|
||||
}{
|
||||
{"content-length", "21"},
|
||||
{"from", "mruby"},
|
||||
}
|
||||
for _, tt := range hdtests {
|
||||
if got, want := res.header.Get(tt.k), tt.v; got != want {
|
||||
t.Errorf("%v = %v; want %v", tt.k, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
if got, want := string(res.body), "Hello World from resp"; got != want {
|
||||
t.Errorf("body = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// // TestS3H2ConnectFailure tests that server handles the situation that
|
||||
// // connection attempt to HTTP/2 backend failed.
|
||||
// func TestS3H2ConnectFailure(t *testing.T) {
|
||||
// st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--http2-bridge"}, t, noopHandler)
|
||||
// defer st.Close()
|
||||
|
||||
// // simulate backend connect attempt failure
|
||||
// st.ts.Close()
|
||||
|
||||
// res, err := st.spdy(requestParam{
|
||||
// name: "TestS3H2ConnectFailure",
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.Fatalf("Error st.spdy() = %v", err)
|
||||
// }
|
||||
// want := 503
|
||||
// if got := res.status; got != want {
|
||||
// t.Errorf("status: %v; want %v", got, want)
|
||||
// }
|
||||
// }
|
||||
|
||||
// TestS3H2ReqPhaseReturn tests mruby request phase hook returns
|
||||
// custom response.
|
||||
func TestS3H2ReqPhaseReturn(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--http2-bridge", "--mruby-file=" + testDir + "/req-return.rb"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H2ReqPhaseReturn",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 404; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
hdtests := []struct {
|
||||
k, v string
|
||||
}{
|
||||
{"content-length", "20"},
|
||||
{"from", "mruby"},
|
||||
}
|
||||
for _, tt := range hdtests {
|
||||
if got, want := res.header.Get(tt.k), tt.v; got != want {
|
||||
t.Errorf("%v = %v; want %v", tt.k, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
if got, want := string(res.body), "Hello World from req"; got != want {
|
||||
t.Errorf("body = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3H2RespPhaseReturn tests mruby response phase hook returns
|
||||
// custom response.
|
||||
func TestS3H2RespPhaseReturn(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--http2-bridge", "--mruby-file=" + testDir + "/resp-return.rb"}, t, noopHandler)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3H2RespPhaseReturn",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
|
||||
if got, want := res.status, 404; got != want {
|
||||
t.Errorf("status = %v; want %v", got, want)
|
||||
}
|
||||
|
||||
hdtests := []struct {
|
||||
k, v string
|
||||
}{
|
||||
{"content-length", "21"},
|
||||
{"from", "mruby"},
|
||||
}
|
||||
for _, tt := range hdtests {
|
||||
if got, want := res.header.Get(tt.k), tt.v; got != want {
|
||||
t.Errorf("%v = %v; want %v", tt.k, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
if got, want := string(res.body), "Hello World from resp"; got != want {
|
||||
t.Errorf("body = %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3APIBackendconfig exercise backendconfig API endpoint routine
|
||||
// for successful case.
|
||||
func TestS3APIBackendconfig(t *testing.T) {
|
||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3010)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3APIBackendconfig",
|
||||
path: "/api/v1beta1/backendconfig",
|
||||
method: "PUT",
|
||||
body: []byte(`# comment
|
||||
backend=127.0.0.1,3011
|
||||
|
||||
`),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
|
||||
var apiResp APIResponse
|
||||
err = json.Unmarshal(res.body, &apiResp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshaling API response: %v", err)
|
||||
}
|
||||
if got, want := apiResp.Status, "Success"; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Code, 200; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3APIBackendconfigQuery exercise backendconfig API endpoint
|
||||
// routine with query.
|
||||
func TestS3APIBackendconfigQuery(t *testing.T) {
|
||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3010)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3APIBackendconfigQuery",
|
||||
path: "/api/v1beta1/backendconfig?foo=bar",
|
||||
method: "PUT",
|
||||
body: []byte(`# comment
|
||||
backend=127.0.0.1,3011
|
||||
|
||||
`),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
|
||||
var apiResp APIResponse
|
||||
err = json.Unmarshal(res.body, &apiResp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshaling API response: %v", err)
|
||||
}
|
||||
if got, want := apiResp.Status, "Success"; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Code, 200; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3APIBackendconfigBadMethod exercise backendconfig API endpoint
|
||||
// routine with bad method.
|
||||
func TestS3APIBackendconfigBadMethod(t *testing.T) {
|
||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3010)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3APIBackendconfigBadMethod",
|
||||
path: "/api/v1beta1/backendconfig",
|
||||
method: "GET",
|
||||
body: []byte(`# comment
|
||||
backend=127.0.0.1,3011
|
||||
|
||||
`),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 405; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
|
||||
var apiResp APIResponse
|
||||
err = json.Unmarshal(res.body, &apiResp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshaling API response: %v", err)
|
||||
}
|
||||
if got, want := apiResp.Status, "Failure"; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Code, 405; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3APINotFound exercise backendconfig API endpoint routine when
|
||||
// API endpoint is not found.
|
||||
func TestS3APINotFound(t *testing.T) {
|
||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3010)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3APINotFound",
|
||||
path: "/api/notfound",
|
||||
method: "GET",
|
||||
body: []byte(`# comment
|
||||
backend=127.0.0.1,3011
|
||||
|
||||
`),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 404; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
|
||||
var apiResp APIResponse
|
||||
err = json.Unmarshal(res.body, &apiResp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshaling API response: %v", err)
|
||||
}
|
||||
if got, want := apiResp.Status, "Failure"; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
if got, want := apiResp.Code, 404; got != want {
|
||||
t.Errorf("apiResp.Status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3Healthmon tests health monitor endpoint.
|
||||
func TestS3Healthmon(t *testing.T) {
|
||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3011;healthmon"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatalf("request should not be forwarded")
|
||||
}, 3011)
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3Healthmon",
|
||||
path: "/alpha/bravo",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 200; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestS3ResponseBeforeRequestEnd tests the situation where response
|
||||
// ends before request body finishes.
|
||||
func TestS3ResponseBeforeRequestEnd(t *testing.T) {
|
||||
st := newServerTesterTLS([]string{"--npn-list=spdy/3.1", "--mruby-file=" + testDir + "/req-return.rb"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Fatal("request should not be forwarded")
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
res, err := st.spdy(requestParam{
|
||||
name: "TestS3ResponseBeforeRequestEnd",
|
||||
noEndStream: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Error st.spdy() = %v", err)
|
||||
}
|
||||
if got, want := res.status, 404; got != want {
|
||||
t.Errorf("res.status: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/tatsuhiro-t/go-nghttp2"
|
||||
"github.com/tatsuhiro-t/spdy"
|
||||
"golang.org/x/net/http2"
|
||||
"golang.org/x/net/http2/hpack"
|
||||
"golang.org/x/net/websocket"
|
||||
@@ -17,6 +16,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -52,14 +52,12 @@ type serverTester struct {
|
||||
h2PrefaceSent bool // HTTP/2 preface was sent in conn
|
||||
nextStreamID uint32 // next stream ID
|
||||
fr *http2.Framer // HTTP/2 framer
|
||||
spdyFr *spdy.Framer // SPDY/3.1 framer
|
||||
headerBlkBuf bytes.Buffer // buffer to store encoded header block
|
||||
enc *hpack.Encoder // HTTP/2 HPACK encoder
|
||||
header http.Header // received header fields
|
||||
dec *hpack.Decoder // HTTP/2 HPACK decoder
|
||||
authority string // server's host:port
|
||||
frCh chan http2.Frame // used for incoming HTTP/2 frame
|
||||
spdyFrCh chan spdy.Frame // used for incoming SPDY frame
|
||||
errCh chan error
|
||||
}
|
||||
|
||||
@@ -100,10 +98,8 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
|
||||
args := []string{}
|
||||
|
||||
backendTLS := false
|
||||
dns := false
|
||||
externalDNS := false
|
||||
acceptProxyProtocol := false
|
||||
var backendTLS, dns, externalDNS, acceptProxyProtocol, redirectIfNotTLS, affinityCookie, alpnH1 bool
|
||||
|
||||
for _, k := range src_args {
|
||||
switch k {
|
||||
case "--http2-bridge":
|
||||
@@ -115,6 +111,12 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
externalDNS = true
|
||||
case "--accept-proxy-protocol":
|
||||
acceptProxyProtocol = true
|
||||
case "--redirect-if-not-tls":
|
||||
redirectIfNotTLS = true
|
||||
case "--affinity-cookie":
|
||||
affinityCookie = true
|
||||
case "--alpn-h1":
|
||||
alpnH1 = true
|
||||
default:
|
||||
args = append(args, k)
|
||||
}
|
||||
@@ -152,8 +154,8 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
if sep == -1 {
|
||||
t.Fatalf("backendURL.Host %v does not contain separator ':'", backendURL.Host)
|
||||
}
|
||||
// We use awesome service xip.io.
|
||||
b += fmt.Sprintf("%v.xip.io,%v;", backendURL.Host[:sep], backendURL.Host[sep+1:])
|
||||
// We use awesome service nip.io.
|
||||
b += fmt.Sprintf("%v.nip.io,%v;", backendURL.Host[:sep], backendURL.Host[sep+1:])
|
||||
}
|
||||
|
||||
if backendTLS {
|
||||
@@ -163,6 +165,14 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
b += ";dns"
|
||||
}
|
||||
|
||||
if redirectIfNotTLS {
|
||||
b += ";redirect-if-not-tls"
|
||||
}
|
||||
|
||||
if affinityCookie {
|
||||
b += ";affinity=cookie;affinity-cookie-name=affinity;affinity-cookie-path=/foo/bar"
|
||||
}
|
||||
|
||||
noTLS := ";no-tls"
|
||||
if frontendTLS {
|
||||
noTLS = ""
|
||||
@@ -188,10 +198,12 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
nextStreamID: 1,
|
||||
authority: authority,
|
||||
frCh: make(chan http2.Frame),
|
||||
spdyFrCh: make(chan spdy.Frame),
|
||||
errCh: make(chan error),
|
||||
}
|
||||
|
||||
st.cmd.Stdout = os.Stdout
|
||||
st.cmd.Stderr = os.Stderr
|
||||
|
||||
if err := st.cmd.Start(); err != nil {
|
||||
st.t.Fatalf("Error starting %v: %v", serverBin, err)
|
||||
}
|
||||
@@ -210,7 +222,11 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
tlsConfig = clientConfig
|
||||
}
|
||||
tlsConfig.InsecureSkipVerify = true
|
||||
tlsConfig.NextProtos = []string{"h2", "spdy/3.1"}
|
||||
if alpnH1 {
|
||||
tlsConfig.NextProtos = []string{"http/1.1"}
|
||||
} else {
|
||||
tlsConfig.NextProtos = []string{"h2"}
|
||||
}
|
||||
conn, err = tls.Dial("tcp", authority, tlsConfig)
|
||||
} else {
|
||||
conn, err = net.Dial("tcp", authority)
|
||||
@@ -236,12 +252,6 @@ func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handl
|
||||
}
|
||||
|
||||
st.fr = http2.NewFramer(st.conn, st.conn)
|
||||
spdyFr, err := spdy.NewFramer(st.conn, st.conn)
|
||||
if err != nil {
|
||||
st.Close()
|
||||
st.t.Fatalf("Error spdy.NewFramer: %v", err)
|
||||
}
|
||||
st.spdyFr = spdyFr
|
||||
st.enc = hpack.NewEncoder(&st.headerBlkBuf)
|
||||
st.dec = hpack.NewDecoder(4096, func(f hpack.HeaderField) {
|
||||
st.header.Add(f.Name, f.Value)
|
||||
@@ -258,7 +268,7 @@ func (st *serverTester) Close() {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
st.cmd.Wait()
|
||||
done <- struct{}{}
|
||||
close(done)
|
||||
}()
|
||||
|
||||
st.cmd.Process.Signal(syscall.SIGQUIT)
|
||||
@@ -295,26 +305,6 @@ func (st *serverTester) readFrame() (http2.Frame, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (st *serverTester) readSpdyFrame() (spdy.Frame, error) {
|
||||
go func() {
|
||||
f, err := st.spdyFr.ReadFrame()
|
||||
if err != nil {
|
||||
st.errCh <- err
|
||||
return
|
||||
}
|
||||
st.spdyFrCh <- f
|
||||
}()
|
||||
|
||||
select {
|
||||
case f := <-st.spdyFrCh:
|
||||
return f, nil
|
||||
case err := <-st.errCh:
|
||||
return nil, err
|
||||
case <-time.After(2 * time.Second):
|
||||
return nil, errors.New("timeout waiting for frame")
|
||||
}
|
||||
}
|
||||
|
||||
type requestParam struct {
|
||||
name string // name for this request to identify the request in log easily
|
||||
streamID uint32 // stream ID, automatically assigned if 0
|
||||
@@ -455,122 +445,6 @@ func (st *serverTester) http1(rp requestParam) (*serverResponse, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (st *serverTester) spdy(rp requestParam) (*serverResponse, error) {
|
||||
res := &serverResponse{}
|
||||
|
||||
var id spdy.StreamId
|
||||
if rp.streamID != 0 {
|
||||
id = spdy.StreamId(rp.streamID)
|
||||
if id >= spdy.StreamId(st.nextStreamID) && id%2 == 1 {
|
||||
st.nextStreamID = uint32(id) + 2
|
||||
}
|
||||
} else {
|
||||
id = spdy.StreamId(st.nextStreamID)
|
||||
st.nextStreamID += 2
|
||||
}
|
||||
|
||||
method := "GET"
|
||||
if rp.method != "" {
|
||||
method = rp.method
|
||||
}
|
||||
|
||||
scheme := "http"
|
||||
if rp.scheme != "" {
|
||||
scheme = rp.scheme
|
||||
}
|
||||
|
||||
host := st.authority
|
||||
if rp.authority != "" {
|
||||
host = rp.authority
|
||||
}
|
||||
|
||||
path := "/"
|
||||
if rp.path != "" {
|
||||
path = rp.path
|
||||
}
|
||||
|
||||
header := make(http.Header)
|
||||
header.Add(":method", method)
|
||||
header.Add(":scheme", scheme)
|
||||
header.Add(":host", host)
|
||||
header.Add(":path", path)
|
||||
header.Add(":version", "HTTP/1.1")
|
||||
header.Add("test-case", rp.name)
|
||||
for _, h := range rp.header {
|
||||
header.Add(h.Name, h.Value)
|
||||
}
|
||||
|
||||
var synStreamFlags spdy.ControlFlags
|
||||
if len(rp.body) == 0 && !rp.noEndStream {
|
||||
synStreamFlags = spdy.ControlFlagFin
|
||||
}
|
||||
if err := st.spdyFr.WriteFrame(&spdy.SynStreamFrame{
|
||||
CFHeader: spdy.ControlFrameHeader{
|
||||
Flags: synStreamFlags,
|
||||
},
|
||||
StreamId: id,
|
||||
Headers: header,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(rp.body) != 0 {
|
||||
var dataFlags spdy.DataFlags
|
||||
if !rp.noEndStream {
|
||||
dataFlags = spdy.DataFlagFin
|
||||
}
|
||||
if err := st.spdyFr.WriteFrame(&spdy.DataFrame{
|
||||
StreamId: id,
|
||||
Flags: dataFlags,
|
||||
Data: rp.body,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
loop:
|
||||
for {
|
||||
fr, err := st.readSpdyFrame()
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
switch f := fr.(type) {
|
||||
case *spdy.SynReplyFrame:
|
||||
if f.StreamId != id {
|
||||
break
|
||||
}
|
||||
res.header = cloneHeader(f.Headers)
|
||||
if _, err := fmt.Sscan(res.header.Get(":status"), &res.status); err != nil {
|
||||
return res, fmt.Errorf("Error parsing status code: %v", err)
|
||||
}
|
||||
if f.CFHeader.Flags&spdy.ControlFlagFin != 0 {
|
||||
break loop
|
||||
}
|
||||
case *spdy.DataFrame:
|
||||
if f.StreamId != id {
|
||||
break
|
||||
}
|
||||
res.body = append(res.body, f.Data...)
|
||||
if f.Flags&spdy.DataFlagFin != 0 {
|
||||
break loop
|
||||
}
|
||||
case *spdy.RstStreamFrame:
|
||||
if f.StreamId != id {
|
||||
break
|
||||
}
|
||||
res.spdyRstErrCode = f.Status
|
||||
break loop
|
||||
case *spdy.GoAwayFrame:
|
||||
if f.Status == spdy.GoAwayOK {
|
||||
break
|
||||
}
|
||||
res.spdyGoAwayErrCode = f.Status
|
||||
break loop
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (st *serverTester) http2(rp requestParam) (*serverResponse, error) {
|
||||
st.headerBlkBuf.Reset()
|
||||
st.header = make(http.Header)
|
||||
@@ -759,9 +633,7 @@ type serverResponse struct {
|
||||
streamID uint32 // stream ID in HTTP/2
|
||||
errCode http2.ErrCode // error code received in HTTP/2 RST_STREAM or GOAWAY
|
||||
connErr bool // true if HTTP/2 connection error
|
||||
spdyGoAwayErrCode spdy.GoAwayStatus // status code received in SPDY RST_STREAM
|
||||
spdyRstErrCode spdy.RstStreamStatus // status code received in SPDY GOAWAY
|
||||
connClose bool // Conection: close is included in response header in HTTP/1 test
|
||||
connClose bool // Connection: close is included in response header in HTTP/1 test
|
||||
reqHeader http.Header // http request header, currently only sotres pushed request header
|
||||
pushResponse []*serverResponse // pushed response
|
||||
}
|
||||
@@ -793,6 +665,7 @@ func cloneHeader(h http.Header) http.Header {
|
||||
func noopHandler(w http.ResponseWriter, r *http.Request) {}
|
||||
|
||||
type APIResponse struct {
|
||||
Status string `json:"status,omitempty"`
|
||||
Code int `json:"code,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Code int `json:"code,omitempty"`
|
||||
Data map[string]interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
@@ -38,14 +38,25 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
# Public shared library
|
||||
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
|
||||
set_target_properties(nghttp2 PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCFLAGS}"
|
||||
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
|
||||
C_VISIBILITY_PRESET hidden
|
||||
)
|
||||
if(ENABLE_SHARED_LIB)
|
||||
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
|
||||
set_target_properties(nghttp2 PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCFLAGS}"
|
||||
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
|
||||
C_VISIBILITY_PRESET hidden
|
||||
)
|
||||
target_include_directories(nghttp2 INTERFACE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/includes"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
|
||||
)
|
||||
|
||||
if(HAVE_CUNIT)
|
||||
install(TARGETS nghttp2
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
|
||||
if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
|
||||
# Static library (for unittests because of symbol visibility)
|
||||
add_library(nghttp2_static STATIC ${NGHTTP2_SOURCES})
|
||||
set_target_properties(nghttp2_static PROPERTIES
|
||||
@@ -54,10 +65,12 @@ if(HAVE_CUNIT)
|
||||
ARCHIVE_OUTPUT_NAME nghttp2
|
||||
)
|
||||
target_compile_definitions(nghttp2_static PUBLIC "-DNGHTTP2_STATICLIB")
|
||||
if(ENABLE_STATIC_LIB)
|
||||
install(TARGETS nghttp2_static
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS nghttp2
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
@@ -62,7 +62,7 @@ AR := lib
|
||||
#LD := xilink
|
||||
#AR := xilib
|
||||
RC := rc
|
||||
CFLAGS := -I./includes -Dssize_t=long -D_U_=""
|
||||
CFLAGS := -I./includes -Dssize_t=long
|
||||
|
||||
CFLAGS_R := -nologo -MD -W3 -Z7 -DBUILDING_NGHTTP2
|
||||
CFLAGS_D := -nologo -MDd -W3 -Z7 -DBUILDING_NGHTTP2 \
|
||||
|
||||
@@ -28,7 +28,12 @@
|
||||
/* Define WIN32 when build target is Win32 API (borrowed from
|
||||
libcurl) */
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
#define WIN32
|
||||
# define WIN32
|
||||
#endif
|
||||
|
||||
/* Compatibility for non-Clang compilers */
|
||||
#ifndef __has_declspec_attribute
|
||||
# define __has_declspec_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -40,9 +45,9 @@ extern "C" {
|
||||
/* MSVC < 2013 does not have inttypes.h because it is not C99
|
||||
compliant. See compiler macros and version number in
|
||||
https://sourceforge.net/p/predef/wiki/Compilers/ */
|
||||
#include <stdint.h>
|
||||
# include <stdint.h>
|
||||
#else /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
|
||||
#include <inttypes.h>
|
||||
# include <inttypes.h>
|
||||
#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
@@ -50,20 +55,21 @@ extern "C" {
|
||||
#include <nghttp2/nghttp2ver.h>
|
||||
|
||||
#ifdef NGHTTP2_STATICLIB
|
||||
#define NGHTTP2_EXTERN
|
||||
#elif defined(WIN32)
|
||||
#ifdef BUILDING_NGHTTP2
|
||||
#define NGHTTP2_EXTERN __declspec(dllexport)
|
||||
#else /* !BUILDING_NGHTTP2 */
|
||||
#define NGHTTP2_EXTERN __declspec(dllimport)
|
||||
#endif /* !BUILDING_NGHTTP2 */
|
||||
#else /* !defined(WIN32) */
|
||||
#ifdef BUILDING_NGHTTP2
|
||||
#define NGHTTP2_EXTERN __attribute__((visibility("default")))
|
||||
#else /* !BUILDING_NGHTTP2 */
|
||||
#define NGHTTP2_EXTERN
|
||||
#endif /* !BUILDING_NGHTTP2 */
|
||||
#endif /* !defined(WIN32) */
|
||||
# define NGHTTP2_EXTERN
|
||||
#elif defined(WIN32) || (__has_declspec_attribute(dllexport) && \
|
||||
__has_declspec_attribute(dllimport))
|
||||
# ifdef BUILDING_NGHTTP2
|
||||
# define NGHTTP2_EXTERN __declspec(dllexport)
|
||||
# else /* !BUILDING_NGHTTP2 */
|
||||
# define NGHTTP2_EXTERN __declspec(dllimport)
|
||||
# endif /* !BUILDING_NGHTTP2 */
|
||||
#else /* !defined(WIN32) */
|
||||
# ifdef BUILDING_NGHTTP2
|
||||
# define NGHTTP2_EXTERN __attribute__((visibility("default")))
|
||||
# else /* !BUILDING_NGHTTP2 */
|
||||
# define NGHTTP2_EXTERN
|
||||
# endif /* !BUILDING_NGHTTP2 */
|
||||
#endif /* !defined(WIN32) */
|
||||
|
||||
/**
|
||||
* @macro
|
||||
@@ -387,6 +393,11 @@ typedef enum {
|
||||
* Indicates that a processing was canceled.
|
||||
*/
|
||||
NGHTTP2_ERR_CANCEL = -535,
|
||||
/**
|
||||
* When a local endpoint expects to receive SETTINGS frame, it
|
||||
* receives an other type of frame.
|
||||
*/
|
||||
NGHTTP2_ERR_SETTINGS_EXPECTED = -536,
|
||||
/**
|
||||
* The errors < :enum:`NGHTTP2_ERR_FATAL` mean that the library is
|
||||
* under unexpected condition and processing was terminated (e.g.,
|
||||
@@ -469,6 +480,15 @@ NGHTTP2_EXTERN void nghttp2_rcbuf_decref(nghttp2_rcbuf *rcbuf);
|
||||
*/
|
||||
NGHTTP2_EXTERN nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Returns nonzero if the underlying buffer is statically allocated,
|
||||
* and 0 otherwise. This can be useful for language bindings that wish
|
||||
* to avoid creating duplicate strings for these buffers.
|
||||
*/
|
||||
NGHTTP2_EXTERN int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf);
|
||||
|
||||
/**
|
||||
* @enum
|
||||
*
|
||||
@@ -597,7 +617,12 @@ typedef enum {
|
||||
* The ALTSVC frame, which is defined in `RFC 7383
|
||||
* <https://tools.ietf.org/html/rfc7838#section-4>`_.
|
||||
*/
|
||||
NGHTTP2_ALTSVC = 0x0a
|
||||
NGHTTP2_ALTSVC = 0x0a,
|
||||
/**
|
||||
* The ORIGIN frame, which is defined by `RFC 8336
|
||||
* <https://tools.ietf.org/html/rfc8336>`_.
|
||||
*/
|
||||
NGHTTP2_ORIGIN = 0x0c
|
||||
} nghttp2_frame_type;
|
||||
|
||||
/**
|
||||
@@ -661,7 +686,12 @@ typedef enum {
|
||||
/**
|
||||
* SETTINGS_MAX_HEADER_LIST_SIZE
|
||||
*/
|
||||
NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06
|
||||
NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06,
|
||||
/**
|
||||
* SETTINGS_ENABLE_CONNECT_PROTOCOL
|
||||
* (`RFC 8441 <https://tools.ietf.org/html/rfc8441>`_)
|
||||
*/
|
||||
NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08
|
||||
} nghttp2_settings_id;
|
||||
/* Note: If we add SETTINGS, update the capacity of
|
||||
NGHTTP2_INBOUND_NUM_IV as well */
|
||||
@@ -1741,11 +1771,12 @@ typedef int (*nghttp2_on_header_callback2)(nghttp2_session *session,
|
||||
* The parameter and behaviour are similar to
|
||||
* :type:`nghttp2_on_header_callback`. The difference is that this
|
||||
* callback is only invoked when a invalid header name/value pair is
|
||||
* received which is silently ignored if this callback is not set.
|
||||
* Only invalid regular header field are passed to this callback. In
|
||||
* other words, invalid pseudo header field is not passed to this
|
||||
* callback. Also header fields which includes upper cased latter are
|
||||
* also treated as error without passing them to this callback.
|
||||
* received which is treated as stream error if this callback is not
|
||||
* set. Only invalid regular header field are passed to this
|
||||
* callback. In other words, invalid pseudo header field is not
|
||||
* passed to this callback. Also header fields which includes upper
|
||||
* cased latter are also treated as error without passing them to this
|
||||
* callback.
|
||||
*
|
||||
* This callback is only considered if HTTP messaging validation is
|
||||
* turned on (which is on by default, see
|
||||
@@ -1754,10 +1785,13 @@ typedef int (*nghttp2_on_header_callback2)(nghttp2_session *session,
|
||||
* With this callback, application inspects the incoming invalid
|
||||
* field, and it also can reset stream from this callback by returning
|
||||
* :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. By default, the
|
||||
* error code is :enum:`NGHTTP2_INTERNAL_ERROR`. To change the error
|
||||
* error code is :enum:`NGHTTP2_PROTOCOL_ERROR`. To change the error
|
||||
* code, call `nghttp2_submit_rst_stream()` with the error code of
|
||||
* choice in addition to returning
|
||||
* :enum:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`.
|
||||
*
|
||||
* If 0 is returned, the header field is ignored, and the stream is
|
||||
* not reset.
|
||||
*/
|
||||
typedef int (*nghttp2_on_invalid_header_callback)(
|
||||
nghttp2_session *session, const nghttp2_frame *frame, const uint8_t *name,
|
||||
@@ -1974,6 +2008,9 @@ typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session,
|
||||
* of length |len|. |len| does not include the sentinel NULL
|
||||
* character.
|
||||
*
|
||||
* This function is deprecated. The new application should use
|
||||
* :type:`nghttp2_error_callback2`.
|
||||
*
|
||||
* The format of error message may change between nghttp2 library
|
||||
* versions. The application should not depend on the particular
|
||||
* format.
|
||||
@@ -1990,6 +2027,33 @@ typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session,
|
||||
typedef int (*nghttp2_error_callback)(nghttp2_session *session, const char *msg,
|
||||
size_t len, void *user_data);
|
||||
|
||||
/**
|
||||
* @functypedef
|
||||
*
|
||||
* Callback function invoked when library provides the error code, and
|
||||
* message. This callback is solely for debugging purpose.
|
||||
* |lib_error_code| is one of error code defined in
|
||||
* :enum:`nghttp2_error`. The |msg| is typically NULL-terminated
|
||||
* string of length |len|, and intended for human consumption. |len|
|
||||
* does not include the sentinel NULL character.
|
||||
*
|
||||
* The format of error message may change between nghttp2 library
|
||||
* versions. The application should not depend on the particular
|
||||
* format.
|
||||
*
|
||||
* Normally, application should return 0 from this callback. If fatal
|
||||
* error occurred while doing something in this callback, application
|
||||
* should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
|
||||
* library will return immediately with return value
|
||||
* :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if nonzero value
|
||||
* is returned from this callback, they are treated as
|
||||
* :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, but application should not
|
||||
* rely on this details.
|
||||
*/
|
||||
typedef int (*nghttp2_error_callback2)(nghttp2_session *session,
|
||||
int lib_error_code, const char *msg,
|
||||
size_t len, void *user_data);
|
||||
|
||||
struct nghttp2_session_callbacks;
|
||||
|
||||
/**
|
||||
@@ -2254,10 +2318,30 @@ nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(
|
||||
*
|
||||
* Sets callback function invoked when library tells error message to
|
||||
* the application.
|
||||
*
|
||||
* This function is deprecated. The new application should use
|
||||
* `nghttp2_session_callbacks_set_error_callback2()`.
|
||||
*
|
||||
* If both :type:`nghttp2_error_callback` and
|
||||
* :type:`nghttp2_error_callback2` are set, the latter takes
|
||||
* precedence.
|
||||
*/
|
||||
NGHTTP2_EXTERN void nghttp2_session_callbacks_set_error_callback(
|
||||
nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Sets callback function invoked when library tells error code, and
|
||||
* message to the application.
|
||||
*
|
||||
* If both :type:`nghttp2_error_callback` and
|
||||
* :type:`nghttp2_error_callback2` are set, the latter takes
|
||||
* precedence.
|
||||
*/
|
||||
NGHTTP2_EXTERN void nghttp2_session_callbacks_set_error_callback2(
|
||||
nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2);
|
||||
|
||||
/**
|
||||
* @functypedef
|
||||
*
|
||||
@@ -2405,15 +2489,15 @@ nghttp2_option_set_no_auto_window_update(nghttp2_option *option, int val);
|
||||
*
|
||||
* This option sets the SETTINGS_MAX_CONCURRENT_STREAMS value of
|
||||
* remote endpoint as if it is received in SETTINGS frame. Without
|
||||
* specifying this option, before the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS in SETTINGS frame from remote
|
||||
* endpoint, SETTINGS_MAX_CONCURRENT_STREAMS is unlimited. This may
|
||||
* cause problem if local endpoint submits lots of requests initially
|
||||
* and sending them at once to the remote peer may lead to the
|
||||
* rejection of some requests. Specifying this option to the sensible
|
||||
* value, say 100, may avoid this kind of issue. This value will be
|
||||
* overwritten if the local endpoint receives
|
||||
* SETTINGS_MAX_CONCURRENT_STREAMS from the remote endpoint.
|
||||
* specifying this option, the maximum number of outgoing concurrent
|
||||
* streams is initially limited to 100 to avoid issues when the local
|
||||
* endpoint submits lots of requests before receiving initial SETTINGS
|
||||
* frame from the remote endpoint, since sending them at once to the
|
||||
* remote endpoint could lead to rejection of some of the requests.
|
||||
* This value will be overwritten when the local endpoint receives
|
||||
* initial SETTINGS frame from the remote endpoint, either to the
|
||||
* value advertised in SETTINGS_MAX_CONCURRENT_STREAMS or to the
|
||||
* default value (unlimited) if none was advertised.
|
||||
*/
|
||||
NGHTTP2_EXTERN void
|
||||
nghttp2_option_set_peer_max_concurrent_streams(nghttp2_option *option,
|
||||
@@ -2448,7 +2532,10 @@ nghttp2_option_set_no_recv_client_magic(nghttp2_option *option, int val);
|
||||
* <https://tools.ietf.org/html/rfc7540#section-8>`_. See
|
||||
* :ref:`http-messaging` section for details. For those applications
|
||||
* who use nghttp2 library as non-HTTP use, give nonzero to |val| to
|
||||
* disable this enforcement.
|
||||
* disable this enforcement. Please note that disabling this feature
|
||||
* does not change the fundamental client and server model of HTTP.
|
||||
* That is, even if the validation is disabled, only client can send
|
||||
* requests.
|
||||
*/
|
||||
NGHTTP2_EXTERN void nghttp2_option_set_no_http_messaging(nghttp2_option *option,
|
||||
int val);
|
||||
@@ -2551,6 +2638,16 @@ NGHTTP2_EXTERN void
|
||||
nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option,
|
||||
size_t val);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* This option prevents the library from retaining closed streams to
|
||||
* maintain the priority tree. If this option is set to nonzero,
|
||||
* applications can discard closed stream completely to save memory.
|
||||
*/
|
||||
NGHTTP2_EXTERN void nghttp2_option_set_no_closed_streams(nghttp2_option *option,
|
||||
int val);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
@@ -3000,6 +3097,16 @@ NGHTTP2_EXTERN int
|
||||
nghttp2_session_set_stream_user_data(nghttp2_session *session,
|
||||
int32_t stream_id, void *stream_user_data);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Sets |user_data| to |session|, overwriting the existing user data
|
||||
* specified in `nghttp2_session_client_new()`, or
|
||||
* `nghttp2_session_server_new()`.
|
||||
*/
|
||||
NGHTTP2_EXTERN void nghttp2_session_set_user_data(nghttp2_session *session,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
@@ -3706,10 +3813,13 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
|
||||
* .. warning::
|
||||
*
|
||||
* This function returns assigned stream ID if it succeeds. But
|
||||
* that stream is not opened yet. The application must not submit
|
||||
* that stream is not created yet. The application must not submit
|
||||
* frame to that stream ID before
|
||||
* :type:`nghttp2_before_frame_send_callback` is called for this
|
||||
* frame.
|
||||
* frame. This means `nghttp2_session_get_stream_user_data()` does
|
||||
* not work before the callback. But
|
||||
* `nghttp2_session_set_stream_user_data()` handles this situation
|
||||
* specially, and it can set data to a stream during this period.
|
||||
*
|
||||
*/
|
||||
NGHTTP2_EXTERN int32_t nghttp2_submit_request(
|
||||
@@ -3792,9 +3902,8 @@ nghttp2_submit_response(nghttp2_session *session, int32_t stream_id,
|
||||
* Submits trailer fields HEADERS against the stream |stream_id|.
|
||||
*
|
||||
* The |nva| is an array of name/value pair :type:`nghttp2_nv` with
|
||||
* |nvlen| elements. The application is responsible not to include
|
||||
* pseudo-header fields (header field whose name starts with ":") in
|
||||
* |nva|.
|
||||
* |nvlen| elements. The application must not include pseudo-header
|
||||
* fields (headers whose names starts with ":") in |nva|.
|
||||
*
|
||||
* This function creates copies of all name/value pairs in |nva|. It
|
||||
* also lower-cases all names in |nva|. The order of elements in
|
||||
@@ -4426,8 +4535,7 @@ typedef struct {
|
||||
* Submits ALTSVC frame.
|
||||
*
|
||||
* ALTSVC frame is a non-critical extension to HTTP/2, and defined in
|
||||
* is defined in `RFC 7383
|
||||
* <https://tools.ietf.org/html/rfc7838#section-4>`_.
|
||||
* `RFC 7383 <https://tools.ietf.org/html/rfc7838#section-4>`_.
|
||||
*
|
||||
* The |flags| is currently ignored and should be
|
||||
* :enum:`NGHTTP2_FLAG_NONE`.
|
||||
@@ -4461,6 +4569,81 @@ NGHTTP2_EXTERN int nghttp2_submit_altsvc(nghttp2_session *session,
|
||||
const uint8_t *field_value,
|
||||
size_t field_value_len);
|
||||
|
||||
/**
|
||||
* @struct
|
||||
*
|
||||
* The single entry of an origin.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* The pointer to origin. No validation is made against this field
|
||||
* by the library. This is not necessarily NULL-terminated.
|
||||
*/
|
||||
uint8_t *origin;
|
||||
/**
|
||||
* The length of the |origin|.
|
||||
*/
|
||||
size_t origin_len;
|
||||
} nghttp2_origin_entry;
|
||||
|
||||
/**
|
||||
* @struct
|
||||
*
|
||||
* The payload of ORIGIN frame. ORIGIN frame is a non-critical
|
||||
* extension to HTTP/2 and defined by `RFC 8336
|
||||
* <https://tools.ietf.org/html/rfc8336>`_.
|
||||
*
|
||||
* If this frame is received, and
|
||||
* `nghttp2_option_set_user_recv_extension_type()` is not set, and
|
||||
* `nghttp2_option_set_builtin_recv_extension_type()` is set for
|
||||
* :enum:`NGHTTP2_ORIGIN`, ``nghttp2_extension.payload`` will point to
|
||||
* this struct.
|
||||
*
|
||||
* It has the following members:
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* The number of origins contained in |ov|.
|
||||
*/
|
||||
size_t nov;
|
||||
/**
|
||||
* The pointer to the array of origins contained in ORIGIN frame.
|
||||
*/
|
||||
nghttp2_origin_entry *ov;
|
||||
} nghttp2_ext_origin;
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* Submits ORIGIN frame.
|
||||
*
|
||||
* ORIGIN frame is a non-critical extension to HTTP/2 and defined by
|
||||
* `RFC 8336 <https://tools.ietf.org/html/rfc8336>`_.
|
||||
*
|
||||
* The |flags| is currently ignored and should be
|
||||
* :enum:`NGHTTP2_FLAG_NONE`.
|
||||
*
|
||||
* The |ov| points to the array of origins. The |nov| specifies the
|
||||
* number of origins included in |ov|. This function creates copies
|
||||
* of all elements in |ov|.
|
||||
*
|
||||
* The ORIGIN frame is only usable by a server. If this function is
|
||||
* invoked with client side session, this function returns
|
||||
* :enum:`NGHTTP2_ERR_INVALID_STATE`.
|
||||
*
|
||||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory
|
||||
* :enum:`NGHTTP2_ERR_INVALID_STATE`
|
||||
* The function is called from client side session.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* There are too many origins, or an origin is too large to fit
|
||||
* into a default frame payload.
|
||||
*/
|
||||
NGHTTP2_EXTERN int nghttp2_submit_origin(nghttp2_session *session,
|
||||
uint8_t flags,
|
||||
const nghttp2_origin_entry *ov,
|
||||
size_t nov);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
@@ -4677,8 +4860,8 @@ nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater,
|
||||
*
|
||||
* After this function returns, it is safe to delete the |nva|.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
* This function returns the number of bytes written to |buf| if it
|
||||
* succeeds, or one of the following negative error codes:
|
||||
*
|
||||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory.
|
||||
@@ -4709,8 +4892,8 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater,
|
||||
*
|
||||
* After this function returns, it is safe to delete the |nva|.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
* This function returns the number of bytes written to |vec| if it
|
||||
* succeeds, or one of the following negative error codes:
|
||||
*
|
||||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_BUF_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -398,7 +398,7 @@ int nghttp2_bufs_advance(nghttp2_bufs *bufs);
|
||||
void nghttp2_bufs_seek_last_present(nghttp2_bufs *bufs);
|
||||
|
||||
/*
|
||||
* Returns nonzero if bufs->cur->next is not emtpy.
|
||||
* Returns nonzero if bufs->cur->next is not empty.
|
||||
*/
|
||||
int nghttp2_bufs_next_present(nghttp2_bufs *bufs);
|
||||
|
||||
|
||||
@@ -168,3 +168,8 @@ void nghttp2_session_callbacks_set_error_callback(
|
||||
nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback) {
|
||||
cbs->error_callback = error_callback;
|
||||
}
|
||||
|
||||
void nghttp2_session_callbacks_set_error_callback2(
|
||||
nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2) {
|
||||
cbs->error_callback2 = error_callback2;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_CALLBACKS_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -119,6 +119,7 @@ struct nghttp2_session_callbacks {
|
||||
nghttp2_unpack_extension_callback unpack_extension_callback;
|
||||
nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback;
|
||||
nghttp2_error_callback error_callback;
|
||||
nghttp2_error_callback2 error_callback2;
|
||||
};
|
||||
|
||||
#endif /* NGHTTP2_CALLBACKS_H */
|
||||
|
||||
@@ -53,6 +53,8 @@ void nghttp2_set_debug_vprintf_callback(
|
||||
#else /* !DEBUGBUILD */
|
||||
|
||||
void nghttp2_set_debug_vprintf_callback(
|
||||
nghttp2_debug_vprintf_callback debug_vprintf_callback _U_) {}
|
||||
nghttp2_debug_vprintf_callback debug_vprintf_callback) {
|
||||
(void)debug_vprintf_callback;
|
||||
}
|
||||
|
||||
#endif /* !DEBUGBUILD */
|
||||
|
||||
@@ -26,18 +26,18 @@
|
||||
#define NGHTTP2_DEBUG_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
#define DEBUGF(...) nghttp2_debug_vprintf(__VA_ARGS__)
|
||||
# define DEBUGF(...) nghttp2_debug_vprintf(__VA_ARGS__)
|
||||
void nghttp2_debug_vprintf(const char *format, ...);
|
||||
#else
|
||||
#define DEBUGF(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
# define DEBUGF(...) \
|
||||
do { \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* NGHTTP2_DEBUG_H */
|
||||
|
||||
@@ -87,7 +87,7 @@ void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id,
|
||||
frame->pri_spec = *pri_spec;
|
||||
}
|
||||
|
||||
void nghttp2_frame_priority_free(nghttp2_priority *frame _U_) {}
|
||||
void nghttp2_frame_priority_free(nghttp2_priority *frame) { (void)frame; }
|
||||
|
||||
void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame, int32_t stream_id,
|
||||
uint32_t error_code) {
|
||||
@@ -96,7 +96,7 @@ void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame, int32_t stream_id,
|
||||
frame->error_code = error_code;
|
||||
}
|
||||
|
||||
void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame _U_) {}
|
||||
void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame) { (void)frame; }
|
||||
|
||||
void nghttp2_frame_settings_init(nghttp2_settings *frame, uint8_t flags,
|
||||
nghttp2_settings_entry *iv, size_t niv) {
|
||||
@@ -137,7 +137,7 @@ void nghttp2_frame_ping_init(nghttp2_ping *frame, uint8_t flags,
|
||||
}
|
||||
}
|
||||
|
||||
void nghttp2_frame_ping_free(nghttp2_ping *frame _U_) {}
|
||||
void nghttp2_frame_ping_free(nghttp2_ping *frame) { (void)frame; }
|
||||
|
||||
void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id,
|
||||
uint32_t error_code, uint8_t *opaque_data,
|
||||
@@ -163,7 +163,9 @@ void nghttp2_frame_window_update_init(nghttp2_window_update *frame,
|
||||
frame->reserved = 0;
|
||||
}
|
||||
|
||||
void nghttp2_frame_window_update_free(nghttp2_window_update *frame _U_) {}
|
||||
void nghttp2_frame_window_update_free(nghttp2_window_update *frame) {
|
||||
(void)frame;
|
||||
}
|
||||
|
||||
size_t nghttp2_frame_trail_padlen(nghttp2_frame *frame, size_t padlen) {
|
||||
/* We have iframe->padlen == 0, but iframe->frame.hd.flags may have
|
||||
@@ -183,7 +185,7 @@ void nghttp2_frame_data_init(nghttp2_data *frame, uint8_t flags,
|
||||
frame->padlen = 0;
|
||||
}
|
||||
|
||||
void nghttp2_frame_data_free(nghttp2_data *frame _U_) {}
|
||||
void nghttp2_frame_data_free(nghttp2_data *frame) { (void)frame; }
|
||||
|
||||
void nghttp2_frame_extension_init(nghttp2_extension *frame, uint8_t type,
|
||||
uint8_t flags, int32_t stream_id,
|
||||
@@ -192,7 +194,7 @@ void nghttp2_frame_extension_init(nghttp2_extension *frame, uint8_t type,
|
||||
frame->payload = payload;
|
||||
}
|
||||
|
||||
void nghttp2_frame_extension_free(nghttp2_extension *frame _U_) {}
|
||||
void nghttp2_frame_extension_free(nghttp2_extension *frame) { (void)frame; }
|
||||
|
||||
void nghttp2_frame_altsvc_init(nghttp2_extension *frame, int32_t stream_id,
|
||||
uint8_t *origin, size_t origin_len,
|
||||
@@ -213,11 +215,44 @@ void nghttp2_frame_altsvc_free(nghttp2_extension *frame, nghttp2_mem *mem) {
|
||||
nghttp2_ext_altsvc *altsvc;
|
||||
|
||||
altsvc = frame->payload;
|
||||
if (altsvc == NULL) {
|
||||
return;
|
||||
}
|
||||
/* We use the same buffer for altsvc->origin and
|
||||
altsvc->field_value. */
|
||||
nghttp2_mem_free(mem, altsvc->origin);
|
||||
}
|
||||
|
||||
void nghttp2_frame_origin_init(nghttp2_extension *frame,
|
||||
nghttp2_origin_entry *ov, size_t nov) {
|
||||
nghttp2_ext_origin *origin;
|
||||
size_t payloadlen = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nov; ++i) {
|
||||
payloadlen += 2 + ov[i].origin_len;
|
||||
}
|
||||
|
||||
nghttp2_frame_hd_init(&frame->hd, payloadlen, NGHTTP2_ORIGIN,
|
||||
NGHTTP2_FLAG_NONE, 0);
|
||||
|
||||
origin = frame->payload;
|
||||
origin->ov = ov;
|
||||
origin->nov = nov;
|
||||
}
|
||||
|
||||
void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem) {
|
||||
nghttp2_ext_origin *origin;
|
||||
|
||||
origin = frame->payload;
|
||||
if (origin == NULL) {
|
||||
return;
|
||||
}
|
||||
/* We use the same buffer for all resources pointed by the field of
|
||||
origin directly or indirectly. */
|
||||
nghttp2_mem_free(mem, origin->ov);
|
||||
}
|
||||
|
||||
size_t nghttp2_frame_priority_len(uint8_t flags) {
|
||||
if (flags & NGHTTP2_FLAG_PRIORITY) {
|
||||
return NGHTTP2_PRIORITY_SPECLEN;
|
||||
@@ -346,9 +381,7 @@ void nghttp2_frame_pack_priority_spec(uint8_t *buf,
|
||||
}
|
||||
|
||||
void nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec,
|
||||
uint8_t flags _U_,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen _U_) {
|
||||
const uint8_t *payload) {
|
||||
int32_t dep_stream_id;
|
||||
uint8_t exclusive;
|
||||
int32_t weight;
|
||||
@@ -361,11 +394,9 @@ void nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec,
|
||||
}
|
||||
|
||||
int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen) {
|
||||
const uint8_t *payload) {
|
||||
if (frame->hd.flags & NGHTTP2_FLAG_PRIORITY) {
|
||||
nghttp2_frame_unpack_priority_spec(&frame->pri_spec, frame->hd.flags,
|
||||
payload, payloadlen);
|
||||
nghttp2_frame_unpack_priority_spec(&frame->pri_spec, payload);
|
||||
} else {
|
||||
nghttp2_priority_spec_default_init(&frame->pri_spec);
|
||||
}
|
||||
@@ -397,10 +428,8 @@ int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) {
|
||||
}
|
||||
|
||||
void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen) {
|
||||
nghttp2_frame_unpack_priority_spec(&frame->pri_spec, frame->hd.flags, payload,
|
||||
payloadlen);
|
||||
const uint8_t *payload) {
|
||||
nghttp2_frame_unpack_priority_spec(&frame->pri_spec, payload);
|
||||
}
|
||||
|
||||
int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs,
|
||||
@@ -424,8 +453,7 @@ int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs,
|
||||
}
|
||||
|
||||
void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen _U_) {
|
||||
const uint8_t *payload) {
|
||||
frame->error_code = nghttp2_get_uint32(payload);
|
||||
}
|
||||
|
||||
@@ -540,8 +568,7 @@ int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs,
|
||||
}
|
||||
|
||||
int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen _U_) {
|
||||
const uint8_t *payload) {
|
||||
frame->promised_stream_id =
|
||||
nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK;
|
||||
frame->nva = NULL;
|
||||
@@ -569,8 +596,7 @@ int nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame) {
|
||||
}
|
||||
|
||||
void nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen _U_) {
|
||||
const uint8_t *payload) {
|
||||
memcpy(frame->opaque_data, payload, sizeof(frame->opaque_data));
|
||||
}
|
||||
|
||||
@@ -607,7 +633,6 @@ int nghttp2_frame_pack_goaway(nghttp2_bufs *bufs, nghttp2_goaway *frame) {
|
||||
|
||||
void nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen _U_,
|
||||
uint8_t *var_gift_payload,
|
||||
size_t var_gift_payloadlen) {
|
||||
frame->last_stream_id = nghttp2_get_uint32(payload) & NGHTTP2_STREAM_ID_MASK;
|
||||
@@ -643,8 +668,8 @@ int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame,
|
||||
memcpy(var_gift_payload, payload + 8, var_gift_payloadlen);
|
||||
}
|
||||
|
||||
nghttp2_frame_unpack_goaway_payload(frame, payload, payloadlen,
|
||||
var_gift_payload, var_gift_payloadlen);
|
||||
nghttp2_frame_unpack_goaway_payload(frame, payload, var_gift_payload,
|
||||
var_gift_payloadlen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -670,8 +695,7 @@ int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs,
|
||||
}
|
||||
|
||||
void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen _U_) {
|
||||
const uint8_t *payload) {
|
||||
frame->window_size_increment =
|
||||
nghttp2_get_uint32(payload) & NGHTTP2_WINDOW_SIZE_INCREMENT_MASK;
|
||||
}
|
||||
@@ -681,6 +705,9 @@ int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) {
|
||||
nghttp2_buf *buf;
|
||||
nghttp2_ext_altsvc *altsvc;
|
||||
|
||||
/* This is required with --disable-assert. */
|
||||
(void)rv;
|
||||
|
||||
altsvc = frame->payload;
|
||||
|
||||
buf = &bufs->head->buf;
|
||||
@@ -749,6 +776,106 @@ int nghttp2_frame_unpack_altsvc_payload2(nghttp2_extension *frame,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *frame) {
|
||||
nghttp2_buf *buf;
|
||||
nghttp2_ext_origin *origin;
|
||||
nghttp2_origin_entry *orig;
|
||||
size_t i;
|
||||
|
||||
origin = frame->payload;
|
||||
|
||||
buf = &bufs->head->buf;
|
||||
|
||||
if (nghttp2_buf_avail(buf) < frame->hd.length) {
|
||||
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
|
||||
}
|
||||
|
||||
buf->pos -= NGHTTP2_FRAME_HDLEN;
|
||||
|
||||
nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
|
||||
|
||||
for (i = 0; i < origin->nov; ++i) {
|
||||
orig = &origin->ov[i];
|
||||
nghttp2_put_uint16be(buf->last, (uint16_t)orig->origin_len);
|
||||
buf->last += 2;
|
||||
buf->last = nghttp2_cpymem(buf->last, orig->origin, orig->origin_len);
|
||||
}
|
||||
|
||||
assert(nghttp2_buf_len(buf) == NGHTTP2_FRAME_HDLEN + frame->hd.length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen, nghttp2_mem *mem) {
|
||||
nghttp2_ext_origin *origin;
|
||||
const uint8_t *p, *end;
|
||||
uint8_t *dst;
|
||||
size_t originlen;
|
||||
nghttp2_origin_entry *ov;
|
||||
size_t nov = 0;
|
||||
size_t len = 0;
|
||||
|
||||
origin = frame->payload;
|
||||
p = payload;
|
||||
end = p + payloadlen;
|
||||
|
||||
for (; p != end;) {
|
||||
if (end - p < 2) {
|
||||
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
|
||||
}
|
||||
originlen = nghttp2_get_uint16(p);
|
||||
p += 2;
|
||||
if (originlen == 0) {
|
||||
continue;
|
||||
}
|
||||
if (originlen > (size_t)(end - p)) {
|
||||
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
|
||||
}
|
||||
p += originlen;
|
||||
/* 1 for terminal NULL */
|
||||
len += originlen + 1;
|
||||
++nov;
|
||||
}
|
||||
|
||||
if (nov == 0) {
|
||||
origin->ov = NULL;
|
||||
origin->nov = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
len += nov * sizeof(nghttp2_origin_entry);
|
||||
|
||||
ov = nghttp2_mem_malloc(mem, len);
|
||||
if (ov == NULL) {
|
||||
return NGHTTP2_ERR_NOMEM;
|
||||
}
|
||||
|
||||
origin->ov = ov;
|
||||
origin->nov = nov;
|
||||
|
||||
dst = (uint8_t *)ov + nov * sizeof(nghttp2_origin_entry);
|
||||
p = payload;
|
||||
|
||||
for (; p != end;) {
|
||||
originlen = nghttp2_get_uint16(p);
|
||||
p += 2;
|
||||
if (originlen == 0) {
|
||||
continue;
|
||||
}
|
||||
ov->origin = dst;
|
||||
ov->origin_len = originlen;
|
||||
dst = nghttp2_cpymem(dst, p, originlen);
|
||||
*dst++ = '\0';
|
||||
p += originlen;
|
||||
++ov;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nghttp2_settings_entry *nghttp2_frame_iv_copy(const nghttp2_settings_entry *iv,
|
||||
size_t niv, nghttp2_mem *mem) {
|
||||
nghttp2_settings_entry *iv_copy;
|
||||
@@ -923,6 +1050,11 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv) {
|
||||
break;
|
||||
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
|
||||
break;
|
||||
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
|
||||
if (iv[i].value != 0 && iv[i].value != 1) {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_FRAME_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -70,7 +70,10 @@
|
||||
#define NGHTTP2_MAX_PADLEN 256
|
||||
|
||||
/* Union of extension frame payload */
|
||||
typedef union { nghttp2_ext_altsvc altsvc; } nghttp2_ext_frame_payload;
|
||||
typedef union {
|
||||
nghttp2_ext_altsvc altsvc;
|
||||
nghttp2_ext_origin origin;
|
||||
} nghttp2_ext_frame_payload;
|
||||
|
||||
void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd);
|
||||
|
||||
@@ -104,8 +107,7 @@ void nghttp2_frame_pack_priority_spec(uint8_t *buf,
|
||||
* assumes the |payload| contains whole priority specification.
|
||||
*/
|
||||
void nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec,
|
||||
uint8_t flags, const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Returns the offset from the HEADERS frame payload where the
|
||||
@@ -144,8 +146,7 @@ int nghttp2_frame_pack_headers(nghttp2_bufs *bufs, nghttp2_headers *frame,
|
||||
* This function always succeeds and returns 0.
|
||||
*/
|
||||
int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Packs PRIORITY frame |frame| in wire format and store it in
|
||||
@@ -162,8 +163,7 @@ int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame);
|
||||
* Unpacks PRIORITY wire format into |frame|.
|
||||
*/
|
||||
void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Packs RST_STREAM frame |frame| in wire frame format and store it in
|
||||
@@ -181,8 +181,7 @@ int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs,
|
||||
* Unpacks RST_STREAM frame byte sequence into |frame|.
|
||||
*/
|
||||
void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Packs SETTINGS frame |frame| in wire format and store it in
|
||||
@@ -273,8 +272,7 @@ int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs,
|
||||
* TODO END_HEADERS flag is not set
|
||||
*/
|
||||
int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Packs PING frame |frame| in wire format and store it in
|
||||
@@ -291,8 +289,7 @@ int nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame);
|
||||
* Unpacks PING wire format into |frame|.
|
||||
*/
|
||||
void nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Packs GOAWAY frame |frame| in wire format and store it in |bufs|.
|
||||
@@ -321,7 +318,6 @@ int nghttp2_frame_pack_goaway(nghttp2_bufs *bufs, nghttp2_goaway *frame);
|
||||
*/
|
||||
void nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen,
|
||||
uint8_t *var_gift_payload,
|
||||
size_t var_gift_payloadlen);
|
||||
|
||||
@@ -356,8 +352,7 @@ int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs,
|
||||
* Unpacks WINDOW_UPDATE frame byte sequence into |frame|.
|
||||
*/
|
||||
void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen);
|
||||
const uint8_t *payload);
|
||||
|
||||
/*
|
||||
* Packs ALTSVC frame |frame| in wire frame format and store it in
|
||||
@@ -398,6 +393,36 @@ int nghttp2_frame_unpack_altsvc_payload2(nghttp2_extension *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen, nghttp2_mem *mem);
|
||||
|
||||
/*
|
||||
* Packs ORIGIN frame |frame| in wire frame format and store it in
|
||||
* |bufs|.
|
||||
*
|
||||
* The caller must make sure that nghttp2_bufs_reset(bufs) is called
|
||||
* before calling this function.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
*
|
||||
* NGHTTP2_ERR_FRAME_SIZE_ERROR
|
||||
* The length of the frame is too large.
|
||||
*/
|
||||
int nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *ext);
|
||||
|
||||
/*
|
||||
* Unpacks ORIGIN wire format into |frame|. The |payload| of length
|
||||
* |payloadlen| contains the frame payload.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
*
|
||||
* NGHTTP2_ERR_NOMEM
|
||||
* Out of memory.
|
||||
* NGHTTP2_ERR_FRAME_SIZE_ERROR
|
||||
* The payload is too small.
|
||||
*/
|
||||
int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame,
|
||||
const uint8_t *payload,
|
||||
size_t payloadlen, nghttp2_mem *mem);
|
||||
/*
|
||||
* Initializes HEADERS frame |frame| with given values. |frame| takes
|
||||
* ownership of |nva|, so caller must not free it. If |stream_id| is
|
||||
@@ -495,6 +520,24 @@ void nghttp2_frame_altsvc_init(nghttp2_extension *frame, int32_t stream_id,
|
||||
*/
|
||||
void nghttp2_frame_altsvc_free(nghttp2_extension *frame, nghttp2_mem *mem);
|
||||
|
||||
/*
|
||||
* Initializes ORIGIN frame |frame| with given values. This function
|
||||
* assumes that frame->payload points to nghttp2_ext_origin object.
|
||||
* Also |ov| and the memory pointed by the field of its elements are
|
||||
* allocated in single buffer, starting with |ov|. On success, this
|
||||
* function takes ownership of |ov|, so caller must not free it.
|
||||
*/
|
||||
void nghttp2_frame_origin_init(nghttp2_extension *frame,
|
||||
nghttp2_origin_entry *ov, size_t nov);
|
||||
|
||||
/*
|
||||
* Frees up resources under |frame|. This function does not free
|
||||
* nghttp2_ext_origin object pointed by frame->payload. This function
|
||||
* only frees nghttp2_ext_origin.ov. Therefore, other fields must be
|
||||
* allocated in the same buffer with ov.
|
||||
*/
|
||||
void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem);
|
||||
|
||||
/*
|
||||
* Returns the number of padding bytes after payload. The total
|
||||
* padding length is given in the |padlen|. The returned value does
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
/* 3rd parameter is nghttp2_token value for header field name. We use
|
||||
first enum value if same header names are repeated (e.g.,
|
||||
:status). */
|
||||
static nghttp2_hd_static_entry static_table[] = {
|
||||
static const nghttp2_hd_static_entry static_table[] = {
|
||||
MAKE_STATIC_ENT(":authority", "", 0, 3153725150u),
|
||||
MAKE_STATIC_ENT(":method", "GET", 1, 695666056u),
|
||||
MAKE_STATIC_ENT(":method", "POST", 1, 695666056u),
|
||||
@@ -271,6 +271,15 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
switch (name[8]) {
|
||||
case 'l':
|
||||
if (memeq(":protoco", name, 8)) {
|
||||
return NGHTTP2_TOKEN__PROTOCOL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
switch (name[9]) {
|
||||
case 'e':
|
||||
@@ -662,9 +671,9 @@ static int hd_context_init(nghttp2_hd_context *context, nghttp2_mem *mem) {
|
||||
context->mem = mem;
|
||||
context->bad = 0;
|
||||
context->hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
|
||||
rv = hd_ringbuf_init(&context->hd_table, context->hd_table_bufsize_max /
|
||||
NGHTTP2_HD_ENTRY_OVERHEAD,
|
||||
mem);
|
||||
rv = hd_ringbuf_init(
|
||||
&context->hd_table,
|
||||
context->hd_table_bufsize_max / NGHTTP2_HD_ENTRY_OVERHEAD, mem);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
@@ -1159,7 +1168,7 @@ static search_result search_static_table(const nghttp2_nv *nv, int32_t token,
|
||||
int name_only) {
|
||||
search_result res = {token, 0};
|
||||
int i;
|
||||
nghttp2_hd_static_entry *ent;
|
||||
const nghttp2_hd_static_entry *ent;
|
||||
|
||||
if (name_only) {
|
||||
return res;
|
||||
@@ -1184,7 +1193,7 @@ static search_result search_hd_table(nghttp2_hd_context *context,
|
||||
int indexing_mode, nghttp2_hd_map *map,
|
||||
uint32_t hash) {
|
||||
search_result res = {-1, 0};
|
||||
nghttp2_hd_entry *ent;
|
||||
const nghttp2_hd_entry *ent;
|
||||
int exact_match;
|
||||
int name_only = indexing_mode == NGHTTP2_HD_NEVER_INDEXING;
|
||||
|
||||
@@ -1289,8 +1298,9 @@ nghttp2_hd_nv nghttp2_hd_table_get(nghttp2_hd_context *context, size_t idx) {
|
||||
return hd_ringbuf_get(&context->hd_table, idx - NGHTTP2_STATIC_TABLE_LENGTH)
|
||||
->nv;
|
||||
} else {
|
||||
nghttp2_hd_static_entry *ent = &static_table[idx];
|
||||
nghttp2_hd_nv nv = {&ent->name, &ent->value, ent->token,
|
||||
const nghttp2_hd_static_entry *ent = &static_table[idx];
|
||||
nghttp2_hd_nv nv = {(nghttp2_rcbuf *)&ent->name,
|
||||
(nghttp2_rcbuf *)&ent->value, ent->token,
|
||||
NGHTTP2_NV_FLAG_NONE};
|
||||
return nv;
|
||||
}
|
||||
@@ -1380,7 +1390,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
|
||||
if (indexing_mode == NGHTTP2_HD_WITH_INDEXING) {
|
||||
nghttp2_hd_nv hd_nv;
|
||||
|
||||
if (idx != -1 && idx < (ssize_t)NGHTTP2_STATIC_TABLE_LENGTH) {
|
||||
if (idx != -1) {
|
||||
hd_nv.name = nghttp2_hd_table_get(&deflater->ctx, (size_t)idx).name;
|
||||
nghttp2_rcbuf_incref(hd_nv.name);
|
||||
} else {
|
||||
@@ -1537,10 +1547,11 @@ ssize_t nghttp2_hd_deflate_hd_vec(nghttp2_hd_deflater *deflater,
|
||||
return (ssize_t)buflen;
|
||||
}
|
||||
|
||||
size_t nghttp2_hd_deflate_bound(nghttp2_hd_deflater *deflater _U_,
|
||||
size_t nghttp2_hd_deflate_bound(nghttp2_hd_deflater *deflater,
|
||||
const nghttp2_nv *nva, size_t nvlen) {
|
||||
size_t n = 0;
|
||||
size_t i;
|
||||
(void)deflater;
|
||||
|
||||
/* Possible Maximum Header Table Size Change. Encoding (1u << 31) -
|
||||
1 using 4 bit prefix requires 6 bytes. We may emit this at most
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_HD_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -111,6 +111,7 @@ typedef enum {
|
||||
NGHTTP2_TOKEN_KEEP_ALIVE,
|
||||
NGHTTP2_TOKEN_PROXY_CONNECTION,
|
||||
NGHTTP2_TOKEN_UPGRADE,
|
||||
NGHTTP2_TOKEN__PROTOCOL,
|
||||
} nghttp2_token;
|
||||
|
||||
struct nghttp2_hd_entry;
|
||||
@@ -211,7 +212,9 @@ typedef struct {
|
||||
|
||||
#define HD_MAP_SIZE 128
|
||||
|
||||
typedef struct { nghttp2_hd_entry *table[HD_MAP_SIZE]; } nghttp2_hd_map;
|
||||
typedef struct {
|
||||
nghttp2_hd_entry *table[HD_MAP_SIZE];
|
||||
} nghttp2_hd_map;
|
||||
|
||||
struct nghttp2_hd_deflater {
|
||||
nghttp2_hd_context ctx;
|
||||
@@ -313,7 +316,7 @@ void nghttp2_hd_deflate_free(nghttp2_hd_deflater *deflater);
|
||||
*
|
||||
* This function expands |bufs| as necessary to store the result. If
|
||||
* buffers is full and the process still requires more space, this
|
||||
* funtion fails and returns NGHTTP2_ERR_HEADER_COMP.
|
||||
* function fails and returns NGHTTP2_ERR_HEADER_COMP.
|
||||
*
|
||||
* After this function returns, it is safe to delete the |nva|.
|
||||
*
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_HD_HUFFMAN_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -322,6 +322,9 @@ const char *nghttp2_strerror(int error_code) {
|
||||
return "Internal error";
|
||||
case NGHTTP2_ERR_CANCEL:
|
||||
return "Cancel";
|
||||
case NGHTTP2_ERR_SETTINGS_EXPECTED:
|
||||
return "When a local endpoint expects to receive SETTINGS frame, it "
|
||||
"receives an other type of frame";
|
||||
case NGHTTP2_ERR_NOMEM:
|
||||
return "Out of memory";
|
||||
case NGHTTP2_ERR_CALLBACK_FAILURE:
|
||||
@@ -337,7 +340,7 @@ const char *nghttp2_strerror(int error_code) {
|
||||
}
|
||||
|
||||
/* Generated by gennmchartbl.py */
|
||||
static int VALID_HD_NAME_CHARS[] = {
|
||||
static const int VALID_HD_NAME_CHARS[] = {
|
||||
0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,
|
||||
0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,
|
||||
0 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */,
|
||||
@@ -425,7 +428,7 @@ int nghttp2_check_header_name(const uint8_t *name, size_t len) {
|
||||
}
|
||||
|
||||
/* Generated by genvchartbl.py */
|
||||
static int VALID_HD_VALUE_CHARS[] = {
|
||||
static const int VALID_HD_VALUE_CHARS[] = {
|
||||
0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,
|
||||
0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,
|
||||
0 /* BS */, 1 /* HT */, 0 /* LF */, 0 /* VT */,
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_HELPER_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -113,7 +113,7 @@ static int check_path(nghttp2_stream *stream) {
|
||||
}
|
||||
|
||||
static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
int trailer) {
|
||||
int trailer, int connect_protocol) {
|
||||
if (nv->name->base[0] == ':') {
|
||||
if (trailer ||
|
||||
(stream->http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED)) {
|
||||
@@ -146,10 +146,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_CONNECT;
|
||||
if (stream->http_flags &
|
||||
(NGHTTP2_HTTP_FLAG__PATH | NGHTTP2_HTTP_FLAG__SCHEME)) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
@@ -162,9 +158,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
}
|
||||
break;
|
||||
case NGHTTP2_TOKEN__PATH:
|
||||
if (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PATH)) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
@@ -175,9 +168,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
}
|
||||
break;
|
||||
case NGHTTP2_TOKEN__SCHEME:
|
||||
if (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__SCHEME)) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
@@ -186,6 +176,15 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
stream->http_flags |= NGHTTP2_HTTP_FLAG_SCHEME_HTTP;
|
||||
}
|
||||
break;
|
||||
case NGHTTP2_TOKEN__PROTOCOL:
|
||||
if (!connect_protocol) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
|
||||
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PROTOCOL)) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
break;
|
||||
case NGHTTP2_TOKEN_HOST:
|
||||
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG_HOST)) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
@@ -244,7 +243,7 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
stream->status_code = (int16_t)parse_uint(nv->value->base, nv->value->len);
|
||||
if (stream->status_code == -1) {
|
||||
if (stream->status_code == -1 || stream->status_code == 101) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
break;
|
||||
@@ -265,7 +264,7 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
|
||||
return NGHTTP2_ERR_REMOVE_HTTP_HEADER;
|
||||
}
|
||||
if (stream->status_code / 100 == 1 ||
|
||||
(stream->status_code == 200 &&
|
||||
(stream->status_code / 100 == 2 &&
|
||||
(stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT))) {
|
||||
return NGHTTP2_ERR_HTTP_HEADER;
|
||||
}
|
||||
@@ -458,7 +457,9 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
|
||||
}
|
||||
|
||||
if (session->server || frame->hd.type == NGHTTP2_PUSH_PROMISE) {
|
||||
return http_request_on_header(stream, nv, trailer);
|
||||
return http_request_on_header(stream, nv, trailer,
|
||||
session->server &&
|
||||
session->pending_enable_connect_protocol);
|
||||
}
|
||||
|
||||
return http_response_on_header(stream, nv, trailer);
|
||||
@@ -466,8 +467,11 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
|
||||
|
||||
int nghttp2_http_on_request_headers(nghttp2_stream *stream,
|
||||
nghttp2_frame *frame) {
|
||||
if (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) {
|
||||
if ((stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0) {
|
||||
if (!(stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
|
||||
(stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT)) {
|
||||
if ((stream->http_flags &
|
||||
(NGHTTP2_HTTP_FLAG__SCHEME | NGHTTP2_HTTP_FLAG__PATH)) ||
|
||||
(stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0) {
|
||||
return -1;
|
||||
}
|
||||
stream->content_length = -1;
|
||||
@@ -478,6 +482,11 @@ int nghttp2_http_on_request_headers(nghttp2_stream *stream,
|
||||
(NGHTTP2_HTTP_FLAG__AUTHORITY | NGHTTP2_HTTP_FLAG_HOST)) == 0) {
|
||||
return -1;
|
||||
}
|
||||
if ((stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
|
||||
((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) == 0 ||
|
||||
(stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0)) {
|
||||
return -1;
|
||||
}
|
||||
if (!check_path(stream)) {
|
||||
return -1;
|
||||
}
|
||||
@@ -521,8 +530,10 @@ int nghttp2_http_on_response_headers(nghttp2_stream *stream) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp2_http_on_trailer_headers(nghttp2_stream *stream _U_,
|
||||
int nghttp2_http_on_trailer_headers(nghttp2_stream *stream,
|
||||
nghttp2_frame *frame) {
|
||||
(void)stream;
|
||||
|
||||
if ((frame->hd.flags & NGHTTP2_FLAG_END_STREAM) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_HTTP_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_INT_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_MAP_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -24,18 +24,27 @@
|
||||
*/
|
||||
#include "nghttp2_mem.h"
|
||||
|
||||
static void *default_malloc(size_t size, void *mem_user_data _U_) {
|
||||
static void *default_malloc(size_t size, void *mem_user_data) {
|
||||
(void)mem_user_data;
|
||||
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void default_free(void *ptr, void *mem_user_data _U_) { free(ptr); }
|
||||
static void default_free(void *ptr, void *mem_user_data) {
|
||||
(void)mem_user_data;
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static void *default_calloc(size_t nmemb, size_t size, void *mem_user_data) {
|
||||
(void)mem_user_data;
|
||||
|
||||
static void *default_calloc(size_t nmemb, size_t size,
|
||||
void *mem_user_data _U_) {
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
|
||||
static void *default_realloc(void *ptr, size_t size, void *mem_user_data _U_) {
|
||||
static void *default_realloc(void *ptr, size_t size, void *mem_user_data) {
|
||||
(void)mem_user_data;
|
||||
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_MEM_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -26,15 +26,15 @@
|
||||
#define NGHTTP2_NET_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
# include <arpa/inet.h>
|
||||
#endif /* HAVE_ARPA_INET_H */
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
# include <netinet/in.h>
|
||||
#endif /* HAVE_NETINET_IN_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -44,11 +44,11 @@
|
||||
define inline functions for those function so that we don't have
|
||||
dependeny on that lib. */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define STIN static __inline
|
||||
#else
|
||||
#define STIN static inline
|
||||
#endif
|
||||
# ifdef _MSC_VER
|
||||
# define STIN static __inline
|
||||
# else
|
||||
# define STIN static inline
|
||||
# endif
|
||||
|
||||
STIN uint32_t htonl(uint32_t hostlong) {
|
||||
uint32_t res;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_NPN_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -86,6 +86,10 @@ void nghttp2_option_set_builtin_recv_extension_type(nghttp2_option *option,
|
||||
option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;
|
||||
option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ALTSVC;
|
||||
return;
|
||||
case NGHTTP2_ORIGIN:
|
||||
option->opt_set_mask |= NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES;
|
||||
option->builtin_recv_ext_types |= NGHTTP2_TYPEMASK_ORIGIN;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -107,3 +111,8 @@ void nghttp2_option_set_max_deflate_dynamic_table_size(nghttp2_option *option,
|
||||
option->opt_set_mask |= NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE;
|
||||
option->max_deflate_dynamic_table_size = val;
|
||||
}
|
||||
|
||||
void nghttp2_option_set_no_closed_streams(nghttp2_option *option, int val) {
|
||||
option->opt_set_mask |= NGHTTP2_OPT_NO_CLOSED_STREAMS;
|
||||
option->no_closed_streams = val;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_OPTION_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -65,6 +65,7 @@ typedef enum {
|
||||
NGHTTP2_OPT_BUILTIN_RECV_EXT_TYPES = 1 << 7,
|
||||
NGHTTP2_OPT_MAX_SEND_HEADER_BLOCK_LENGTH = 1 << 8,
|
||||
NGHTTP2_OPT_MAX_DEFLATE_DYNAMIC_TABLE_SIZE = 1 << 9,
|
||||
NGHTTP2_OPT_NO_CLOSED_STREAMS = 1 << 10,
|
||||
} nghttp2_option_flag;
|
||||
|
||||
/**
|
||||
@@ -112,6 +113,10 @@ struct nghttp2_option {
|
||||
* NGHTTP2_OPT_NO_AUTO_PING_ACK
|
||||
*/
|
||||
int no_auto_ping_ack;
|
||||
/**
|
||||
* NGHTTP2_OPT_NO_CLOSED_STREAMS
|
||||
*/
|
||||
int no_closed_streams;
|
||||
/**
|
||||
* NGHTTP2_OPT_USER_RECV_EXT_TYPES
|
||||
*/
|
||||
|
||||
@@ -86,6 +86,9 @@ void nghttp2_outbound_item_free(nghttp2_outbound_item *item, nghttp2_mem *mem) {
|
||||
case NGHTTP2_ALTSVC:
|
||||
nghttp2_frame_altsvc_free(&frame->ext, mem);
|
||||
break;
|
||||
case NGHTTP2_ORIGIN:
|
||||
nghttp2_frame_origin_free(&frame->ext, mem);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_OUTBOUND_ITEM_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -112,7 +112,7 @@ struct nghttp2_outbound_item {
|
||||
nghttp2_ext_frame_payload ext_frame_payload;
|
||||
nghttp2_aux_data aux_data;
|
||||
/* The priority used in priority comparion. Smaller is served
|
||||
ealier. For PING, SETTINGS and non-DATA frames (excluding
|
||||
earlier. For PING, SETTINGS and non-DATA frames (excluding
|
||||
response HEADERS frame) have dedicated cycle value defined above.
|
||||
For DATA frame, cycle is computed by taking into account of
|
||||
effective weight and frame payload length previously sent, so
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_PQ_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -35,14 +35,16 @@
|
||||
|
||||
/* Implementation of priority queue */
|
||||
|
||||
typedef struct { size_t index; } nghttp2_pq_entry;
|
||||
typedef struct {
|
||||
size_t index;
|
||||
} nghttp2_pq_entry;
|
||||
|
||||
typedef struct {
|
||||
/* The pointer to the pointer to the item stored */
|
||||
nghttp2_pq_entry **q;
|
||||
/* Memory allocator */
|
||||
nghttp2_mem *mem;
|
||||
/* The number of items sotred */
|
||||
/* The number of items stored */
|
||||
size_t length;
|
||||
/* The maximum number of items this pq can store. This is
|
||||
automatically extended when length is reached to this value. */
|
||||
@@ -71,7 +73,7 @@ void nghttp2_pq_free(nghttp2_pq *pq);
|
||||
/*
|
||||
* Adds |item| to the priority queue |pq|.
|
||||
*
|
||||
* This function returns 0 if it succeds, or one of the following
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
*
|
||||
* NGHTTP2_ERR_NOMEM
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_PRIORITY_SPEC_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_QUEUE_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
# include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -36,7 +36,9 @@ typedef struct nghttp2_queue_cell {
|
||||
struct nghttp2_queue_cell *next;
|
||||
} nghttp2_queue_cell;
|
||||
|
||||
typedef struct { nghttp2_queue_cell *front, *back; } nghttp2_queue;
|
||||
typedef struct {
|
||||
nghttp2_queue_cell *front, *back;
|
||||
} nghttp2_queue;
|
||||
|
||||
void nghttp2_queue_init(nghttp2_queue *queue);
|
||||
void nghttp2_queue_free(nghttp2_queue *queue);
|
||||
|
||||
@@ -96,3 +96,7 @@ nghttp2_vec nghttp2_rcbuf_get_buf(nghttp2_rcbuf *rcbuf) {
|
||||
nghttp2_vec res = {rcbuf->base, rcbuf->len};
|
||||
return res;
|
||||
}
|
||||
|
||||
int nghttp2_rcbuf_is_static(const nghttp2_rcbuf *rcbuf) {
|
||||
return rcbuf->ref == -1;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_RCBUF_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_SESSION_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -51,7 +51,8 @@ typedef enum {
|
||||
NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE = 1 << 0,
|
||||
NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC = 1 << 1,
|
||||
NGHTTP2_OPTMASK_NO_HTTP_MESSAGING = 1 << 2,
|
||||
NGHTTP2_OPTMASK_NO_AUTO_PING_ACK = 1 << 3
|
||||
NGHTTP2_OPTMASK_NO_AUTO_PING_ACK = 1 << 3,
|
||||
NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4
|
||||
} nghttp2_optmask;
|
||||
|
||||
/*
|
||||
@@ -60,7 +61,8 @@ typedef enum {
|
||||
*/
|
||||
typedef enum {
|
||||
NGHTTP2_TYPEMASK_NONE = 0,
|
||||
NGHTTP2_TYPEMASK_ALTSVC = 1 << 0
|
||||
NGHTTP2_TYPEMASK_ALTSVC = 1 << 0,
|
||||
NGHTTP2_TYPEMASK_ORIGIN = 1 << 1
|
||||
} nghttp2_typemask;
|
||||
|
||||
typedef enum {
|
||||
@@ -120,6 +122,7 @@ typedef enum {
|
||||
NGHTTP2_IB_IGN_DATA,
|
||||
NGHTTP2_IB_IGN_ALL,
|
||||
NGHTTP2_IB_READ_ALTSVC_PAYLOAD,
|
||||
NGHTTP2_IB_READ_ORIGIN_PAYLOAD,
|
||||
NGHTTP2_IB_READ_EXTENSION_PAYLOAD
|
||||
} nghttp2_inbound_state;
|
||||
|
||||
@@ -161,6 +164,7 @@ typedef struct {
|
||||
uint32_t initial_window_size;
|
||||
uint32_t max_frame_size;
|
||||
uint32_t max_header_list_size;
|
||||
uint32_t enable_connect_protocol;
|
||||
} nghttp2_settings_storage;
|
||||
|
||||
typedef enum {
|
||||
@@ -205,9 +209,6 @@ struct nghttp2_session {
|
||||
nghttp2_session_callbacks callbacks;
|
||||
/* Memory allocator */
|
||||
nghttp2_mem mem;
|
||||
/* Base value when we schedule next DATA frame write. This is
|
||||
updated when one frame was written. */
|
||||
uint64_t last_cycle;
|
||||
void *user_data;
|
||||
/* Points to the latest incoming closed stream. NULL if there is no
|
||||
closed stream. Only used when session is initialized as
|
||||
@@ -300,8 +301,10 @@ struct nghttp2_session {
|
||||
increased/decreased by submitting WINDOW_UPDATE. See
|
||||
nghttp2_submit_window_update(). */
|
||||
int32_t local_window_size;
|
||||
/* Settings value received from the remote endpoint. We just use ID
|
||||
as index. The index = 0 is unused. */
|
||||
/* This flag is used to indicate that the local endpoint received initial
|
||||
SETTINGS frame from the remote endpoint. */
|
||||
uint8_t remote_settings_received;
|
||||
/* Settings value received from the remote endpoint. */
|
||||
nghttp2_settings_storage remote_settings;
|
||||
/* Settings value of the local endpoint. */
|
||||
nghttp2_settings_storage local_settings;
|
||||
@@ -310,15 +313,18 @@ struct nghttp2_session {
|
||||
/* Unacked local SETTINGS_MAX_CONCURRENT_STREAMS value. We use this
|
||||
to refuse the incoming stream if it exceeds this value. */
|
||||
uint32_t pending_local_max_concurrent_stream;
|
||||
/* The bitwose OR of zero or more of nghttp2_typemask to indicate
|
||||
/* The bitwise OR of zero or more of nghttp2_typemask to indicate
|
||||
that the default handling of extension frame is enabled. */
|
||||
uint32_t builtin_recv_ext_types;
|
||||
/* Unacked local ENABLE_PUSH value. We use this to refuse
|
||||
PUSH_PROMISE before SETTINGS ACK is received. */
|
||||
uint8_t pending_enable_push;
|
||||
/* Unacked local ENABLE_CONNECT_PROTOCOL value. We use this to
|
||||
accept :protocol header field before SETTINGS_ACK is received. */
|
||||
uint8_t pending_enable_connect_protocol;
|
||||
/* Nonzero if the session is server side. */
|
||||
uint8_t server;
|
||||
/* Flags indicating GOAWAY is sent and/or recieved. The flags are
|
||||
/* Flags indicating GOAWAY is sent and/or received. The flags are
|
||||
composed by bitwise OR-ing nghttp2_goaway_flag. */
|
||||
uint8_t goaway_flags;
|
||||
/* This flag is used to reduce excessive queuing of WINDOW_UPDATE to
|
||||
@@ -697,7 +703,7 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session,
|
||||
* NGHTTP2_ERR_NOMEM
|
||||
* Out of memory.
|
||||
* NGHTTP2_ERR_CALLBACK_FAILURE
|
||||
* The callback function failed.
|
||||
* The callback function failed.
|
||||
* NGHTTP2_ERR_FLOODED
|
||||
* There are too many items in outbound queue, and this is most
|
||||
* likely caused by misbehaviour of peer.
|
||||
@@ -715,13 +721,13 @@ int nghttp2_session_on_ping_received(nghttp2_session *session,
|
||||
* NGHTTP2_ERR_NOMEM
|
||||
* Out of memory.
|
||||
* NGHTTP2_ERR_CALLBACK_FAILURE
|
||||
* The callback function failed.
|
||||
* The callback function failed.
|
||||
*/
|
||||
int nghttp2_session_on_goaway_received(nghttp2_session *session,
|
||||
nghttp2_frame *frame);
|
||||
|
||||
/*
|
||||
* Called when WINDOW_UPDATE is recieved, assuming |frame| is properly
|
||||
* Called when WINDOW_UPDATE is received, assuming |frame| is properly
|
||||
* initialized.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
@@ -730,24 +736,37 @@ int nghttp2_session_on_goaway_received(nghttp2_session *session,
|
||||
* NGHTTP2_ERR_NOMEM
|
||||
* Out of memory.
|
||||
* NGHTTP2_ERR_CALLBACK_FAILURE
|
||||
* The callback function failed.
|
||||
* The callback function failed.
|
||||
*/
|
||||
int nghttp2_session_on_window_update_received(nghttp2_session *session,
|
||||
nghttp2_frame *frame);
|
||||
|
||||
/*
|
||||
* Called when ALTSVC is recieved, assuming |frame| is properly
|
||||
* Called when ALTSVC is received, assuming |frame| is properly
|
||||
* initialized.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
*
|
||||
* NGHTTP2_ERR_CALLBACK_FAILURE
|
||||
* The callback function failed.
|
||||
* The callback function failed.
|
||||
*/
|
||||
int nghttp2_session_on_altsvc_received(nghttp2_session *session,
|
||||
nghttp2_frame *frame);
|
||||
|
||||
/*
|
||||
* Called when ORIGIN is received, assuming |frame| is properly
|
||||
* initialized.
|
||||
*
|
||||
* This function returns 0 if it succeeds, or one of the following
|
||||
* negative error codes:
|
||||
*
|
||||
* NGHTTP2_ERR_CALLBACK_FAILURE
|
||||
* The callback function failed.
|
||||
*/
|
||||
int nghttp2_session_on_origin_received(nghttp2_session *session,
|
||||
nghttp2_frame *frame);
|
||||
|
||||
/*
|
||||
* Called when DATA is received, assuming |frame| is properly
|
||||
* initialized.
|
||||
@@ -758,7 +777,7 @@ int nghttp2_session_on_altsvc_received(nghttp2_session *session,
|
||||
* NGHTTP2_ERR_NOMEM
|
||||
* Out of memory.
|
||||
* NGHTTP2_ERR_CALLBACK_FAILURE
|
||||
* The callback function failed.
|
||||
* The callback function failed.
|
||||
*/
|
||||
int nghttp2_session_on_data_received(nghttp2_session *session,
|
||||
nghttp2_frame *frame);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "nghttp2_session.h"
|
||||
#include "nghttp2_helper.h"
|
||||
#include "nghttp2_debug.h"
|
||||
#include "nghttp2_frame.h"
|
||||
|
||||
/* Maximum distance between any two stream's cycle in the same
|
||||
prirority queue. Imagine stream A's cycle is A, and stream B's
|
||||
@@ -40,7 +41,8 @@
|
||||
words, B is really greater than or equal to A. Otherwise, A is a
|
||||
result of overflow, and it is actually A > B if we consider that
|
||||
fact. */
|
||||
#define NGHTTP2_MAX_CYCLE_DISTANCE (16384 * 256 + 255)
|
||||
#define NGHTTP2_MAX_CYCLE_DISTANCE \
|
||||
((uint64_t)NGHTTP2_MAX_FRAME_SIZE_MAX * 256 + 255)
|
||||
|
||||
static int stream_less(const void *lhsx, const void *rhsx) {
|
||||
const nghttp2_stream *lhs, *rhs;
|
||||
@@ -52,11 +54,7 @@ static int stream_less(const void *lhsx, const void *rhsx) {
|
||||
return lhs->seq < rhs->seq;
|
||||
}
|
||||
|
||||
if (lhs->cycle < rhs->cycle) {
|
||||
return rhs->cycle - lhs->cycle <= NGHTTP2_MAX_CYCLE_DISTANCE;
|
||||
}
|
||||
|
||||
return lhs->cycle - rhs->cycle > NGHTTP2_MAX_CYCLE_DISTANCE;
|
||||
return rhs->cycle - lhs->cycle <= NGHTTP2_MAX_CYCLE_DISTANCE;
|
||||
}
|
||||
|
||||
void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
|
||||
@@ -135,14 +133,14 @@ static int stream_subtree_active(nghttp2_stream *stream) {
|
||||
/*
|
||||
* Returns next cycle for |stream|.
|
||||
*/
|
||||
static void stream_next_cycle(nghttp2_stream *stream, uint32_t last_cycle) {
|
||||
uint32_t penalty;
|
||||
static void stream_next_cycle(nghttp2_stream *stream, uint64_t last_cycle) {
|
||||
uint64_t penalty;
|
||||
|
||||
penalty = (uint32_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT +
|
||||
penalty = (uint64_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT +
|
||||
stream->pending_penalty;
|
||||
|
||||
stream->cycle = last_cycle + penalty / (uint32_t)stream->weight;
|
||||
stream->pending_penalty = penalty % (uint32_t)stream->weight;
|
||||
stream->pending_penalty = (uint32_t)(penalty % (uint32_t)stream->weight);
|
||||
}
|
||||
|
||||
static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {
|
||||
@@ -153,7 +151,7 @@ static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {
|
||||
stream_next_cycle(stream, dep_stream->descendant_last_cycle);
|
||||
stream->seq = dep_stream->descendant_next_seq++;
|
||||
|
||||
DEBUGF("stream: stream=%d obq push cycle=%d\n", stream->stream_id,
|
||||
DEBUGF("stream: stream=%d obq push cycle=%lu\n", stream->stream_id,
|
||||
stream->cycle);
|
||||
|
||||
DEBUGF("stream: push stream %d to stream %d\n", stream->stream_id,
|
||||
@@ -239,7 +237,7 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
|
||||
|
||||
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
||||
|
||||
DEBUGF("stream: stream=%d obq resched cycle=%d\n", stream->stream_id,
|
||||
DEBUGF("stream: stream=%d obq resched cycle=%lu\n", stream->stream_id,
|
||||
stream->cycle);
|
||||
|
||||
dep_stream->last_writelen = stream->last_writelen;
|
||||
@@ -248,9 +246,9 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
|
||||
|
||||
void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
|
||||
nghttp2_stream *dep_stream;
|
||||
uint32_t last_cycle;
|
||||
uint64_t last_cycle;
|
||||
int32_t old_weight;
|
||||
uint32_t wlen_penalty;
|
||||
uint64_t wlen_penalty;
|
||||
|
||||
if (stream->weight == weight) {
|
||||
return;
|
||||
@@ -273,7 +271,7 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
|
||||
|
||||
nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry);
|
||||
|
||||
wlen_penalty = (uint32_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT;
|
||||
wlen_penalty = (uint64_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT;
|
||||
|
||||
/* Compute old stream->pending_penalty we used to calculate
|
||||
stream->cycle */
|
||||
@@ -289,9 +287,8 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
|
||||
place */
|
||||
stream_next_cycle(stream, last_cycle);
|
||||
|
||||
if (stream->cycle < dep_stream->descendant_last_cycle &&
|
||||
(dep_stream->descendant_last_cycle - stream->cycle) <=
|
||||
NGHTTP2_MAX_CYCLE_DISTANCE) {
|
||||
if (dep_stream->descendant_last_cycle - stream->cycle <=
|
||||
NGHTTP2_MAX_CYCLE_DISTANCE) {
|
||||
stream->cycle = dep_stream->descendant_last_cycle;
|
||||
}
|
||||
|
||||
@@ -299,7 +296,7 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
|
||||
|
||||
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
||||
|
||||
DEBUGF("stream: stream=%d obq resched cycle=%d\n", stream->stream_id,
|
||||
DEBUGF("stream: stream=%d obq resched cycle=%lu\n", stream->stream_id,
|
||||
stream->cycle);
|
||||
}
|
||||
|
||||
@@ -366,8 +363,9 @@ static void check_queued(nghttp2_stream *stream) {
|
||||
}
|
||||
}
|
||||
if (queued == 0) {
|
||||
fprintf(stderr, "stream(%p)=%d, stream->queued == 1, and "
|
||||
"!stream_active(), but no descendants is queued\n",
|
||||
fprintf(stderr,
|
||||
"stream(%p)=%d, stream->queued == 1, and "
|
||||
"!stream_active(), but no descendants is queued\n",
|
||||
stream, stream->stream_id);
|
||||
assert(0);
|
||||
}
|
||||
@@ -378,9 +376,10 @@ static void check_queued(nghttp2_stream *stream) {
|
||||
}
|
||||
} else {
|
||||
if (stream_active(stream) || !nghttp2_pq_empty(&stream->obq)) {
|
||||
fprintf(stderr, "stream(%p) = %d, stream->queued == 0, but "
|
||||
"stream_active(stream) == %d and "
|
||||
"nghttp2_pq_size(&stream->obq) = %zu\n",
|
||||
fprintf(stderr,
|
||||
"stream(%p) = %d, stream->queued == 0, but "
|
||||
"stream_active(stream) == %d and "
|
||||
"nghttp2_pq_size(&stream->obq) = %zu\n",
|
||||
stream, stream->stream_id, stream_active(stream),
|
||||
nghttp2_pq_size(&stream->obq));
|
||||
assert(0);
|
||||
@@ -449,8 +448,8 @@ static void validate_tree(nghttp2_stream *stream) {
|
||||
check_sum_dep(stream);
|
||||
check_dep_prev(stream);
|
||||
}
|
||||
#else /* !STREAM_DEP_DEBUG */
|
||||
static void validate_tree(nghttp2_stream *stream _U_) {}
|
||||
#else /* !STREAM_DEP_DEBUG */
|
||||
static void validate_tree(nghttp2_stream *stream) { (void)stream; }
|
||||
#endif /* !STREAM_DEP_DEBUG*/
|
||||
|
||||
static int stream_update_dep_on_attach_item(nghttp2_stream *stream) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_STREAM_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
@@ -130,7 +130,8 @@ typedef enum {
|
||||
/* "http" or "https" scheme */
|
||||
NGHTTP2_HTTP_FLAG_SCHEME_HTTP = 1 << 13,
|
||||
/* set if final response is expected */
|
||||
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14
|
||||
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14,
|
||||
NGHTTP2_HTTP_FLAG__PROTOCOL = 1 << 15,
|
||||
} nghttp2_http_flag;
|
||||
|
||||
struct nghttp2_stream {
|
||||
@@ -147,9 +148,9 @@ struct nghttp2_stream {
|
||||
/* Received body so far */
|
||||
int64_t recv_content_length;
|
||||
/* Base last_cycle for direct descendent streams. */
|
||||
uint32_t descendant_last_cycle;
|
||||
uint64_t descendant_last_cycle;
|
||||
/* Next scheduled time to sent item */
|
||||
uint32_t cycle;
|
||||
uint64_t cycle;
|
||||
/* Next seq used for direct descendant streams */
|
||||
uint64_t descendant_next_seq;
|
||||
/* Secondary key for prioritization to break a tie for cycle. This
|
||||
|
||||
@@ -217,7 +217,7 @@ int nghttp2_submit_ping(nghttp2_session *session, uint8_t flags,
|
||||
return nghttp2_session_add_ping(session, flags, opaque_data);
|
||||
}
|
||||
|
||||
int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags _U_,
|
||||
int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id,
|
||||
const nghttp2_priority_spec *pri_spec) {
|
||||
int rv;
|
||||
@@ -225,6 +225,7 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags _U_,
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_priority_spec copy_pri_spec;
|
||||
nghttp2_mem *mem;
|
||||
(void)flags;
|
||||
|
||||
mem = &session->mem;
|
||||
|
||||
@@ -264,8 +265,10 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags _U_,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags _U_,
|
||||
int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id, uint32_t error_code) {
|
||||
(void)flags;
|
||||
|
||||
if (stream_id == 0) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
@@ -273,9 +276,11 @@ int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags _U_,
|
||||
return nghttp2_session_add_rst_stream(session, stream_id, error_code);
|
||||
}
|
||||
|
||||
int nghttp2_submit_goaway(nghttp2_session *session, uint8_t flags _U_,
|
||||
int nghttp2_submit_goaway(nghttp2_session *session, uint8_t flags,
|
||||
int32_t last_stream_id, uint32_t error_code,
|
||||
const uint8_t *opaque_data, size_t opaque_data_len) {
|
||||
(void)flags;
|
||||
|
||||
if (session->goaway_flags & NGHTTP2_GOAWAY_TERM_ON_SEND) {
|
||||
return 0;
|
||||
}
|
||||
@@ -296,12 +301,13 @@ int nghttp2_submit_shutdown_notice(nghttp2_session *session) {
|
||||
NGHTTP2_GOAWAY_AUX_SHUTDOWN_NOTICE);
|
||||
}
|
||||
|
||||
int nghttp2_submit_settings(nghttp2_session *session, uint8_t flags _U_,
|
||||
int nghttp2_submit_settings(nghttp2_session *session, uint8_t flags,
|
||||
const nghttp2_settings_entry *iv, size_t niv) {
|
||||
(void)flags;
|
||||
return nghttp2_session_add_settings(session, NGHTTP2_FLAG_NONE, iv, niv);
|
||||
}
|
||||
|
||||
int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
|
||||
int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id, const nghttp2_nv *nva,
|
||||
size_t nvlen,
|
||||
void *promised_stream_user_data) {
|
||||
@@ -312,6 +318,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
|
||||
int32_t promised_stream_id;
|
||||
int rv;
|
||||
nghttp2_mem *mem;
|
||||
(void)flags;
|
||||
|
||||
mem = &session->mem;
|
||||
|
||||
@@ -365,11 +372,13 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
|
||||
return promised_stream_id;
|
||||
}
|
||||
|
||||
int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags _U_,
|
||||
int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id,
|
||||
int32_t window_size_increment) {
|
||||
int rv;
|
||||
nghttp2_stream *stream = 0;
|
||||
(void)flags;
|
||||
|
||||
if (window_size_increment == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -410,11 +419,12 @@ int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags _U_,
|
||||
}
|
||||
|
||||
int nghttp2_session_set_local_window_size(nghttp2_session *session,
|
||||
uint8_t flags _U_, int32_t stream_id,
|
||||
uint8_t flags, int32_t stream_id,
|
||||
int32_t window_size) {
|
||||
int32_t window_size_increment;
|
||||
nghttp2_stream *stream;
|
||||
int rv;
|
||||
(void)flags;
|
||||
|
||||
if (window_size < 0) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
@@ -476,7 +486,7 @@ int nghttp2_session_set_local_window_size(nghttp2_session *session,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp2_submit_altsvc(nghttp2_session *session, uint8_t flags _U_,
|
||||
int nghttp2_submit_altsvc(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id, const uint8_t *origin,
|
||||
size_t origin_len, const uint8_t *field_value,
|
||||
size_t field_value_len) {
|
||||
@@ -488,6 +498,7 @@ int nghttp2_submit_altsvc(nghttp2_session *session, uint8_t flags _U_,
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_ext_altsvc *altsvc;
|
||||
int rv;
|
||||
(void)flags;
|
||||
|
||||
mem = &session->mem;
|
||||
|
||||
@@ -560,6 +571,89 @@ fail_item_malloc:
|
||||
return rv;
|
||||
}
|
||||
|
||||
int nghttp2_submit_origin(nghttp2_session *session, uint8_t flags,
|
||||
const nghttp2_origin_entry *ov, size_t nov) {
|
||||
nghttp2_mem *mem;
|
||||
uint8_t *p;
|
||||
nghttp2_outbound_item *item;
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_ext_origin *origin;
|
||||
nghttp2_origin_entry *ov_copy;
|
||||
size_t len = 0;
|
||||
size_t i;
|
||||
int rv;
|
||||
(void)flags;
|
||||
|
||||
mem = &session->mem;
|
||||
|
||||
if (!session->server) {
|
||||
return NGHTTP2_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (nov) {
|
||||
for (i = 0; i < nov; ++i) {
|
||||
len += ov[i].origin_len;
|
||||
}
|
||||
|
||||
if (2 * nov + len > NGHTTP2_MAX_PAYLOADLEN) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* The last nov is added for terminal NULL character. */
|
||||
ov_copy =
|
||||
nghttp2_mem_malloc(mem, nov * sizeof(nghttp2_origin_entry) + len + nov);
|
||||
if (ov_copy == NULL) {
|
||||
return NGHTTP2_ERR_NOMEM;
|
||||
}
|
||||
|
||||
p = (uint8_t *)ov_copy + nov * sizeof(nghttp2_origin_entry);
|
||||
|
||||
for (i = 0; i < nov; ++i) {
|
||||
ov_copy[i].origin = p;
|
||||
ov_copy[i].origin_len = ov[i].origin_len;
|
||||
p = nghttp2_cpymem(p, ov[i].origin, ov[i].origin_len);
|
||||
*p++ = '\0';
|
||||
}
|
||||
|
||||
assert((size_t)(p - (uint8_t *)ov_copy) ==
|
||||
nov * sizeof(nghttp2_origin_entry) + len + nov);
|
||||
} else {
|
||||
ov_copy = NULL;
|
||||
}
|
||||
|
||||
item = nghttp2_mem_malloc(mem, sizeof(nghttp2_outbound_item));
|
||||
if (item == NULL) {
|
||||
rv = NGHTTP2_ERR_NOMEM;
|
||||
goto fail_item_malloc;
|
||||
}
|
||||
|
||||
nghttp2_outbound_item_init(item);
|
||||
|
||||
item->aux_data.ext.builtin = 1;
|
||||
|
||||
origin = &item->ext_frame_payload.origin;
|
||||
|
||||
frame = &item->frame;
|
||||
frame->ext.payload = origin;
|
||||
|
||||
nghttp2_frame_origin_init(&frame->ext, ov_copy, nov);
|
||||
|
||||
rv = nghttp2_session_add_item(session, item);
|
||||
if (rv != 0) {
|
||||
nghttp2_frame_origin_free(&frame->ext, mem);
|
||||
nghttp2_mem_free(mem, item);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail_item_malloc:
|
||||
free(ov_copy);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static uint8_t set_request_flags(const nghttp2_priority_spec *pri_spec,
|
||||
const nghttp2_data_provider *data_prd) {
|
||||
uint8_t flags = NGHTTP2_FLAG_NONE;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define NGHTTP2_SUBMIT_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
# include <config.h>
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <nghttp2/nghttp2.h>
|
||||
|
||||
948
m4/ax_cxx_compile_stdcxx.m4
Normal file
948
m4/ax_cxx_compile_stdcxx.m4
Normal file
@@ -0,0 +1,948 @@
|
||||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the specified
|
||||
# version of the C++ standard. If necessary, add switches to CXX and
|
||||
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
|
||||
# or '14' (for the C++14 standard).
|
||||
#
|
||||
# The second argument, if specified, indicates whether you insist on an
|
||||
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
|
||||
# -std=c++11). If neither is specified, you get whatever works, with
|
||||
# preference for an extended mode.
|
||||
#
|
||||
# The third argument, if specified 'mandatory' or if left unspecified,
|
||||
# indicates that baseline support for the specified C++ standard is
|
||||
# required and that the macro should error out if no mode with that
|
||||
# support is found. If specified 'optional', then configuration proceeds
|
||||
# regardless, after defining HAVE_CXX${VERSION} if and only if a
|
||||
# supporting mode is found.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
|
||||
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
|
||||
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
|
||||
# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 10
|
||||
|
||||
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
||||
dnl (serial version number 13).
|
||||
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
|
||||
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
|
||||
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
|
||||
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
|
||||
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
|
||||
m4_if([$2], [], [],
|
||||
[$2], [ext], [],
|
||||
[$2], [noext], [],
|
||||
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
|
||||
m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
|
||||
[$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
|
||||
[$3], [optional], [ax_cxx_compile_cxx$1_required=false],
|
||||
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
|
||||
AC_LANG_PUSH([C++])dnl
|
||||
ac_success=no
|
||||
|
||||
m4_if([$2], [noext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for alternative in ${ax_cxx_compile_alternatives}; do
|
||||
switch="-std=gnu++${alternative}"
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXX="$CXX"
|
||||
CXX="$CXX $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXX="$ac_save_CXX"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXX="$CXX $switch"
|
||||
if test -n "$CXXCPP" ; then
|
||||
CXXCPP="$CXXCPP $switch"
|
||||
fi
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
|
||||
m4_if([$2], [ext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
dnl HP's aCC needs +std=c++11 according to:
|
||||
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
|
||||
dnl Cray's crayCC needs "-h std=c++11"
|
||||
for alternative in ${ax_cxx_compile_alternatives}; do
|
||||
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXX="$CXX"
|
||||
CXX="$CXX $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXX="$ac_save_CXX"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXX="$CXX $switch"
|
||||
if test -n "$CXXCPP" ; then
|
||||
CXXCPP="$CXXCPP $switch"
|
||||
fi
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x$ac_success = xyes; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
AC_LANG_POP([C++])
|
||||
if test x$ax_cxx_compile_cxx$1_required = xtrue; then
|
||||
if test x$ac_success = xno; then
|
||||
AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
|
||||
fi
|
||||
fi
|
||||
if test x$ac_success = xno; then
|
||||
HAVE_CXX$1=0
|
||||
AC_MSG_NOTICE([No compiler with C++$1 support was found])
|
||||
else
|
||||
HAVE_CXX$1=1
|
||||
AC_DEFINE(HAVE_CXX$1,1,
|
||||
[define if the compiler supports basic C++$1 syntax])
|
||||
fi
|
||||
AC_SUBST(HAVE_CXX$1)
|
||||
])
|
||||
|
||||
|
||||
dnl Test body for checking C++11 support
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||
)
|
||||
|
||||
|
||||
dnl Test body for checking C++14 support
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
|
||||
)
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
|
||||
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
|
||||
)
|
||||
|
||||
dnl Tests for new features in C++11
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
|
||||
|
||||
// If the compiler admits that it is not ready for C++11, why torture it?
|
||||
// Hopefully, this will speed up the test.
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#error "This is not a C++ compiler"
|
||||
|
||||
#elif __cplusplus < 201103L
|
||||
|
||||
#error "This is not a C++11 compiler"
|
||||
|
||||
#else
|
||||
|
||||
namespace cxx11
|
||||
{
|
||||
|
||||
namespace test_static_assert
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace test_final_override
|
||||
{
|
||||
|
||||
struct Base
|
||||
{
|
||||
virtual void f() {}
|
||||
};
|
||||
|
||||
struct Derived : public Base
|
||||
{
|
||||
virtual void f() override {}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace test_double_right_angle_brackets
|
||||
{
|
||||
|
||||
template < typename T >
|
||||
struct check {};
|
||||
|
||||
typedef check<void> single_type;
|
||||
typedef check<check<void>> double_type;
|
||||
typedef check<check<check<void>>> triple_type;
|
||||
typedef check<check<check<check<void>>>> quadruple_type;
|
||||
|
||||
}
|
||||
|
||||
namespace test_decltype
|
||||
{
|
||||
|
||||
int
|
||||
f()
|
||||
{
|
||||
int a = 1;
|
||||
decltype(a) b = 2;
|
||||
return a + b;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_type_deduction
|
||||
{
|
||||
|
||||
template < typename T1, typename T2 >
|
||||
struct is_same
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
struct is_same<T, T>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template < typename T1, typename T2 >
|
||||
auto
|
||||
add(T1 a1, T2 a2) -> decltype(a1 + a2)
|
||||
{
|
||||
return a1 + a2;
|
||||
}
|
||||
|
||||
int
|
||||
test(const int c, volatile int v)
|
||||
{
|
||||
static_assert(is_same<int, decltype(0)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(c)>::value == false, "");
|
||||
static_assert(is_same<int, decltype(v)>::value == false, "");
|
||||
auto ac = c;
|
||||
auto av = v;
|
||||
auto sumi = ac + av + 'x';
|
||||
auto sumf = ac + av + 1.0;
|
||||
static_assert(is_same<int, decltype(ac)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(av)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(sumi)>::value == true, "");
|
||||
static_assert(is_same<int, decltype(sumf)>::value == false, "");
|
||||
static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
|
||||
return (sumf > 0.0) ? sumi : add(c, v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_noexcept
|
||||
{
|
||||
|
||||
int f() { return 0; }
|
||||
int g() noexcept { return 0; }
|
||||
|
||||
static_assert(noexcept(f()) == false, "");
|
||||
static_assert(noexcept(g()) == true, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_constexpr
|
||||
{
|
||||
|
||||
template < typename CharT >
|
||||
unsigned long constexpr
|
||||
strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
|
||||
{
|
||||
return *s ? strlen_c_r(s + 1, acc + 1) : acc;
|
||||
}
|
||||
|
||||
template < typename CharT >
|
||||
unsigned long constexpr
|
||||
strlen_c(const CharT *const s) noexcept
|
||||
{
|
||||
return strlen_c_r(s, 0UL);
|
||||
}
|
||||
|
||||
static_assert(strlen_c("") == 0UL, "");
|
||||
static_assert(strlen_c("1") == 1UL, "");
|
||||
static_assert(strlen_c("example") == 7UL, "");
|
||||
static_assert(strlen_c("another\0example") == 7UL, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_rvalue_references
|
||||
{
|
||||
|
||||
template < int N >
|
||||
struct answer
|
||||
{
|
||||
static constexpr int value = N;
|
||||
};
|
||||
|
||||
answer<1> f(int&) { return answer<1>(); }
|
||||
answer<2> f(const int&) { return answer<2>(); }
|
||||
answer<3> f(int&&) { return answer<3>(); }
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
int i = 0;
|
||||
const int c = 0;
|
||||
static_assert(decltype(f(i))::value == 1, "");
|
||||
static_assert(decltype(f(c))::value == 2, "");
|
||||
static_assert(decltype(f(0))::value == 3, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_uniform_initialization
|
||||
{
|
||||
|
||||
struct test
|
||||
{
|
||||
static const int zero {};
|
||||
static const int one {1};
|
||||
};
|
||||
|
||||
static_assert(test::zero == 0, "");
|
||||
static_assert(test::one == 1, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_lambdas
|
||||
{
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
auto lambda1 = [](){};
|
||||
auto lambda2 = lambda1;
|
||||
lambda1();
|
||||
lambda2();
|
||||
}
|
||||
|
||||
int
|
||||
test2()
|
||||
{
|
||||
auto a = [](int i, int j){ return i + j; }(1, 2);
|
||||
auto b = []() -> int { return '0'; }();
|
||||
auto c = [=](){ return a + b; }();
|
||||
auto d = [&](){ return c; }();
|
||||
auto e = [a, &b](int x) mutable {
|
||||
const auto identity = [](int y){ return y; };
|
||||
for (auto i = 0; i < a; ++i)
|
||||
a += b--;
|
||||
return x + identity(a + b);
|
||||
}(0);
|
||||
return a + b + c + d + e;
|
||||
}
|
||||
|
||||
int
|
||||
test3()
|
||||
{
|
||||
const auto nullary = [](){ return 0; };
|
||||
const auto unary = [](int x){ return x; };
|
||||
using nullary_t = decltype(nullary);
|
||||
using unary_t = decltype(unary);
|
||||
const auto higher1st = [](nullary_t f){ return f(); };
|
||||
const auto higher2nd = [unary](nullary_t f1){
|
||||
return [unary, f1](unary_t f2){ return f2(unary(f1())); };
|
||||
};
|
||||
return higher1st(nullary) + higher2nd(nullary)(unary);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_variadic_templates
|
||||
{
|
||||
|
||||
template <int...>
|
||||
struct sum;
|
||||
|
||||
template <int N0, int... N1toN>
|
||||
struct sum<N0, N1toN...>
|
||||
{
|
||||
static constexpr auto value = N0 + sum<N1toN...>::value;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct sum<>
|
||||
{
|
||||
static constexpr auto value = 0;
|
||||
};
|
||||
|
||||
static_assert(sum<>::value == 0, "");
|
||||
static_assert(sum<1>::value == 1, "");
|
||||
static_assert(sum<23>::value == 23, "");
|
||||
static_assert(sum<1, 2>::value == 3, "");
|
||||
static_assert(sum<5, 5, 11>::value == 21, "");
|
||||
static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
|
||||
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
|
||||
// Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
|
||||
// because of this.
|
||||
namespace test_template_alias_sfinae
|
||||
{
|
||||
|
||||
struct foo {};
|
||||
|
||||
template<typename T>
|
||||
using member = typename T::member_type;
|
||||
|
||||
template<typename T>
|
||||
void func(...) {}
|
||||
|
||||
template<typename T>
|
||||
void func(member<T>*) {}
|
||||
|
||||
void test();
|
||||
|
||||
void test() { func<foo>(0); }
|
||||
|
||||
}
|
||||
|
||||
} // namespace cxx11
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
|
||||
]])
|
||||
|
||||
|
||||
dnl Tests for new features in C++14
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
|
||||
|
||||
// If the compiler admits that it is not ready for C++14, why torture it?
|
||||
// Hopefully, this will speed up the test.
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#error "This is not a C++ compiler"
|
||||
|
||||
#elif __cplusplus < 201402L
|
||||
|
||||
#error "This is not a C++14 compiler"
|
||||
|
||||
#else
|
||||
|
||||
namespace cxx14
|
||||
{
|
||||
|
||||
namespace test_polymorphic_lambdas
|
||||
{
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
const auto lambda = [](auto&&... args){
|
||||
const auto istiny = [](auto x){
|
||||
return (sizeof(x) == 1UL) ? 1 : 0;
|
||||
};
|
||||
const int aretiny[] = { istiny(args)... };
|
||||
return aretiny[0];
|
||||
};
|
||||
return lambda(1, 1L, 1.0f, '1');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_binary_literals
|
||||
{
|
||||
|
||||
constexpr auto ivii = 0b0000000000101010;
|
||||
static_assert(ivii == 42, "wrong value");
|
||||
|
||||
}
|
||||
|
||||
namespace test_generalized_constexpr
|
||||
{
|
||||
|
||||
template < typename CharT >
|
||||
constexpr unsigned long
|
||||
strlen_c(const CharT *const s) noexcept
|
||||
{
|
||||
auto length = 0UL;
|
||||
for (auto p = s; *p; ++p)
|
||||
++length;
|
||||
return length;
|
||||
}
|
||||
|
||||
static_assert(strlen_c("") == 0UL, "");
|
||||
static_assert(strlen_c("x") == 1UL, "");
|
||||
static_assert(strlen_c("test") == 4UL, "");
|
||||
static_assert(strlen_c("another\0test") == 7UL, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_lambda_init_capture
|
||||
{
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
auto x = 0;
|
||||
const auto lambda1 = [a = x](int b){ return a + b; };
|
||||
const auto lambda2 = [a = lambda1(x)](){ return a; };
|
||||
return lambda2();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_digit_separators
|
||||
{
|
||||
|
||||
constexpr auto ten_million = 100'000'000;
|
||||
static_assert(ten_million == 100000000, "");
|
||||
|
||||
}
|
||||
|
||||
namespace test_return_type_deduction
|
||||
{
|
||||
|
||||
auto f(int& x) { return x; }
|
||||
decltype(auto) g(int& x) { return x; }
|
||||
|
||||
template < typename T1, typename T2 >
|
||||
struct is_same
|
||||
{
|
||||
static constexpr auto value = false;
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
struct is_same<T, T>
|
||||
{
|
||||
static constexpr auto value = true;
|
||||
};
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
auto x = 0;
|
||||
static_assert(is_same<int, decltype(f(x))>::value, "");
|
||||
static_assert(is_same<int&, decltype(g(x))>::value, "");
|
||||
return x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace cxx14
|
||||
|
||||
#endif // __cplusplus >= 201402L
|
||||
|
||||
]])
|
||||
|
||||
|
||||
dnl Tests for new features in C++17
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
|
||||
|
||||
// If the compiler admits that it is not ready for C++17, why torture it?
|
||||
// Hopefully, this will speed up the test.
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#error "This is not a C++ compiler"
|
||||
|
||||
#elif __cplusplus < 201703L
|
||||
|
||||
#error "This is not a C++17 compiler"
|
||||
|
||||
#else
|
||||
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
namespace cxx17
|
||||
{
|
||||
|
||||
namespace test_constexpr_lambdas
|
||||
{
|
||||
|
||||
constexpr int foo = [](){return 42;}();
|
||||
|
||||
}
|
||||
|
||||
namespace test::nested_namespace::definitions
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
namespace test_fold_expression
|
||||
{
|
||||
|
||||
template<typename... Args>
|
||||
int multiply(Args... args)
|
||||
{
|
||||
return (args * ... * 1);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
bool all(Args... args)
|
||||
{
|
||||
return (args && ...);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_extended_static_assert
|
||||
{
|
||||
|
||||
static_assert (true);
|
||||
|
||||
}
|
||||
|
||||
namespace test_auto_brace_init_list
|
||||
{
|
||||
|
||||
auto foo = {5};
|
||||
auto bar {5};
|
||||
|
||||
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
|
||||
static_assert(std::is_same<int, decltype(bar)>::value);
|
||||
}
|
||||
|
||||
namespace test_typename_in_template_template_parameter
|
||||
{
|
||||
|
||||
template<template<typename> typename X> struct D;
|
||||
|
||||
}
|
||||
|
||||
namespace test_fallthrough_nodiscard_maybe_unused_attributes
|
||||
{
|
||||
|
||||
int f1()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
|
||||
[[nodiscard]] int f2()
|
||||
{
|
||||
[[maybe_unused]] auto unused = f1();
|
||||
|
||||
switch (f1())
|
||||
{
|
||||
case 17:
|
||||
f1();
|
||||
[[fallthrough]];
|
||||
case 42:
|
||||
f1();
|
||||
}
|
||||
return f1();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_extended_aggregate_initialization
|
||||
{
|
||||
|
||||
struct base1
|
||||
{
|
||||
int b1, b2 = 42;
|
||||
};
|
||||
|
||||
struct base2
|
||||
{
|
||||
base2() {
|
||||
b3 = 42;
|
||||
}
|
||||
int b3;
|
||||
};
|
||||
|
||||
struct derived : base1, base2
|
||||
{
|
||||
int d;
|
||||
};
|
||||
|
||||
derived d1 {{1, 2}, {}, 4}; // full initialization
|
||||
derived d2 {{}, {}, 4}; // value-initialized bases
|
||||
|
||||
}
|
||||
|
||||
namespace test_general_range_based_for_loop
|
||||
{
|
||||
|
||||
struct iter
|
||||
{
|
||||
int i;
|
||||
|
||||
int& operator* ()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
const int& operator* () const
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
iter& operator++()
|
||||
{
|
||||
++i;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct sentinel
|
||||
{
|
||||
int i;
|
||||
};
|
||||
|
||||
bool operator== (const iter& i, const sentinel& s)
|
||||
{
|
||||
return i.i == s.i;
|
||||
}
|
||||
|
||||
bool operator!= (const iter& i, const sentinel& s)
|
||||
{
|
||||
return !(i == s);
|
||||
}
|
||||
|
||||
struct range
|
||||
{
|
||||
iter begin() const
|
||||
{
|
||||
return {0};
|
||||
}
|
||||
|
||||
sentinel end() const
|
||||
{
|
||||
return {5};
|
||||
}
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
range r {};
|
||||
|
||||
for (auto i : r)
|
||||
{
|
||||
[[maybe_unused]] auto v = i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_lambda_capture_asterisk_this_by_value
|
||||
{
|
||||
|
||||
struct t
|
||||
{
|
||||
int i;
|
||||
int foo()
|
||||
{
|
||||
return [*this]()
|
||||
{
|
||||
return i;
|
||||
}();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace test_enum_class_construction
|
||||
{
|
||||
|
||||
enum class byte : unsigned char
|
||||
{};
|
||||
|
||||
byte foo {42};
|
||||
|
||||
}
|
||||
|
||||
namespace test_constexpr_if
|
||||
{
|
||||
|
||||
template <bool cond>
|
||||
int f ()
|
||||
{
|
||||
if constexpr(cond)
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_selection_statement_with_initializer
|
||||
{
|
||||
|
||||
int f()
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
|
||||
int f2()
|
||||
{
|
||||
if (auto i = f(); i > 0)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
switch (auto i = f(); i + 4)
|
||||
{
|
||||
case 17:
|
||||
return 2;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_template_argument_deduction_for_class_templates
|
||||
{
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct pair
|
||||
{
|
||||
pair (T1 p1, T2 p2)
|
||||
: m1 {p1},
|
||||
m2 {p2}
|
||||
{}
|
||||
|
||||
T1 m1;
|
||||
T2 m2;
|
||||
};
|
||||
|
||||
void f()
|
||||
{
|
||||
[[maybe_unused]] auto p = pair{13, 42u};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace test_non_type_auto_template_parameters
|
||||
{
|
||||
|
||||
template <auto n>
|
||||
struct B
|
||||
{};
|
||||
|
||||
B<5> b1;
|
||||
B<'a'> b2;
|
||||
|
||||
}
|
||||
|
||||
namespace test_structured_bindings
|
||||
{
|
||||
|
||||
int arr[2] = { 1, 2 };
|
||||
std::pair<int, int> pr = { 1, 2 };
|
||||
|
||||
auto f1() -> int(&)[2]
|
||||
{
|
||||
return arr;
|
||||
}
|
||||
|
||||
auto f2() -> std::pair<int, int>&
|
||||
{
|
||||
return pr;
|
||||
}
|
||||
|
||||
struct S
|
||||
{
|
||||
int x1 : 2;
|
||||
volatile double y1;
|
||||
};
|
||||
|
||||
S f3()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
auto [ x1, y1 ] = f1();
|
||||
auto& [ xr1, yr1 ] = f1();
|
||||
auto [ x2, y2 ] = f2();
|
||||
auto& [ xr2, yr2 ] = f2();
|
||||
const auto [ x3, y3 ] = f3();
|
||||
|
||||
}
|
||||
|
||||
namespace test_exception_spec_type_system
|
||||
{
|
||||
|
||||
struct Good {};
|
||||
struct Bad {};
|
||||
|
||||
void g1() noexcept;
|
||||
void g2();
|
||||
|
||||
template<typename T>
|
||||
Bad
|
||||
f(T*, T*);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
Good
|
||||
f(T1*, T2*);
|
||||
|
||||
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
|
||||
|
||||
}
|
||||
|
||||
namespace test_inline_variables
|
||||
{
|
||||
|
||||
template<class T> void f(T)
|
||||
{}
|
||||
|
||||
template<class T> inline T g(T)
|
||||
{
|
||||
return T{};
|
||||
}
|
||||
|
||||
template<> inline void f<>(int)
|
||||
{}
|
||||
|
||||
template<> int g<>(int)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace cxx17
|
||||
|
||||
#endif // __cplusplus < 201703L
|
||||
|
||||
]])
|
||||
@@ -1,133 +0,0 @@
|
||||
# ============================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
|
||||
# ============================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the C++11
|
||||
# standard; if necessary, add switches to CXXFLAGS to enable support.
|
||||
#
|
||||
# The first argument, if specified, indicates whether you insist on an
|
||||
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
|
||||
# -std=c++11). If neither is specified, you get whatever works, with
|
||||
# preference for an extended mode.
|
||||
#
|
||||
# The second argument, if specified 'mandatory' or if left unspecified,
|
||||
# indicates that baseline C++11 support is required and that the macro
|
||||
# should error out if no mode with that support is found. If specified
|
||||
# 'optional', then configuration proceeds regardless, after defining
|
||||
# HAVE_CXX11 if and only if a supporting mode is found.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 3
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
typedef check<check<bool>> right_angle_brackets;
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);
|
||||
|
||||
auto d = a;
|
||||
])
|
||||
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
||||
m4_if([$1], [], [],
|
||||
[$1], [ext], [],
|
||||
[$1], [noext], [],
|
||||
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
|
||||
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
|
||||
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
|
||||
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
|
||||
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl
|
||||
AC_LANG_PUSH([C++])dnl
|
||||
ac_success=no
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
|
||||
ax_cv_cxx_compile_cxx11,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[ax_cv_cxx_compile_cxx11=yes],
|
||||
[ax_cv_cxx_compile_cxx11=no])])
|
||||
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
|
||||
ac_success=yes
|
||||
fi
|
||||
|
||||
m4_if([$1], [noext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for switch in -std=gnu++11 -std=gnu++0x; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
|
||||
m4_if([$1], [ext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for switch in -std=c++11 -std=c++0x; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
AC_LANG_POP([C++])
|
||||
if test x$ax_cxx_compile_cxx11_required = xtrue; then
|
||||
if test x$ac_success = xno; then
|
||||
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
|
||||
fi
|
||||
else
|
||||
if test x$ac_success = xno; then
|
||||
HAVE_CXX11=0
|
||||
AC_MSG_NOTICE([No compiler with C++11 support was found])
|
||||
else
|
||||
HAVE_CXX11=1
|
||||
AC_DEFINE(HAVE_CXX11,1,
|
||||
[define if the compiler supports basic C++11 syntax])
|
||||
fi
|
||||
|
||||
AC_SUBST(HAVE_CXX11)
|
||||
fi
|
||||
])
|
||||
@@ -8,11 +8,8 @@ set_source_files_properties(${cxx_sources} PROPERTIES
|
||||
COMPILE_FLAGS "${WARNCXXFLAGS} ${CXX1XCXXFLAGS}")
|
||||
|
||||
include_directories(
|
||||
"${CMAKE_SOURCE_DIR}/lib/includes"
|
||||
"${CMAKE_BINARY_DIR}/lib/includes"
|
||||
"${CMAKE_SOURCE_DIR}/lib"
|
||||
"${CMAKE_SOURCE_DIR}/src/includes"
|
||||
"${CMAKE_SOURCE_DIR}/third-party"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../third-party"
|
||||
|
||||
${JEMALLOC_INCLUDE_DIRS}
|
||||
${SPDYLAY_INCLUDE_DIRS}
|
||||
@@ -48,7 +45,7 @@ if(ENABLE_APP)
|
||||
set(NGHTTP_SOURCES
|
||||
${HELPER_OBJECTS}
|
||||
nghttp.cc
|
||||
ssl.cc
|
||||
tls.cc
|
||||
)
|
||||
if(HAVE_LIBXML2)
|
||||
list(APPEND NGHTTP_SOURCES HtmlParser.cc)
|
||||
@@ -58,7 +55,7 @@ if(ENABLE_APP)
|
||||
set(NGHTTPD_SOURCES
|
||||
${HELPER_OBJECTS}
|
||||
nghttpd.cc
|
||||
ssl.cc
|
||||
tls.cc
|
||||
HttpServer.cc
|
||||
)
|
||||
|
||||
@@ -67,7 +64,7 @@ if(ENABLE_APP)
|
||||
util.cc
|
||||
http2.cc h2load.cc
|
||||
timegm.c
|
||||
ssl.cc
|
||||
tls.cc
|
||||
h2load_http2_session.cc
|
||||
h2load_http1_session.cc
|
||||
)
|
||||
@@ -82,7 +79,7 @@ if(ENABLE_APP)
|
||||
set(NGHTTPX_SRCS
|
||||
util.cc http2.cc timegm.c
|
||||
app_helper.cc
|
||||
ssl.cc
|
||||
tls.cc
|
||||
shrpx_config.cc
|
||||
shrpx_accept_handler.cc
|
||||
shrpx_connection_handler.cc
|
||||
@@ -98,7 +95,7 @@ if(ENABLE_APP)
|
||||
shrpx_log.cc
|
||||
shrpx_http.cc
|
||||
shrpx_io_control.cc
|
||||
shrpx_ssl.cc
|
||||
shrpx_tls.cc
|
||||
shrpx_worker.cc
|
||||
shrpx_log_config.cc
|
||||
shrpx_connect_blocker.cc
|
||||
@@ -152,7 +149,7 @@ if(ENABLE_APP)
|
||||
if(HAVE_CUNIT)
|
||||
set(NGHTTPX_UNITTEST_SOURCES
|
||||
shrpx-unittest.cc
|
||||
shrpx_ssl_test.cc
|
||||
shrpx_tls_test.cc
|
||||
shrpx_downstream_test.cc
|
||||
shrpx_config_test.cc
|
||||
shrpx_worker_test.cc
|
||||
@@ -216,7 +213,7 @@ endif()
|
||||
if(ENABLE_ASIO_LIB)
|
||||
set(NGHTTP2_ASIO_SOURCES
|
||||
util.cc http2.cc
|
||||
ssl.cc
|
||||
tls.cc
|
||||
timegm.c
|
||||
asio_common.cc
|
||||
asio_io_service_pool.cc
|
||||
@@ -252,6 +249,11 @@ if(ENABLE_ASIO_LIB)
|
||||
${OPENSSL_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
target_include_directories(nghttp2_asio INTERFACE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../lib/includes"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../lib/includes"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
|
||||
)
|
||||
target_link_libraries(nghttp2_asio
|
||||
nghttp2
|
||||
${OPENSSL_LIBRARIES}
|
||||
@@ -261,7 +263,9 @@ if(ENABLE_ASIO_LIB)
|
||||
VERSION 1.0.0 SOVERSION 1)
|
||||
|
||||
install(TARGETS nghttp2_asio
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2_asio.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user