http: simplify checkInvalidHeaderChar
In the spirit of 17399, we can also simplify checkInvalidHeaderChar to use regex matching instead of a loop. This makes it faster on long matches and slower on short matches or non-matches. This change also includes some sample data from an AcmeAir benchmark run, as a rough proxy for real-world data.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
- http
Benchmark results
improvement confidence p.value
http\\check_invalid_header_char.js n=1000000 input="\177" -56.65 % *** 1.320705e-40
http\\check_invalid_header_char.js n=1000000 input="" -70.08 % *** 1.329603e-60
http\\check_invalid_header_char.js n=1000000 input="\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tFoo bar baz" 198.82 % *** 1.052799e-76
http\\check_invalid_header_char.js n=1000000 input="1" -50.00 % *** 7.800619e-22
http\\check_invalid_header_char.js n=1000000 input="20091" -6.44 % *** 7.491287e-04
http\\check_invalid_header_char.js n=1000000 input="ä,-æ-╪å`¢" -33.16 % *** 5.648190e-21
http\\check_invalid_header_char.js n=1000000 input="close" 22.88 % *** 1.497247e-25
http\\check_invalid_header_char.js n=1000000 input="en-US" 24.31 % *** 4.582121e-46
http\\check_invalid_header_char.js n=1000000 input="foo\\nbar" -5.84 % *** 2.581802e-08
http\\check_invalid_header_char.js n=1000000 input="group_acmeair" 19.81 % *** 2.764867e-37
http\\check_invalid_header_char.js n=1000000 input="gzip" 4.54 % * 1.921983e-02
http\\check_invalid_header_char.js n=1000000 input="Here is a value that is real..."(truncated) 280.31 % *** 8.462204e-37
http\\check_invalid_header_char.js n=1000000 input="keep-alive" 80.49 % *** 4.132616e-53
http\\check_invalid_header_char.js n=1000000 input="private" 41.84 % *** 1.856953e-15
http\\check_invalid_header_char.js n=1000000 input="SAMEORIGIN" 82.00 % *** 2.317592e-50
http\\check_invalid_header_char.js n=1000000 input="Sat, 07 May 2016 16:54:48 GMT" 199.94 % *** 2.698766e-29
http\\check_invalid_header_char.js n=1000000 input="text/html; charset=utf-8" 176.87 % *** 1.854601e-33
http\\check_invalid_header_char.js n=1000000 input="text/plain" 75.47 % *** 1.241438e-24