protocol-quic 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/ext/ngtcp2/AUTHORS +44 -0
- data/ext/ngtcp2/CMakeLists.txt +431 -0
- data/ext/ngtcp2/CMakeOptions.txt +17 -0
- data/ext/ngtcp2/COPYING +22 -0
- data/ext/ngtcp2/ChangeLog +0 -0
- data/ext/ngtcp2/Makefile.am +60 -0
- data/ext/ngtcp2/NEWS +0 -0
- data/ext/ngtcp2/README +1 -0
- data/ext/ngtcp2/README.rst +258 -0
- data/ext/ngtcp2/ci/build_boringssl.sh +10 -0
- data/ext/ngtcp2/ci/build_nghttp3.sh +9 -0
- data/ext/ngtcp2/ci/build_openssl1.sh +8 -0
- data/ext/ngtcp2/ci/build_openssl1_cross.sh +9 -0
- data/ext/ngtcp2/ci/build_openssl3.sh +8 -0
- data/ext/ngtcp2/ci/build_picotls.sh +26 -0
- data/ext/ngtcp2/ci/build_wolfssl.sh +9 -0
- data/ext/ngtcp2/ci/gen-certificate.sh +8 -0
- data/ext/ngtcp2/cmake/ExtractValidFlags.cmake +31 -0
- data/ext/ngtcp2/cmake/FindCUnit.cmake +40 -0
- data/ext/ngtcp2/cmake/FindJemalloc.cmake +40 -0
- data/ext/ngtcp2/cmake/FindLibev.cmake +38 -0
- data/ext/ngtcp2/cmake/FindLibnghttp3.cmake +41 -0
- data/ext/ngtcp2/cmake/Findwolfssl.cmake +41 -0
- data/ext/ngtcp2/cmake/Version.cmake +11 -0
- data/ext/ngtcp2/cmakeconfig.h.in +36 -0
- data/ext/ngtcp2/configure.ac +755 -0
- data/ext/ngtcp2/crypto/CMakeLists.txt +56 -0
- data/ext/ngtcp2/crypto/Makefile.am +49 -0
- data/ext/ngtcp2/crypto/boringssl/CMakeLists.txt +64 -0
- data/ext/ngtcp2/crypto/boringssl/Makefile.am +39 -0
- data/ext/ngtcp2/crypto/boringssl/boringssl.c +630 -0
- data/ext/ngtcp2/crypto/boringssl/libngtcp2_crypto_boringssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/gnutls/CMakeLists.txt +86 -0
- data/ext/ngtcp2/crypto/gnutls/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/gnutls/gnutls.c +644 -0
- data/ext/ngtcp2/crypto/gnutls/libngtcp2_crypto_gnutls.pc.in +33 -0
- data/ext/ngtcp2/crypto/includes/CMakeLists.txt +56 -0
- data/ext/ngtcp2/crypto/includes/Makefile.am +45 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto.h +893 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_boringssl.h +104 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_gnutls.h +107 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_openssl.h +132 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_picotls.h +246 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_wolfssl.h +106 -0
- data/ext/ngtcp2/crypto/openssl/CMakeLists.txt +86 -0
- data/ext/ngtcp2/crypto/openssl/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/openssl/libngtcp2_crypto_openssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/openssl/openssl.c +807 -0
- data/ext/ngtcp2/crypto/picotls/CMakeLists.txt +65 -0
- data/ext/ngtcp2/crypto/picotls/Makefile.am +39 -0
- data/ext/ngtcp2/crypto/picotls/libngtcp2_crypto_picotls.pc.in +33 -0
- data/ext/ngtcp2/crypto/picotls/picotls.c +707 -0
- data/ext/ngtcp2/crypto/shared.c +1431 -0
- data/ext/ngtcp2/crypto/shared.h +350 -0
- data/ext/ngtcp2/crypto/wolfssl/CMakeLists.txt +84 -0
- data/ext/ngtcp2/crypto/wolfssl/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/wolfssl/libngtcp2_crypto_wolfssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/wolfssl/wolfssl.c +534 -0
- data/ext/ngtcp2/doc/Makefile.am +65 -0
- data/ext/ngtcp2/doc/make.bat +35 -0
- data/ext/ngtcp2/doc/mkapiref.py +356 -0
- data/ext/ngtcp2/doc/source/conf.py.in +94 -0
- data/ext/ngtcp2/doc/source/index.rst +22 -0
- data/ext/ngtcp2/doc/source/programmers-guide.rst +476 -0
- data/ext/ngtcp2/docker/Dockerfile +39 -0
- data/ext/ngtcp2/examples/CMakeLists.txt +361 -0
- data/ext/ngtcp2/examples/Makefile.am +228 -0
- data/ext/ngtcp2/examples/client.cc +3049 -0
- data/ext/ngtcp2/examples/client.h +192 -0
- data/ext/ngtcp2/examples/client_base.cc +202 -0
- data/ext/ngtcp2/examples/client_base.h +213 -0
- data/ext/ngtcp2/examples/debug.cc +298 -0
- data/ext/ngtcp2/examples/debug.h +124 -0
- data/ext/ngtcp2/examples/examplestest.cc +84 -0
- data/ext/ngtcp2/examples/gtlssimpleclient.c +720 -0
- data/ext/ngtcp2/examples/h09client.cc +2601 -0
- data/ext/ngtcp2/examples/h09client.h +196 -0
- data/ext/ngtcp2/examples/h09server.cc +3024 -0
- data/ext/ngtcp2/examples/h09server.h +237 -0
- data/ext/ngtcp2/examples/http.cc +138 -0
- data/ext/ngtcp2/examples/http.h +44 -0
- data/ext/ngtcp2/examples/network.h +80 -0
- data/ext/ngtcp2/examples/server.cc +3731 -0
- data/ext/ngtcp2/examples/server.h +256 -0
- data/ext/ngtcp2/examples/server_base.cc +58 -0
- data/ext/ngtcp2/examples/server_base.h +195 -0
- data/ext/ngtcp2/examples/shared.cc +385 -0
- data/ext/ngtcp2/examples/shared.h +96 -0
- data/ext/ngtcp2/examples/simpleclient.c +683 -0
- data/ext/ngtcp2/examples/template.h +71 -0
- data/ext/ngtcp2/examples/tests/README.rst +60 -0
- data/ext/ngtcp2/examples/tests/__init__.py +0 -0
- data/ext/ngtcp2/examples/tests/config.ini.in +32 -0
- data/ext/ngtcp2/examples/tests/conftest.py +28 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/__init__.py +6 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/certs.py +476 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/client.py +187 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/env.py +191 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/log.py +101 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/server.py +137 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/tls.py +983 -0
- data/ext/ngtcp2/examples/tests/test_01_handshake.py +30 -0
- data/ext/ngtcp2/examples/tests/test_02_resume.py +46 -0
- data/ext/ngtcp2/examples/tests/test_03_earlydata.py +56 -0
- data/ext/ngtcp2/examples/tests/test_04_clientcert.py +57 -0
- data/ext/ngtcp2/examples/tests/test_05_ciphers.py +46 -0
- data/ext/ngtcp2/examples/tls_client_context.h +52 -0
- data/ext/ngtcp2/examples/tls_client_context_boringssl.cc +126 -0
- data/ext/ngtcp2/examples/tls_client_context_boringssl.h +49 -0
- data/ext/ngtcp2/examples/tls_client_context_gnutls.cc +74 -0
- data/ext/ngtcp2/examples/tls_client_context_gnutls.h +50 -0
- data/ext/ngtcp2/examples/tls_client_context_openssl.cc +137 -0
- data/ext/ngtcp2/examples/tls_client_context_openssl.h +49 -0
- data/ext/ngtcp2/examples/tls_client_context_picotls.cc +158 -0
- data/ext/ngtcp2/examples/tls_client_context_picotls.h +53 -0
- data/ext/ngtcp2/examples/tls_client_context_wolfssl.cc +177 -0
- data/ext/ngtcp2/examples/tls_client_context_wolfssl.h +51 -0
- data/ext/ngtcp2/examples/tls_client_session.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_boringssl.cc +110 -0
- data/ext/ngtcp2/examples/tls_client_session_boringssl.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_gnutls.cc +190 -0
- data/ext/ngtcp2/examples/tls_client_session_gnutls.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_openssl.cc +113 -0
- data/ext/ngtcp2/examples/tls_client_session_openssl.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_picotls.cc +147 -0
- data/ext/ngtcp2/examples/tls_client_session_picotls.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_wolfssl.cc +160 -0
- data/ext/ngtcp2/examples/tls_client_session_wolfssl.h +52 -0
- data/ext/ngtcp2/examples/tls_server_context.h +52 -0
- data/ext/ngtcp2/examples/tls_server_context_boringssl.cc +257 -0
- data/ext/ngtcp2/examples/tls_server_context_boringssl.h +54 -0
- data/ext/ngtcp2/examples/tls_server_context_gnutls.cc +99 -0
- data/ext/ngtcp2/examples/tls_server_context_gnutls.h +59 -0
- data/ext/ngtcp2/examples/tls_server_context_openssl.cc +338 -0
- data/ext/ngtcp2/examples/tls_server_context_openssl.h +54 -0
- data/ext/ngtcp2/examples/tls_server_context_picotls.cc +321 -0
- data/ext/ngtcp2/examples/tls_server_context_picotls.h +58 -0
- data/ext/ngtcp2/examples/tls_server_context_wolfssl.cc +284 -0
- data/ext/ngtcp2/examples/tls_server_context_wolfssl.h +55 -0
- data/ext/ngtcp2/examples/tls_server_session.h +52 -0
- data/ext/ngtcp2/examples/tls_server_session_boringssl.cc +84 -0
- data/ext/ngtcp2/examples/tls_server_session_boringssl.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_gnutls.cc +155 -0
- data/ext/ngtcp2/examples/tls_server_session_gnutls.h +46 -0
- data/ext/ngtcp2/examples/tls_server_session_openssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_server_session_openssl.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_picotls.cc +70 -0
- data/ext/ngtcp2/examples/tls_server_session_picotls.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_wolfssl.cc +55 -0
- data/ext/ngtcp2/examples/tls_server_session_wolfssl.h +47 -0
- data/ext/ngtcp2/examples/tls_session_base_gnutls.cc +87 -0
- data/ext/ngtcp2/examples/tls_session_base_gnutls.h +51 -0
- data/ext/ngtcp2/examples/tls_session_base_openssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_session_base_openssl.h +52 -0
- data/ext/ngtcp2/examples/tls_session_base_picotls.cc +56 -0
- data/ext/ngtcp2/examples/tls_session_base_picotls.h +54 -0
- data/ext/ngtcp2/examples/tls_session_base_wolfssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_session_base_wolfssl.h +54 -0
- data/ext/ngtcp2/examples/tls_shared_picotls.cc +59 -0
- data/ext/ngtcp2/examples/tls_shared_picotls.h +36 -0
- data/ext/ngtcp2/examples/util.cc +646 -0
- data/ext/ngtcp2/examples/util.h +361 -0
- data/ext/ngtcp2/examples/util_gnutls.cc +136 -0
- data/ext/ngtcp2/examples/util_openssl.cc +131 -0
- data/ext/ngtcp2/examples/util_test.cc +237 -0
- data/ext/ngtcp2/examples/util_test.h +45 -0
- data/ext/ngtcp2/examples/util_wolfssl.cc +130 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/ack +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/ack_ecn +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/connection_close +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/crypto +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/data_blocked +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram_len +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_data +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_stream_data +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_streams +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/new_connection_id +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/new_token +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/path_challenge +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/path_response +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/reset_stream +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/retire_connection_id +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stop_sending +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_data_blocked +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_len +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/streams_blocked +0 -0
- data/ext/ngtcp2/fuzz/corpus/ksl/random +0 -0
- data/ext/ngtcp2/fuzz/decode_frame.cc +25 -0
- data/ext/ngtcp2/fuzz/ksl.cc +77 -0
- data/ext/ngtcp2/interop/Dockerfile +39 -0
- data/ext/ngtcp2/interop/run_endpoint.sh +93 -0
- data/ext/ngtcp2/lib/CMakeLists.txt +110 -0
- data/ext/ngtcp2/lib/Makefile.am +122 -0
- data/ext/ngtcp2/lib/includes/CMakeLists.txt +4 -0
- data/ext/ngtcp2/lib/includes/Makefile.am +25 -0
- data/ext/ngtcp2/lib/includes/ngtcp2/ngtcp2.h +5843 -0
- data/ext/ngtcp2/lib/includes/ngtcp2/version.h.in +51 -0
- data/ext/ngtcp2/lib/libngtcp2.pc.in +33 -0
- data/ext/ngtcp2/lib/ngtcp2_acktr.c +335 -0
- data/ext/ngtcp2/lib/ngtcp2_acktr.h +221 -0
- data/ext/ngtcp2/lib/ngtcp2_addr.c +117 -0
- data/ext/ngtcp2/lib/ngtcp2_addr.h +69 -0
- data/ext/ngtcp2/lib/ngtcp2_balloc.c +90 -0
- data/ext/ngtcp2/lib/ngtcp2_balloc.h +91 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr.c +693 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr.h +157 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr2.c +1490 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr2.h +149 -0
- data/ext/ngtcp2/lib/ngtcp2_buf.c +56 -0
- data/ext/ngtcp2/lib/ngtcp2_buf.h +108 -0
- data/ext/ngtcp2/lib/ngtcp2_cc.c +616 -0
- data/ext/ngtcp2/lib/ngtcp2_cc.h +422 -0
- data/ext/ngtcp2/lib/ngtcp2_cid.c +147 -0
- data/ext/ngtcp2/lib/ngtcp2_cid.h +175 -0
- data/ext/ngtcp2/lib/ngtcp2_conn.c +13731 -0
- data/ext/ngtcp2/lib/ngtcp2_conn.h +1119 -0
- data/ext/ngtcp2/lib/ngtcp2_conn_stat.h +131 -0
- data/ext/ngtcp2/lib/ngtcp2_conv.c +291 -0
- data/ext/ngtcp2/lib/ngtcp2_conv.h +208 -0
- data/ext/ngtcp2/lib/ngtcp2_crypto.c +895 -0
- data/ext/ngtcp2/lib/ngtcp2_crypto.h +148 -0
- data/ext/ngtcp2/lib/ngtcp2_err.c +154 -0
- data/ext/ngtcp2/lib/ngtcp2_err.h +34 -0
- data/ext/ngtcp2/lib/ngtcp2_gaptr.c +167 -0
- data/ext/ngtcp2/lib/ngtcp2_gaptr.h +98 -0
- data/ext/ngtcp2/lib/ngtcp2_idtr.c +79 -0
- data/ext/ngtcp2/lib/ngtcp2_idtr.h +89 -0
- data/ext/ngtcp2/lib/ngtcp2_ksl.c +819 -0
- data/ext/ngtcp2/lib/ngtcp2_ksl.h +345 -0
- data/ext/ngtcp2/lib/ngtcp2_log.c +822 -0
- data/ext/ngtcp2/lib/ngtcp2_log.h +123 -0
- data/ext/ngtcp2/lib/ngtcp2_macro.h +58 -0
- data/ext/ngtcp2/lib/ngtcp2_map.c +336 -0
- data/ext/ngtcp2/lib/ngtcp2_map.h +136 -0
- data/ext/ngtcp2/lib/ngtcp2_mem.c +113 -0
- data/ext/ngtcp2/lib/ngtcp2_mem.h +72 -0
- data/ext/ngtcp2/lib/ngtcp2_net.h +136 -0
- data/ext/ngtcp2/lib/ngtcp2_objalloc.c +40 -0
- data/ext/ngtcp2/lib/ngtcp2_objalloc.h +140 -0
- data/ext/ngtcp2/lib/ngtcp2_opl.c +46 -0
- data/ext/ngtcp2/lib/ngtcp2_opl.h +65 -0
- data/ext/ngtcp2/lib/ngtcp2_path.c +77 -0
- data/ext/ngtcp2/lib/ngtcp2_path.h +49 -0
- data/ext/ngtcp2/lib/ngtcp2_pkt.c +2527 -0
- data/ext/ngtcp2/lib/ngtcp2_pkt.h +1235 -0
- data/ext/ngtcp2/lib/ngtcp2_pmtud.c +160 -0
- data/ext/ngtcp2/lib/ngtcp2_pmtud.h +123 -0
- data/ext/ngtcp2/lib/ngtcp2_ppe.c +230 -0
- data/ext/ngtcp2/lib/ngtcp2_ppe.h +153 -0
- data/ext/ngtcp2/lib/ngtcp2_pq.c +164 -0
- data/ext/ngtcp2/lib/ngtcp2_pq.h +126 -0
- data/ext/ngtcp2/lib/ngtcp2_pv.c +172 -0
- data/ext/ngtcp2/lib/ngtcp2_pv.h +194 -0
- data/ext/ngtcp2/lib/ngtcp2_qlog.c +1219 -0
- data/ext/ngtcp2/lib/ngtcp2_qlog.h +161 -0
- data/ext/ngtcp2/lib/ngtcp2_range.c +61 -0
- data/ext/ngtcp2/lib/ngtcp2_range.h +80 -0
- data/ext/ngtcp2/lib/ngtcp2_rcvry.h +40 -0
- data/ext/ngtcp2/lib/ngtcp2_ringbuf.c +121 -0
- data/ext/ngtcp2/lib/ngtcp2_ringbuf.h +132 -0
- data/ext/ngtcp2/lib/ngtcp2_rob.c +319 -0
- data/ext/ngtcp2/lib/ngtcp2_rob.h +197 -0
- data/ext/ngtcp2/lib/ngtcp2_rst.c +138 -0
- data/ext/ngtcp2/lib/ngtcp2_rst.h +86 -0
- data/ext/ngtcp2/lib/ngtcp2_rtb.c +1676 -0
- data/ext/ngtcp2/lib/ngtcp2_rtb.h +468 -0
- data/ext/ngtcp2/lib/ngtcp2_str.c +233 -0
- data/ext/ngtcp2/lib/ngtcp2_str.h +94 -0
- data/ext/ngtcp2/lib/ngtcp2_strm.c +698 -0
- data/ext/ngtcp2/lib/ngtcp2_strm.h +310 -0
- data/ext/ngtcp2/lib/ngtcp2_unreachable.c +71 -0
- data/ext/ngtcp2/lib/ngtcp2_unreachable.h +46 -0
- data/ext/ngtcp2/lib/ngtcp2_vec.c +243 -0
- data/ext/ngtcp2/lib/ngtcp2_vec.h +120 -0
- data/ext/ngtcp2/lib/ngtcp2_version.c +39 -0
- data/ext/ngtcp2/lib/ngtcp2_window_filter.c +99 -0
- data/ext/ngtcp2/lib/ngtcp2_window_filter.h +65 -0
- data/ext/ngtcp2/m4/ax_check_compile_flag.m4 +74 -0
- data/ext/ngtcp2/m4/ax_cxx_compile_stdcxx.m4 +1009 -0
- data/ext/ngtcp2/tests/CMakeLists.txt +68 -0
- data/ext/ngtcp2/tests/Makefile.am +94 -0
- data/ext/ngtcp2/tests/main.c +358 -0
- data/ext/ngtcp2/tests/ngtcp2_acktr_test.c +367 -0
- data/ext/ngtcp2/tests/ngtcp2_acktr_test.h +37 -0
- data/ext/ngtcp2/tests/ngtcp2_conn_test.c +9821 -0
- data/ext/ngtcp2/tests/ngtcp2_conn_test.h +104 -0
- data/ext/ngtcp2/tests/ngtcp2_conv_test.c +430 -0
- data/ext/ngtcp2/tests/ngtcp2_conv_test.h +46 -0
- data/ext/ngtcp2/tests/ngtcp2_crypto_test.c +667 -0
- data/ext/ngtcp2/tests/ngtcp2_crypto_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_gaptr_test.c +127 -0
- data/ext/ngtcp2/tests/ngtcp2_gaptr_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_idtr_test.c +79 -0
- data/ext/ngtcp2/tests/ngtcp2_idtr_test.h +34 -0
- data/ext/ngtcp2/tests/ngtcp2_ksl_test.c +502 -0
- data/ext/ngtcp2/tests/ngtcp2_ksl_test.h +39 -0
- data/ext/ngtcp2/tests/ngtcp2_map_test.c +206 -0
- data/ext/ngtcp2/tests/ngtcp2_map_test.h +38 -0
- data/ext/ngtcp2/tests/ngtcp2_pkt_test.c +1645 -0
- data/ext/ngtcp2/tests/ngtcp2_pkt_test.h +68 -0
- data/ext/ngtcp2/tests/ngtcp2_pmtud_test.c +153 -0
- data/ext/ngtcp2/tests/ngtcp2_pmtud_test.h +34 -0
- data/ext/ngtcp2/tests/ngtcp2_pv_test.c +129 -0
- data/ext/ngtcp2/tests/ngtcp2_pv_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_range_test.c +105 -0
- data/ext/ngtcp2/tests/ngtcp2_range_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.c +91 -0
- data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_rob_test.c +552 -0
- data/ext/ngtcp2/tests/ngtcp2_rob_test.h +37 -0
- data/ext/ngtcp2/tests/ngtcp2_rtb_test.c +470 -0
- data/ext/ngtcp2/tests/ngtcp2_rtb_test.h +38 -0
- data/ext/ngtcp2/tests/ngtcp2_str_test.c +96 -0
- data/ext/ngtcp2/tests/ngtcp2_str_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_strm_test.c +575 -0
- data/ext/ngtcp2/tests/ngtcp2_strm_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_test_helper.c +404 -0
- data/ext/ngtcp2/tests/ngtcp2_test_helper.h +191 -0
- data/ext/ngtcp2/tests/ngtcp2_vec_test.c +426 -0
- data/ext/ngtcp2/tests/ngtcp2_vec_test.h +36 -0
- data/ext/ngtcp2/third-party/CMakeLists.txt +34 -0
- data/ext/ngtcp2/third-party/Makefile.am +31 -0
- data/ext/ngtcp2/third-party/http-parser/AUTHORS +68 -0
- data/ext/ngtcp2/third-party/http-parser/LICENSE-MIT +23 -0
- data/ext/ngtcp2/third-party/http-parser/Makefile +157 -0
- data/ext/ngtcp2/third-party/http-parser/README.md +246 -0
- data/ext/ngtcp2/third-party/http-parser/bench.c +111 -0
- data/ext/ngtcp2/third-party/http-parser/contrib/parsertrace.c +160 -0
- data/ext/ngtcp2/third-party/http-parser/contrib/url_parser.c +47 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.c +2419 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.gyp +111 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.h +431 -0
- data/ext/ngtcp2/third-party/http-parser/test.c +4411 -0
- data/lib/protocol/quic/version.rb +10 -0
- data/lib/protocol/quic.rb +9 -0
- data/license.md +21 -0
- data.tar.gz.sig +1 -0
- metadata +424 -0
- metadata.gz.sig +1 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
# This file is used with the GYP meta build system.
|
2
|
+
# http://code.google.com/p/gyp/
|
3
|
+
# To build try this:
|
4
|
+
# svn co http://gyp.googlecode.com/svn/trunk gyp
|
5
|
+
# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp
|
6
|
+
# ./out/Debug/test
|
7
|
+
{
|
8
|
+
'target_defaults': {
|
9
|
+
'default_configuration': 'Debug',
|
10
|
+
'configurations': {
|
11
|
+
# TODO: hoist these out and put them somewhere common, because
|
12
|
+
# RuntimeLibrary MUST MATCH across the entire project
|
13
|
+
'Debug': {
|
14
|
+
'defines': [ 'DEBUG', '_DEBUG' ],
|
15
|
+
'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ],
|
16
|
+
'msvs_settings': {
|
17
|
+
'VCCLCompilerTool': {
|
18
|
+
'RuntimeLibrary': 1, # static debug
|
19
|
+
},
|
20
|
+
},
|
21
|
+
},
|
22
|
+
'Release': {
|
23
|
+
'defines': [ 'NDEBUG' ],
|
24
|
+
'cflags': [ '-Wall', '-Wextra', '-O3' ],
|
25
|
+
'msvs_settings': {
|
26
|
+
'VCCLCompilerTool': {
|
27
|
+
'RuntimeLibrary': 0, # static release
|
28
|
+
},
|
29
|
+
},
|
30
|
+
}
|
31
|
+
},
|
32
|
+
'msvs_settings': {
|
33
|
+
'VCCLCompilerTool': {
|
34
|
+
},
|
35
|
+
'VCLibrarianTool': {
|
36
|
+
},
|
37
|
+
'VCLinkerTool': {
|
38
|
+
'GenerateDebugInformation': 'true',
|
39
|
+
},
|
40
|
+
},
|
41
|
+
'conditions': [
|
42
|
+
['OS == "win"', {
|
43
|
+
'defines': [
|
44
|
+
'WIN32'
|
45
|
+
],
|
46
|
+
}]
|
47
|
+
],
|
48
|
+
},
|
49
|
+
|
50
|
+
'targets': [
|
51
|
+
{
|
52
|
+
'target_name': 'http_parser',
|
53
|
+
'type': 'static_library',
|
54
|
+
'include_dirs': [ '.' ],
|
55
|
+
'direct_dependent_settings': {
|
56
|
+
'defines': [ 'HTTP_PARSER_STRICT=0' ],
|
57
|
+
'include_dirs': [ '.' ],
|
58
|
+
},
|
59
|
+
'defines': [ 'HTTP_PARSER_STRICT=0' ],
|
60
|
+
'sources': [ './http_parser.c', ],
|
61
|
+
'conditions': [
|
62
|
+
['OS=="win"', {
|
63
|
+
'msvs_settings': {
|
64
|
+
'VCCLCompilerTool': {
|
65
|
+
# Compile as C++. http_parser.c is actually C99, but C++ is
|
66
|
+
# close enough in this case.
|
67
|
+
'CompileAs': 2,
|
68
|
+
},
|
69
|
+
},
|
70
|
+
}]
|
71
|
+
],
|
72
|
+
},
|
73
|
+
|
74
|
+
{
|
75
|
+
'target_name': 'http_parser_strict',
|
76
|
+
'type': 'static_library',
|
77
|
+
'include_dirs': [ '.' ],
|
78
|
+
'direct_dependent_settings': {
|
79
|
+
'defines': [ 'HTTP_PARSER_STRICT=1' ],
|
80
|
+
'include_dirs': [ '.' ],
|
81
|
+
},
|
82
|
+
'defines': [ 'HTTP_PARSER_STRICT=1' ],
|
83
|
+
'sources': [ './http_parser.c', ],
|
84
|
+
'conditions': [
|
85
|
+
['OS=="win"', {
|
86
|
+
'msvs_settings': {
|
87
|
+
'VCCLCompilerTool': {
|
88
|
+
# Compile as C++. http_parser.c is actually C99, but C++ is
|
89
|
+
# close enough in this case.
|
90
|
+
'CompileAs': 2,
|
91
|
+
},
|
92
|
+
},
|
93
|
+
}]
|
94
|
+
],
|
95
|
+
},
|
96
|
+
|
97
|
+
{
|
98
|
+
'target_name': 'test-nonstrict',
|
99
|
+
'type': 'executable',
|
100
|
+
'dependencies': [ 'http_parser' ],
|
101
|
+
'sources': [ 'test.c' ]
|
102
|
+
},
|
103
|
+
|
104
|
+
{
|
105
|
+
'target_name': 'test-strict',
|
106
|
+
'type': 'executable',
|
107
|
+
'dependencies': [ 'http_parser_strict' ],
|
108
|
+
'sources': [ 'test.c' ]
|
109
|
+
}
|
110
|
+
]
|
111
|
+
}
|
@@ -0,0 +1,431 @@
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
2
|
+
*
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
* furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
11
|
+
* all copies or substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19
|
+
* IN THE SOFTWARE.
|
20
|
+
*/
|
21
|
+
#ifndef http_parser_h
|
22
|
+
#define http_parser_h
|
23
|
+
#ifdef __cplusplus
|
24
|
+
extern "C" {
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/* Also update SONAME in the Makefile whenever you change these. */
|
28
|
+
#define HTTP_PARSER_VERSION_MAJOR 2
|
29
|
+
#define HTTP_PARSER_VERSION_MINOR 7
|
30
|
+
#define HTTP_PARSER_VERSION_PATCH 1
|
31
|
+
|
32
|
+
#include <stddef.h>
|
33
|
+
#if defined(_WIN32) && !defined(__MINGW32__) && \
|
34
|
+
(!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
|
35
|
+
#include <BaseTsd.h>
|
36
|
+
typedef __int8 int8_t;
|
37
|
+
typedef unsigned __int8 uint8_t;
|
38
|
+
typedef __int16 int16_t;
|
39
|
+
typedef unsigned __int16 uint16_t;
|
40
|
+
typedef __int32 int32_t;
|
41
|
+
typedef unsigned __int32 uint32_t;
|
42
|
+
typedef __int64 int64_t;
|
43
|
+
typedef unsigned __int64 uint64_t;
|
44
|
+
#else
|
45
|
+
#include <stdint.h>
|
46
|
+
#endif
|
47
|
+
|
48
|
+
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
|
49
|
+
* faster
|
50
|
+
*/
|
51
|
+
#ifndef HTTP_PARSER_STRICT
|
52
|
+
# define HTTP_PARSER_STRICT 1
|
53
|
+
#endif
|
54
|
+
|
55
|
+
/* Maximium header size allowed. If the macro is not defined
|
56
|
+
* before including this header then the default is used. To
|
57
|
+
* change the maximum header size, define the macro in the build
|
58
|
+
* environment (e.g. -DHTTP_MAX_HEADER_SIZE=<value>). To remove
|
59
|
+
* the effective limit on the size of the header, define the macro
|
60
|
+
* to a very large number (e.g. -DHTTP_MAX_HEADER_SIZE=0x7fffffff)
|
61
|
+
*/
|
62
|
+
#ifndef HTTP_MAX_HEADER_SIZE
|
63
|
+
# define HTTP_MAX_HEADER_SIZE (80*1024)
|
64
|
+
#endif
|
65
|
+
|
66
|
+
typedef struct http_parser http_parser;
|
67
|
+
typedef struct http_parser_settings http_parser_settings;
|
68
|
+
|
69
|
+
|
70
|
+
/* Callbacks should return non-zero to indicate an error. The parser will
|
71
|
+
* then halt execution.
|
72
|
+
*
|
73
|
+
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
|
74
|
+
* returning '1' from on_headers_complete will tell the parser that it
|
75
|
+
* should not expect a body. This is used when receiving a response to a
|
76
|
+
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
|
77
|
+
* chunked' headers that indicate the presence of a body.
|
78
|
+
*
|
79
|
+
* Returning `2` from on_headers_complete will tell parser that it should not
|
80
|
+
* expect neither a body nor any futher responses on this connection. This is
|
81
|
+
* useful for handling responses to a CONNECT request which may not contain
|
82
|
+
* `Upgrade` or `Connection: upgrade` headers.
|
83
|
+
*
|
84
|
+
* http_data_cb does not return data chunks. It will be called arbitrarily
|
85
|
+
* many times for each string. E.G. you might get 10 callbacks for "on_url"
|
86
|
+
* each providing just a few characters more data.
|
87
|
+
*/
|
88
|
+
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
|
89
|
+
typedef int (*http_cb) (http_parser*);
|
90
|
+
|
91
|
+
|
92
|
+
/* Status Codes */
|
93
|
+
#define HTTP_STATUS_MAP(XX) \
|
94
|
+
XX(100, CONTINUE, Continue) \
|
95
|
+
XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \
|
96
|
+
XX(102, PROCESSING, Processing) \
|
97
|
+
XX(200, OK, OK) \
|
98
|
+
XX(201, CREATED, Created) \
|
99
|
+
XX(202, ACCEPTED, Accepted) \
|
100
|
+
XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \
|
101
|
+
XX(204, NO_CONTENT, No Content) \
|
102
|
+
XX(205, RESET_CONTENT, Reset Content) \
|
103
|
+
XX(206, PARTIAL_CONTENT, Partial Content) \
|
104
|
+
XX(207, MULTI_STATUS, Multi-Status) \
|
105
|
+
XX(208, ALREADY_REPORTED, Already Reported) \
|
106
|
+
XX(226, IM_USED, IM Used) \
|
107
|
+
XX(300, MULTIPLE_CHOICES, Multiple Choices) \
|
108
|
+
XX(301, MOVED_PERMANENTLY, Moved Permanently) \
|
109
|
+
XX(302, FOUND, Found) \
|
110
|
+
XX(303, SEE_OTHER, See Other) \
|
111
|
+
XX(304, NOT_MODIFIED, Not Modified) \
|
112
|
+
XX(305, USE_PROXY, Use Proxy) \
|
113
|
+
XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \
|
114
|
+
XX(308, PERMANENT_REDIRECT, Permanent Redirect) \
|
115
|
+
XX(400, BAD_REQUEST, Bad Request) \
|
116
|
+
XX(401, UNAUTHORIZED, Unauthorized) \
|
117
|
+
XX(402, PAYMENT_REQUIRED, Payment Required) \
|
118
|
+
XX(403, FORBIDDEN, Forbidden) \
|
119
|
+
XX(404, NOT_FOUND, Not Found) \
|
120
|
+
XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \
|
121
|
+
XX(406, NOT_ACCEPTABLE, Not Acceptable) \
|
122
|
+
XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \
|
123
|
+
XX(408, REQUEST_TIMEOUT, Request Timeout) \
|
124
|
+
XX(409, CONFLICT, Conflict) \
|
125
|
+
XX(410, GONE, Gone) \
|
126
|
+
XX(411, LENGTH_REQUIRED, Length Required) \
|
127
|
+
XX(412, PRECONDITION_FAILED, Precondition Failed) \
|
128
|
+
XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \
|
129
|
+
XX(414, URI_TOO_LONG, URI Too Long) \
|
130
|
+
XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \
|
131
|
+
XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \
|
132
|
+
XX(417, EXPECTATION_FAILED, Expectation Failed) \
|
133
|
+
XX(421, MISDIRECTED_REQUEST, Misdirected Request) \
|
134
|
+
XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \
|
135
|
+
XX(423, LOCKED, Locked) \
|
136
|
+
XX(424, FAILED_DEPENDENCY, Failed Dependency) \
|
137
|
+
XX(426, UPGRADE_REQUIRED, Upgrade Required) \
|
138
|
+
XX(428, PRECONDITION_REQUIRED, Precondition Required) \
|
139
|
+
XX(429, TOO_MANY_REQUESTS, Too Many Requests) \
|
140
|
+
XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \
|
141
|
+
XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \
|
142
|
+
XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \
|
143
|
+
XX(501, NOT_IMPLEMENTED, Not Implemented) \
|
144
|
+
XX(502, BAD_GATEWAY, Bad Gateway) \
|
145
|
+
XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \
|
146
|
+
XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \
|
147
|
+
XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \
|
148
|
+
XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \
|
149
|
+
XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \
|
150
|
+
XX(508, LOOP_DETECTED, Loop Detected) \
|
151
|
+
XX(510, NOT_EXTENDED, Not Extended) \
|
152
|
+
XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \
|
153
|
+
|
154
|
+
enum http_status
|
155
|
+
{
|
156
|
+
#define XX(num, name, string) HTTP_STATUS_##name = num,
|
157
|
+
HTTP_STATUS_MAP(XX)
|
158
|
+
#undef XX
|
159
|
+
};
|
160
|
+
|
161
|
+
|
162
|
+
/* Request Methods */
|
163
|
+
#define HTTP_METHOD_MAP(XX) \
|
164
|
+
XX(0, DELETE, DELETE) \
|
165
|
+
XX(1, GET, GET) \
|
166
|
+
XX(2, HEAD, HEAD) \
|
167
|
+
XX(3, POST, POST) \
|
168
|
+
XX(4, PUT, PUT) \
|
169
|
+
/* pathological */ \
|
170
|
+
XX(5, CONNECT, CONNECT) \
|
171
|
+
XX(6, OPTIONS, OPTIONS) \
|
172
|
+
XX(7, TRACE, TRACE) \
|
173
|
+
/* WebDAV */ \
|
174
|
+
XX(8, COPY, COPY) \
|
175
|
+
XX(9, LOCK, LOCK) \
|
176
|
+
XX(10, MKCOL, MKCOL) \
|
177
|
+
XX(11, MOVE, MOVE) \
|
178
|
+
XX(12, PROPFIND, PROPFIND) \
|
179
|
+
XX(13, PROPPATCH, PROPPATCH) \
|
180
|
+
XX(14, SEARCH, SEARCH) \
|
181
|
+
XX(15, UNLOCK, UNLOCK) \
|
182
|
+
XX(16, BIND, BIND) \
|
183
|
+
XX(17, REBIND, REBIND) \
|
184
|
+
XX(18, UNBIND, UNBIND) \
|
185
|
+
XX(19, ACL, ACL) \
|
186
|
+
/* subversion */ \
|
187
|
+
XX(20, REPORT, REPORT) \
|
188
|
+
XX(21, MKACTIVITY, MKACTIVITY) \
|
189
|
+
XX(22, CHECKOUT, CHECKOUT) \
|
190
|
+
XX(23, MERGE, MERGE) \
|
191
|
+
/* upnp */ \
|
192
|
+
XX(24, MSEARCH, M-SEARCH) \
|
193
|
+
XX(25, NOTIFY, NOTIFY) \
|
194
|
+
XX(26, SUBSCRIBE, SUBSCRIBE) \
|
195
|
+
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
|
196
|
+
/* RFC-5789 */ \
|
197
|
+
XX(28, PATCH, PATCH) \
|
198
|
+
XX(29, PURGE, PURGE) \
|
199
|
+
/* CalDAV */ \
|
200
|
+
XX(30, MKCALENDAR, MKCALENDAR) \
|
201
|
+
/* RFC-2068, section 19.6.1.2 */ \
|
202
|
+
XX(31, LINK, LINK) \
|
203
|
+
XX(32, UNLINK, UNLINK) \
|
204
|
+
|
205
|
+
enum http_method
|
206
|
+
{
|
207
|
+
#define XX(num, name, string) HTTP_##name = num,
|
208
|
+
HTTP_METHOD_MAP(XX)
|
209
|
+
#undef XX
|
210
|
+
};
|
211
|
+
|
212
|
+
|
213
|
+
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
214
|
+
|
215
|
+
|
216
|
+
/* Flag values for http_parser.flags field */
|
217
|
+
enum flags
|
218
|
+
{ F_CHUNKED = 1 << 0
|
219
|
+
, F_CONNECTION_KEEP_ALIVE = 1 << 1
|
220
|
+
, F_CONNECTION_CLOSE = 1 << 2
|
221
|
+
, F_CONNECTION_UPGRADE = 1 << 3
|
222
|
+
, F_TRAILING = 1 << 4
|
223
|
+
, F_UPGRADE = 1 << 5
|
224
|
+
, F_SKIPBODY = 1 << 6
|
225
|
+
, F_CONTENTLENGTH = 1 << 7
|
226
|
+
};
|
227
|
+
|
228
|
+
|
229
|
+
/* Map for errno-related constants
|
230
|
+
*
|
231
|
+
* The provided argument should be a macro that takes 2 arguments.
|
232
|
+
*/
|
233
|
+
#define HTTP_ERRNO_MAP(XX) \
|
234
|
+
/* No error */ \
|
235
|
+
XX(OK, "success") \
|
236
|
+
\
|
237
|
+
/* Callback-related errors */ \
|
238
|
+
XX(CB_message_begin, "the on_message_begin callback failed") \
|
239
|
+
XX(CB_url, "the on_url callback failed") \
|
240
|
+
XX(CB_header_field, "the on_header_field callback failed") \
|
241
|
+
XX(CB_header_value, "the on_header_value callback failed") \
|
242
|
+
XX(CB_headers_complete, "the on_headers_complete callback failed") \
|
243
|
+
XX(CB_body, "the on_body callback failed") \
|
244
|
+
XX(CB_message_complete, "the on_message_complete callback failed") \
|
245
|
+
XX(CB_status, "the on_status callback failed") \
|
246
|
+
XX(CB_chunk_header, "the on_chunk_header callback failed") \
|
247
|
+
XX(CB_chunk_complete, "the on_chunk_complete callback failed") \
|
248
|
+
\
|
249
|
+
/* Parsing-related errors */ \
|
250
|
+
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
|
251
|
+
XX(HEADER_OVERFLOW, \
|
252
|
+
"too many header bytes seen; overflow detected") \
|
253
|
+
XX(CLOSED_CONNECTION, \
|
254
|
+
"data received after completed connection: close message") \
|
255
|
+
XX(INVALID_VERSION, "invalid HTTP version") \
|
256
|
+
XX(INVALID_STATUS, "invalid HTTP status code") \
|
257
|
+
XX(INVALID_METHOD, "invalid HTTP method") \
|
258
|
+
XX(INVALID_URL, "invalid URL") \
|
259
|
+
XX(INVALID_HOST, "invalid host") \
|
260
|
+
XX(INVALID_PORT, "invalid port") \
|
261
|
+
XX(INVALID_PATH, "invalid path") \
|
262
|
+
XX(INVALID_QUERY_STRING, "invalid query string") \
|
263
|
+
XX(INVALID_FRAGMENT, "invalid fragment") \
|
264
|
+
XX(LF_EXPECTED, "LF character expected") \
|
265
|
+
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
|
266
|
+
XX(INVALID_CONTENT_LENGTH, \
|
267
|
+
"invalid character in content-length header") \
|
268
|
+
XX(UNEXPECTED_CONTENT_LENGTH, \
|
269
|
+
"unexpected content-length header") \
|
270
|
+
XX(INVALID_CHUNK_SIZE, \
|
271
|
+
"invalid character in chunk size header") \
|
272
|
+
XX(INVALID_CONSTANT, "invalid constant string") \
|
273
|
+
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
|
274
|
+
XX(STRICT, "strict mode assertion failed") \
|
275
|
+
XX(PAUSED, "parser is paused") \
|
276
|
+
XX(UNKNOWN, "an unknown error occurred")
|
277
|
+
|
278
|
+
|
279
|
+
/* Define HPE_* values for each errno value above */
|
280
|
+
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
|
281
|
+
enum http_errno {
|
282
|
+
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
|
283
|
+
};
|
284
|
+
#undef HTTP_ERRNO_GEN
|
285
|
+
|
286
|
+
|
287
|
+
/* Get an http_errno value from an http_parser */
|
288
|
+
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
|
289
|
+
|
290
|
+
|
291
|
+
struct http_parser {
|
292
|
+
/** PRIVATE **/
|
293
|
+
unsigned int type : 2; /* enum http_parser_type */
|
294
|
+
unsigned int flags : 8; /* F_* values from 'flags' enum; semi-public */
|
295
|
+
unsigned int state : 7; /* enum state from http_parser.c */
|
296
|
+
unsigned int header_state : 7; /* enum header_state from http_parser.c */
|
297
|
+
unsigned int index : 7; /* index into current matcher */
|
298
|
+
unsigned int lenient_http_headers : 1;
|
299
|
+
|
300
|
+
uint32_t nread; /* # bytes read in various scenarios */
|
301
|
+
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
|
302
|
+
|
303
|
+
/** READ-ONLY **/
|
304
|
+
unsigned short http_major;
|
305
|
+
unsigned short http_minor;
|
306
|
+
unsigned int status_code : 16; /* responses only */
|
307
|
+
unsigned int method : 8; /* requests only */
|
308
|
+
unsigned int http_errno : 7;
|
309
|
+
|
310
|
+
/* 1 = Upgrade header was present and the parser has exited because of that.
|
311
|
+
* 0 = No upgrade header present.
|
312
|
+
* Should be checked when http_parser_execute() returns in addition to
|
313
|
+
* error checking.
|
314
|
+
*/
|
315
|
+
unsigned int upgrade : 1;
|
316
|
+
|
317
|
+
/** PUBLIC **/
|
318
|
+
void *data; /* A pointer to get hook to the "connection" or "socket" object */
|
319
|
+
};
|
320
|
+
|
321
|
+
|
322
|
+
struct http_parser_settings {
|
323
|
+
http_cb on_message_begin;
|
324
|
+
http_data_cb on_url;
|
325
|
+
http_data_cb on_status;
|
326
|
+
http_data_cb on_header_field;
|
327
|
+
http_data_cb on_header_value;
|
328
|
+
http_cb on_headers_complete;
|
329
|
+
http_data_cb on_body;
|
330
|
+
http_cb on_message_complete;
|
331
|
+
/* When on_chunk_header is called, the current chunk length is stored
|
332
|
+
* in parser->content_length.
|
333
|
+
*/
|
334
|
+
http_cb on_chunk_header;
|
335
|
+
http_cb on_chunk_complete;
|
336
|
+
};
|
337
|
+
|
338
|
+
|
339
|
+
enum http_parser_url_fields
|
340
|
+
{ UF_SCHEMA = 0
|
341
|
+
, UF_HOST = 1
|
342
|
+
, UF_PORT = 2
|
343
|
+
, UF_PATH = 3
|
344
|
+
, UF_QUERY = 4
|
345
|
+
, UF_FRAGMENT = 5
|
346
|
+
, UF_USERINFO = 6
|
347
|
+
, UF_MAX = 7
|
348
|
+
};
|
349
|
+
|
350
|
+
|
351
|
+
/* Result structure for http_parser_parse_url().
|
352
|
+
*
|
353
|
+
* Callers should index into field_data[] with UF_* values iff field_set
|
354
|
+
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
|
355
|
+
* because we probably have padding left over), we convert any port to
|
356
|
+
* a uint16_t.
|
357
|
+
*/
|
358
|
+
struct http_parser_url {
|
359
|
+
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
|
360
|
+
uint16_t port; /* Converted UF_PORT string */
|
361
|
+
|
362
|
+
struct {
|
363
|
+
uint16_t off; /* Offset into buffer in which field starts */
|
364
|
+
uint16_t len; /* Length of run in buffer */
|
365
|
+
} field_data[UF_MAX];
|
366
|
+
};
|
367
|
+
|
368
|
+
|
369
|
+
/* Returns the library version. Bits 16-23 contain the major version number,
|
370
|
+
* bits 8-15 the minor version number and bits 0-7 the patch level.
|
371
|
+
* Usage example:
|
372
|
+
*
|
373
|
+
* unsigned long version = http_parser_version();
|
374
|
+
* unsigned major = (version >> 16) & 255;
|
375
|
+
* unsigned minor = (version >> 8) & 255;
|
376
|
+
* unsigned patch = version & 255;
|
377
|
+
* printf("http_parser v%u.%u.%u\n", major, minor, patch);
|
378
|
+
*/
|
379
|
+
unsigned long http_parser_version(void);
|
380
|
+
|
381
|
+
void http_parser_init(http_parser *parser, enum http_parser_type type);
|
382
|
+
|
383
|
+
|
384
|
+
/* Initialize http_parser_settings members to 0
|
385
|
+
*/
|
386
|
+
void http_parser_settings_init(http_parser_settings *settings);
|
387
|
+
|
388
|
+
|
389
|
+
/* Executes the parser. Returns number of parsed bytes. Sets
|
390
|
+
* `parser->http_errno` on error. */
|
391
|
+
size_t http_parser_execute(http_parser *parser,
|
392
|
+
const http_parser_settings *settings,
|
393
|
+
const char *data,
|
394
|
+
size_t len);
|
395
|
+
|
396
|
+
|
397
|
+
/* If http_should_keep_alive() in the on_headers_complete or
|
398
|
+
* on_message_complete callback returns 0, then this should be
|
399
|
+
* the last message on the connection.
|
400
|
+
* If you are the server, respond with the "Connection: close" header.
|
401
|
+
* If you are the client, close the connection.
|
402
|
+
*/
|
403
|
+
int http_should_keep_alive(const http_parser *parser);
|
404
|
+
|
405
|
+
/* Returns a string version of the HTTP method. */
|
406
|
+
const char *http_method_str(enum http_method m);
|
407
|
+
|
408
|
+
/* Return a string name of the given error */
|
409
|
+
const char *http_errno_name(enum http_errno err);
|
410
|
+
|
411
|
+
/* Return a string description of the given error */
|
412
|
+
const char *http_errno_description(enum http_errno err);
|
413
|
+
|
414
|
+
/* Initialize all http_parser_url members to 0 */
|
415
|
+
void http_parser_url_init(struct http_parser_url *u);
|
416
|
+
|
417
|
+
/* Parse a URL; return nonzero on failure */
|
418
|
+
int http_parser_parse_url(const char *buf, size_t buflen,
|
419
|
+
int is_connect,
|
420
|
+
struct http_parser_url *u);
|
421
|
+
|
422
|
+
/* Pause or un-pause the parser; a nonzero value pauses */
|
423
|
+
void http_parser_pause(http_parser *parser, int paused);
|
424
|
+
|
425
|
+
/* Checks if this is the final chunk of the body. */
|
426
|
+
int http_body_is_final(const http_parser *parser);
|
427
|
+
|
428
|
+
#ifdef __cplusplus
|
429
|
+
}
|
430
|
+
#endif
|
431
|
+
#endif
|