@encharm/cws 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings/cws_linux_108.node +0 -0
- package/dist/bindings/cws_linux_64.node +0 -0
- package/dist/bindings/cws_linux_72.node +0 -0
- package/dist/bindings/cws_linux_79.node +0 -0
- package/dist/bindings/cws_linux_83.node +0 -0
- package/dist/bindings/cws_linux_93.node +0 -0
- package/dist/bindings/cws_win32_64.node +0 -0
- package/dist/bindings/cws_win32_72.node +0 -0
- package/dist/bindings/cws_win32_79.node +0 -0
- package/dist/bindings/cws_win32_83.node +0 -0
- package/dist/bindings/cws_win32_93.node +0 -0
- package/package.json +1 -1
- package/src/Addon.h +24 -2
- package/src/HTTPSocket.cpp +1 -1
- package/src/headers/{13 → 18}/aliased_buffer.h +61 -9
- package/src/headers/18/aliased_struct-inl.h +54 -0
- package/src/headers/18/aliased_struct.h +63 -0
- package/src/headers/{12 → 18}/async_wrap-inl.h +0 -0
- package/src/headers/{12 → 18}/async_wrap.h +26 -2
- package/src/headers/{12/base64.h → 18/base64-inl.h} +78 -86
- package/src/headers/18/base64.h +69 -0
- package/src/headers/{12 → 18}/base_object-inl.h +46 -25
- package/src/headers/{12 → 18}/base_object.h +82 -17
- package/src/headers/{12 → 18}/callback_queue-inl.h +9 -9
- package/src/headers/{12 → 18}/callback_queue.h +13 -5
- package/src/headers/18/cares_wrap.h +523 -0
- package/src/headers/{12 → 18}/connect_wrap.h +0 -0
- package/src/headers/{12 → 18}/connection_wrap.h +0 -0
- package/src/headers/18/crypto/crypto_aes.h +89 -0
- package/src/headers/{13/node_crypto_bio.h → 18/crypto/crypto_bio.h} +3 -4
- package/src/headers/18/crypto/crypto_cipher.h +291 -0
- package/src/headers/{13/node_crypto_clienthello-inl.h → 18/crypto/crypto_clienthello-inl.h} +4 -5
- package/src/headers/{13/node_crypto_clienthello.h → 18/crypto/crypto_clienthello.h} +3 -4
- package/src/headers/{12/node_crypto_common.h → 18/crypto/crypto_common.h} +49 -36
- package/src/headers/18/crypto/crypto_context.h +147 -0
- package/src/headers/18/crypto/crypto_dh.h +156 -0
- package/src/headers/18/crypto/crypto_dsa.h +77 -0
- package/src/headers/18/crypto/crypto_ec.h +170 -0
- package/src/headers/{12/node_crypto_groups.h → 18/crypto/crypto_groups.h} +3 -3
- package/src/headers/18/crypto/crypto_hash.h +89 -0
- package/src/headers/18/crypto/crypto_hkdf.h +65 -0
- package/src/headers/18/crypto/crypto_hmac.h +94 -0
- package/src/headers/18/crypto/crypto_keygen.h +305 -0
- package/src/headers/18/crypto/crypto_keys.h +420 -0
- package/src/headers/18/crypto/crypto_pbkdf2.h +76 -0
- package/src/headers/18/crypto/crypto_random.h +130 -0
- package/src/headers/18/crypto/crypto_rsa.h +141 -0
- package/src/headers/18/crypto/crypto_scrypt.h +87 -0
- package/src/headers/18/crypto/crypto_sig.h +168 -0
- package/src/headers/18/crypto/crypto_spkac.h +21 -0
- package/src/headers/18/crypto/crypto_timing.h +20 -0
- package/src/headers/{13/tls_wrap.h → 18/crypto/crypto_tls.h} +137 -66
- package/src/headers/18/crypto/crypto_util.h +791 -0
- package/src/headers/18/crypto/crypto_x509.h +143 -0
- package/src/headers/{12 → 18}/debug_utils-inl.h +0 -0
- package/src/headers/{13 → 18}/debug_utils.h +7 -4
- package/src/headers/{12 → 18}/diagnosticfilename-inl.h +0 -0
- package/src/headers/{12 → 18}/env-inl.h +397 -304
- package/src/headers/{12 → 18}/env.h +397 -172
- package/src/headers/{12 → 18}/handle_wrap.h +7 -3
- package/src/headers/18/histogram-inl.h +107 -0
- package/src/headers/18/histogram.h +239 -0
- package/src/headers/{13 → 18}/inspector_agent.h +4 -7
- package/src/headers/{12 → 18}/inspector_io.h +0 -0
- package/src/headers/{13 → 18}/inspector_profiler.h +17 -5
- package/src/headers/{12 → 18}/inspector_socket.h +0 -0
- package/src/headers/{12 → 18}/inspector_socket_server.h +0 -0
- package/src/headers/18/js_native_api.h +571 -0
- package/src/headers/{13 → 18}/js_native_api_types.h +30 -7
- package/src/headers/{12 → 18}/js_native_api_v8.h +220 -83
- package/src/headers/{12 → 18}/js_native_api_v8_internals.h +6 -5
- package/src/headers/{12 → 18}/js_stream.h +0 -0
- package/src/headers/{12 → 18}/json_utils.h +0 -0
- package/src/headers/{13 → 18}/memory_tracker-inl.h +6 -5
- package/src/headers/{13 → 18}/memory_tracker.h +0 -7
- package/src/headers/{13 → 18}/module_wrap.h +24 -7
- package/src/headers/{13 → 18}/node.h +329 -68
- package/src/headers/18/node_api.h +288 -0
- package/src/headers/18/node_api_internals.h +38 -0
- package/src/headers/{12 → 18}/node_api_types.h +12 -9
- package/src/headers/{12 → 18}/node_binding.h +0 -0
- package/src/headers/18/node_blob.h +191 -0
- package/src/headers/18/node_bob-inl.h +37 -0
- package/src/headers/18/node_bob.h +111 -0
- package/src/headers/{13 → 18}/node_buffer.h +0 -0
- package/src/headers/{13 → 18}/node_constants.h +5 -1
- package/src/headers/{12 → 18}/node_context_data.h +5 -0
- package/src/headers/{12 → 18}/node_contextify.h +37 -2
- package/src/headers/{10/node_win32_perfctr_provider.h → 18/node_crypto.h} +30 -31
- package/src/headers/{12 → 18}/node_dir.h +0 -0
- package/src/headers/{12 → 18}/node_dtrace.h +0 -0
- package/src/headers/{12 → 18}/node_errors.h +90 -24
- package/src/headers/18/node_external_reference.h +145 -0
- package/src/headers/{13 → 18}/node_file-inl.h +38 -21
- package/src/headers/{12 → 18}/node_file.h +74 -13
- package/src/headers/{13 → 18}/node_http2.h +365 -269
- package/src/headers/{12 → 18}/node_http2_state.h +40 -50
- package/src/headers/{13 → 18}/node_http_common-inl.h +25 -5
- package/src/headers/{13 → 18}/node_http_common.h +24 -20
- package/src/headers/{13 → 18}/node_i18n.h +2 -1
- package/src/headers/{12 → 18}/node_internals.h +39 -41
- package/src/headers/{13 → 18}/node_main_instance.h +15 -18
- package/src/headers/{12 → 18}/node_mem-inl.h +0 -0
- package/src/headers/{12 → 18}/node_mem.h +1 -1
- package/src/headers/{13 → 18}/node_messaging.h +170 -23
- package/src/headers/{12 → 18}/node_metadata.h +17 -4
- package/src/headers/{12 → 18}/node_mutex.h +77 -1
- package/src/headers/{12 → 18}/node_native_module.h +11 -1
- package/src/headers/{13 → 18}/node_native_module_env.h +14 -8
- package/src/headers/{12 → 18}/node_object_wrap.h +0 -0
- package/src/headers/{13 → 18}/node_options-inl.h +51 -21
- package/src/headers/{13 → 18}/node_options.h +46 -14
- package/src/headers/18/node_perf.h +168 -0
- package/src/headers/{12 → 18}/node_perf_common.h +16 -22
- package/src/headers/{12 → 18}/node_platform.h +21 -16
- package/src/headers/18/node_process-inl.h +26 -0
- package/src/headers/18/node_process.h +97 -0
- package/src/headers/{13 → 18}/node_report.h +2 -2
- package/src/headers/{13 → 18}/node_revert.h +10 -0
- package/src/headers/{12 → 18}/node_root_certs.h +439 -651
- package/src/headers/18/node_snapshot_builder.h +43 -0
- package/src/headers/18/node_snapshotable.h +130 -0
- package/src/headers/{12 → 18}/node_sockaddr-inl.h +100 -4
- package/src/headers/18/node_sockaddr.h +405 -0
- package/src/headers/{12 → 18}/node_stat_watcher.h +7 -1
- package/src/headers/{12 → 18}/node_union_bytes.h +0 -0
- package/src/headers/{13 → 18}/node_url.h +18 -1
- package/src/headers/18/node_v8.h +41 -0
- package/src/headers/{12 → 18}/node_v8_platform-inl.h +10 -0
- package/src/headers/{13 → 18}/node_version.h +7 -7
- package/src/headers/{12 → 18}/node_wasi.h +0 -0
- package/src/headers/18/node_wasm_web_api.h +55 -0
- package/src/headers/{13 → 18}/node_watchdog.h +0 -0
- package/src/headers/{10 → 18}/node_win32_etw_provider-inl.h +7 -6
- package/src/headers/{10 → 18}/node_win32_etw_provider.h +0 -0
- package/src/headers/{13 → 18}/node_worker.h +24 -17
- package/src/headers/{12 → 18}/pipe_wrap.h +2 -0
- package/src/headers/{12 → 18}/req_wrap-inl.h +0 -0
- package/src/headers/{12 → 18}/req_wrap.h +1 -1
- package/src/headers/{12 → 18}/spawn_sync.h +0 -0
- package/src/headers/{13 → 18}/stream_base-inl.h +58 -22
- package/src/headers/{13 → 18}/stream_base.h +29 -3
- package/src/headers/{13 → 18}/stream_pipe.h +8 -3
- package/src/headers/{12 → 18}/stream_wrap.h +4 -1
- package/src/headers/{13 → 18}/string_bytes.h +0 -7
- package/src/headers/{12 → 18}/string_decoder-inl.h +0 -0
- package/src/headers/{10 → 18}/string_decoder.h +0 -0
- package/src/headers/{13 → 18}/string_search.h +2 -2
- package/src/headers/{12 → 18}/tcp_wrap.h +4 -0
- package/src/headers/{12 → 18}/threadpoolwork-inl.h +0 -0
- package/src/headers/18/timer_wrap-inl.h +32 -0
- package/src/headers/18/timer_wrap.h +85 -0
- package/src/headers/{13 → 18}/tracing/agent.h +1 -1
- package/src/headers/{12 → 18}/tracing/node_trace_buffer.h +0 -0
- package/src/headers/{12 → 18}/tracing/node_trace_writer.h +0 -0
- package/src/headers/{13 → 18}/tracing/trace_event.h +23 -13
- package/src/headers/{12 → 18}/tracing/trace_event_common.h +0 -0
- package/src/headers/{12 → 18}/tracing/traced_value.h +0 -0
- package/src/headers/{13 → 18}/tty_wrap.h +2 -1
- package/src/headers/{13 → 18}/udp_wrap.h +5 -0
- package/src/headers/{13 → 18}/util-inl.h +69 -15
- package/src/headers/{13 → 18}/util.h +93 -31
- package/src/headers/18/v8-fast-api-calls.h +939 -0
- package/src/headers/{12 → 18}/v8abbr.h +2 -2
- package/src/headers/10/aliased_buffer.h +0 -241
- package/src/headers/10/async_wrap-inl.h +0 -106
- package/src/headers/10/async_wrap.h +0 -218
- package/src/headers/10/base64.h +0 -197
- package/src/headers/10/base_object-inl.h +0 -132
- package/src/headers/10/base_object.h +0 -115
- package/src/headers/10/connect_wrap.h +0 -28
- package/src/headers/10/connection_wrap.h +0 -30
- package/src/headers/10/debug_utils.h +0 -128
- package/src/headers/10/env-inl.h +0 -906
- package/src/headers/10/env.h +0 -1046
- package/src/headers/10/handle_wrap.h +0 -114
- package/src/headers/10/inspector_agent.h +0 -137
- package/src/headers/10/inspector_io.h +0 -97
- package/src/headers/10/inspector_socket.h +0 -59
- package/src/headers/10/inspector_socket_server.h +0 -104
- package/src/headers/10/js_stream.h +0 -57
- package/src/headers/10/memory_tracker-inl.h +0 -318
- package/src/headers/10/memory_tracker.h +0 -246
- package/src/headers/10/module_wrap.h +0 -100
- package/src/headers/10/node.h +0 -863
- package/src/headers/10/node_api.h +0 -752
- package/src/headers/10/node_api_types.h +0 -171
- package/src/headers/10/node_buffer.h +0 -90
- package/src/headers/10/node_code_cache.h +0 -17
- package/src/headers/10/node_constants.h +0 -74
- package/src/headers/10/node_context_data.h +0 -39
- package/src/headers/10/node_contextify.h +0 -141
- package/src/headers/10/node_counters.h +0 -59
- package/src/headers/10/node_crypto.h +0 -699
- package/src/headers/10/node_crypto_bio.h +0 -177
- package/src/headers/10/node_crypto_clienthello-inl.h +0 -92
- package/src/headers/10/node_crypto_clienthello.h +0 -131
- package/src/headers/10/node_crypto_groups.h +0 -416
- package/src/headers/10/node_dtrace.h +0 -84
- package/src/headers/10/node_errors.h +0 -118
- package/src/headers/10/node_file.h +0 -373
- package/src/headers/10/node_http2.h +0 -1304
- package/src/headers/10/node_http2_state.h +0 -158
- package/src/headers/10/node_i18n.h +0 -69
- package/src/headers/10/node_internals.h +0 -952
- package/src/headers/10/node_javascript.h +0 -41
- package/src/headers/10/node_messaging.h +0 -219
- package/src/headers/10/node_mutex.h +0 -191
- package/src/headers/10/node_object_wrap.h +0 -130
- package/src/headers/10/node_options-inl.h +0 -444
- package/src/headers/10/node_options.h +0 -397
- package/src/headers/10/node_perf.h +0 -134
- package/src/headers/10/node_perf_common.h +0 -96
- package/src/headers/10/node_persistent.h +0 -30
- package/src/headers/10/node_platform.h +0 -170
- package/src/headers/10/node_revert.h +0 -75
- package/src/headers/10/node_root_certs.h +0 -3393
- package/src/headers/10/node_stat_watcher.h +0 -65
- package/src/headers/10/node_url.h +0 -193
- package/src/headers/10/node_version.h +0 -120
- package/src/headers/10/node_watchdog.h +0 -114
- package/src/headers/10/node_worker.h +0 -94
- package/src/headers/10/pipe_wrap.h +0 -76
- package/src/headers/10/req_wrap-inl.h +0 -166
- package/src/headers/10/req_wrap.h +0 -61
- package/src/headers/10/sharedarraybuffer_metadata.h +0 -67
- package/src/headers/10/spawn_sync.h +0 -240
- package/src/headers/10/stream_base-inl.h +0 -458
- package/src/headers/10/stream_base.h +0 -378
- package/src/headers/10/stream_pipe.h +0 -72
- package/src/headers/10/stream_wrap.h +0 -130
- package/src/headers/10/string_bytes.h +0 -126
- package/src/headers/10/string_decoder-inl.h +0 -38
- package/src/headers/10/string_search.h +0 -620
- package/src/headers/10/tcp_wrap.h +0 -99
- package/src/headers/10/tls_wrap.h +0 -195
- package/src/headers/10/tracing/agent.h +0 -178
- package/src/headers/10/tracing/node_trace_buffer.h +0 -83
- package/src/headers/10/tracing/node_trace_writer.h +0 -75
- package/src/headers/10/tracing/trace_event.h +0 -706
- package/src/headers/10/tracing/trace_event_common.h +0 -1102
- package/src/headers/10/tracing/traced_value.h +0 -68
- package/src/headers/10/tty_wrap.h +0 -63
- package/src/headers/10/udp_wrap.h +0 -102
- package/src/headers/10/util-inl.h +0 -459
- package/src/headers/10/util.h +0 -508
- package/src/headers/10/v8abbr.h +0 -121
- package/src/headers/12/aliased_buffer.h +0 -263
- package/src/headers/12/debug_utils.h +0 -181
- package/src/headers/12/histogram-inl.h +0 -83
- package/src/headers/12/histogram.h +0 -98
- package/src/headers/12/http_parser_adaptor.h +0 -24
- package/src/headers/12/inspector_agent.h +0 -147
- package/src/headers/12/inspector_profiler.h +0 -137
- package/src/headers/12/js_native_api.h +0 -541
- package/src/headers/12/js_native_api_types.h +0 -139
- package/src/headers/12/memory_tracker-inl.h +0 -339
- package/src/headers/12/memory_tracker.h +0 -283
- package/src/headers/12/module_wrap.h +0 -99
- package/src/headers/12/node.h +0 -887
- package/src/headers/12/node_api.h +0 -239
- package/src/headers/12/node_buffer.h +0 -92
- package/src/headers/12/node_constants.h +0 -80
- package/src/headers/12/node_crypto.h +0 -800
- package/src/headers/12/node_crypto_bio.h +0 -195
- package/src/headers/12/node_crypto_clienthello-inl.h +0 -91
- package/src/headers/12/node_crypto_clienthello.h +0 -132
- package/src/headers/12/node_file-inl.h +0 -289
- package/src/headers/12/node_http2.h +0 -1311
- package/src/headers/12/node_http_parser_impl.h +0 -994
- package/src/headers/12/node_i18n.h +0 -144
- package/src/headers/12/node_main_instance.h +0 -97
- package/src/headers/12/node_messaging.h +0 -227
- package/src/headers/12/node_native_module_env.h +0 -65
- package/src/headers/12/node_options-inl.h +0 -447
- package/src/headers/12/node_options.h +0 -479
- package/src/headers/12/node_perf.h +0 -181
- package/src/headers/12/node_process.h +0 -41
- package/src/headers/12/node_report.h +0 -47
- package/src/headers/12/node_revert.h +0 -78
- package/src/headers/12/node_sockaddr.h +0 -123
- package/src/headers/12/node_url.h +0 -188
- package/src/headers/12/node_version.h +0 -98
- package/src/headers/12/node_watchdog.h +0 -152
- package/src/headers/12/node_win32_etw_provider-inl.h +0 -287
- package/src/headers/12/node_win32_etw_provider.h +0 -99
- package/src/headers/12/node_worker.h +0 -142
- package/src/headers/12/sharedarraybuffer_metadata.h +0 -72
- package/src/headers/12/stream_base-inl.h +0 -323
- package/src/headers/12/stream_base.h +0 -431
- package/src/headers/12/stream_pipe.h +0 -72
- package/src/headers/12/string_bytes.h +0 -142
- package/src/headers/12/string_decoder.h +0 -50
- package/src/headers/12/string_search.h +0 -638
- package/src/headers/12/tls_wrap.h +0 -221
- package/src/headers/12/tracing/agent.h +0 -195
- package/src/headers/12/tracing/trace_event.h +0 -710
- package/src/headers/12/tty_wrap.h +0 -64
- package/src/headers/12/udp_wrap.h +0 -222
- package/src/headers/12/util-inl.h +0 -529
- package/src/headers/12/util.h +0 -765
- package/src/headers/13/async_wrap-inl.h +0 -94
- package/src/headers/13/async_wrap.h +0 -224
- package/src/headers/13/base64.h +0 -197
- package/src/headers/13/base_object-inl.h +0 -353
- package/src/headers/13/base_object.h +0 -229
- package/src/headers/13/connect_wrap.h +0 -26
- package/src/headers/13/connection_wrap.h +0 -30
- package/src/headers/13/debug_utils-inl.h +0 -223
- package/src/headers/13/diagnosticfilename-inl.h +0 -33
- package/src/headers/13/env-inl.h +0 -1293
- package/src/headers/13/env.h +0 -1469
- package/src/headers/13/handle_wrap.h +0 -117
- package/src/headers/13/histogram-inl.h +0 -83
- package/src/headers/13/histogram.h +0 -98
- package/src/headers/13/inspector_io.h +0 -78
- package/src/headers/13/inspector_socket.h +0 -60
- package/src/headers/13/inspector_socket_server.h +0 -110
- package/src/headers/13/js_native_api.h +0 -541
- package/src/headers/13/js_native_api_v8.h +0 -303
- package/src/headers/13/js_native_api_v8_internals.h +0 -38
- package/src/headers/13/js_stream.h +0 -52
- package/src/headers/13/json_utils.h +0 -160
- package/src/headers/13/node_api.h +0 -239
- package/src/headers/13/node_api_types.h +0 -44
- package/src/headers/13/node_binding.h +0 -99
- package/src/headers/13/node_context_data.h +0 -39
- package/src/headers/13/node_contextify.h +0 -161
- package/src/headers/13/node_crypto.h +0 -800
- package/src/headers/13/node_crypto_common.h +0 -138
- package/src/headers/13/node_crypto_groups.h +0 -415
- package/src/headers/13/node_dir.h +0 -52
- package/src/headers/13/node_dtrace.h +0 -86
- package/src/headers/13/node_errors.h +0 -210
- package/src/headers/13/node_file.h +0 -364
- package/src/headers/13/node_http2_state.h +0 -144
- package/src/headers/13/node_internals.h +0 -405
- package/src/headers/13/node_mem-inl.h +0 -112
- package/src/headers/13/node_mem.h +0 -41
- package/src/headers/13/node_metadata.h +0 -109
- package/src/headers/13/node_mutex.h +0 -247
- package/src/headers/13/node_native_module.h +0 -99
- package/src/headers/13/node_object_wrap.h +0 -132
- package/src/headers/13/node_perf.h +0 -181
- package/src/headers/13/node_perf_common.h +0 -97
- package/src/headers/13/node_platform.h +0 -190
- package/src/headers/13/node_process.h +0 -41
- package/src/headers/13/node_root_certs.h +0 -3424
- package/src/headers/13/node_sockaddr-inl.h +0 -170
- package/src/headers/13/node_sockaddr.h +0 -123
- package/src/headers/13/node_stat_watcher.h +0 -66
- package/src/headers/13/node_union_bytes.h +0 -103
- package/src/headers/13/node_v8_platform-inl.h +0 -184
- package/src/headers/13/node_wasi.h +0 -108
- package/src/headers/13/node_win32_etw_provider-inl.h +0 -287
- package/src/headers/13/node_win32_etw_provider.h +0 -99
- package/src/headers/13/pipe_wrap.h +0 -78
- package/src/headers/13/req_wrap-inl.h +0 -170
- package/src/headers/13/req_wrap.h +0 -77
- package/src/headers/13/spawn_sync.h +0 -242
- package/src/headers/13/stream_wrap.h +0 -130
- package/src/headers/13/string_decoder-inl.h +0 -37
- package/src/headers/13/string_decoder.h +0 -50
- package/src/headers/13/tcp_wrap.h +0 -101
- package/src/headers/13/threadpoolwork-inl.h +0 -57
- package/src/headers/13/tracing/node_trace_buffer.h +0 -83
- package/src/headers/13/tracing/node_trace_writer.h +0 -75
- package/src/headers/13/tracing/trace_event_common.h +0 -1109
- package/src/headers/13/tracing/traced_value.h +0 -70
- package/src/headers/13/v8abbr.h +0 -124
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
#include <cstdint>
|
|
8
8
|
#include "nghttp2/nghttp2.h"
|
|
9
9
|
|
|
10
|
+
#include "env.h"
|
|
11
|
+
#include "aliased_struct.h"
|
|
10
12
|
#include "node_http2_state.h"
|
|
11
13
|
#include "node_http_common.h"
|
|
12
14
|
#include "node_mem.h"
|
|
@@ -20,6 +22,10 @@
|
|
|
20
22
|
namespace node {
|
|
21
23
|
namespace http2 {
|
|
22
24
|
|
|
25
|
+
// Constants in all caps are exported as user-facing constants
|
|
26
|
+
// in JavaScript. Constants using the kName pattern are internal
|
|
27
|
+
// only.
|
|
28
|
+
|
|
23
29
|
// We strictly limit the number of outstanding unacknowledged PINGS a user
|
|
24
30
|
// may send in order to prevent abuse. The current default cap is 10. The
|
|
25
31
|
// user may set a different limit using a per Http2Session configuration
|
|
@@ -33,16 +39,62 @@ constexpr size_t kDefaultMaxSettings = 10;
|
|
|
33
39
|
constexpr uint64_t kDefaultMaxSessionMemory = 10000000;
|
|
34
40
|
|
|
35
41
|
// These are the standard HTTP/2 defaults as specified by the RFC
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
constexpr uint32_t DEFAULT_SETTINGS_HEADER_TABLE_SIZE = 4096;
|
|
43
|
+
constexpr uint32_t DEFAULT_SETTINGS_ENABLE_PUSH = 1;
|
|
44
|
+
constexpr uint32_t DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS = 0xffffffffu;
|
|
45
|
+
constexpr uint32_t DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE = 65535;
|
|
46
|
+
constexpr uint32_t DEFAULT_SETTINGS_MAX_FRAME_SIZE = 16384;
|
|
47
|
+
constexpr uint32_t DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE = 65535;
|
|
48
|
+
constexpr uint32_t DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0;
|
|
49
|
+
constexpr uint32_t MAX_MAX_FRAME_SIZE = 16777215;
|
|
50
|
+
constexpr uint32_t MIN_MAX_FRAME_SIZE = DEFAULT_SETTINGS_MAX_FRAME_SIZE;
|
|
51
|
+
constexpr uint32_t MAX_INITIAL_WINDOW_SIZE = 2147483647;
|
|
52
|
+
|
|
53
|
+
// Stream is not going to have any DATA frames
|
|
54
|
+
constexpr int STREAM_OPTION_EMPTY_PAYLOAD = 0x1;
|
|
55
|
+
|
|
56
|
+
// Stream might have trailing headers
|
|
57
|
+
constexpr int STREAM_OPTION_GET_TRAILERS = 0x2;
|
|
58
|
+
|
|
59
|
+
// Http2Stream internal states
|
|
60
|
+
constexpr int kStreamStateNone = 0x0;
|
|
61
|
+
constexpr int kStreamStateShut = 0x1;
|
|
62
|
+
constexpr int kStreamStateReadStart = 0x2;
|
|
63
|
+
constexpr int kStreamStateReadPaused = 0x4;
|
|
64
|
+
constexpr int kStreamStateClosed = 0x8;
|
|
65
|
+
constexpr int kStreamStateDestroyed = 0x10;
|
|
66
|
+
constexpr int kStreamStateTrailers = 0x20;
|
|
67
|
+
|
|
68
|
+
// Http2Session internal states
|
|
69
|
+
constexpr int kSessionStateNone = 0x0;
|
|
70
|
+
constexpr int kSessionStateHasScope = 0x1;
|
|
71
|
+
constexpr int kSessionStateWriteScheduled = 0x2;
|
|
72
|
+
constexpr int kSessionStateClosed = 0x4;
|
|
73
|
+
constexpr int kSessionStateClosing = 0x8;
|
|
74
|
+
constexpr int kSessionStateSending = 0x10;
|
|
75
|
+
constexpr int kSessionStateWriteInProgress = 0x20;
|
|
76
|
+
constexpr int kSessionStateReadingStopped = 0x40;
|
|
77
|
+
constexpr int kSessionStateReceivePaused = 0x80;
|
|
78
|
+
|
|
79
|
+
// The Padding Strategy determines the method by which extra padding is
|
|
80
|
+
// selected for HEADERS and DATA frames. These are configurable via the
|
|
81
|
+
// options passed in to a Http2Session object.
|
|
82
|
+
enum PaddingStrategy {
|
|
83
|
+
// No padding strategy. This is the default.
|
|
84
|
+
PADDING_STRATEGY_NONE,
|
|
85
|
+
// Attempts to ensure that the frame is 8-byte aligned
|
|
86
|
+
PADDING_STRATEGY_ALIGNED,
|
|
87
|
+
// Padding will ensure all data frames are maxFrameSize
|
|
88
|
+
PADDING_STRATEGY_MAX,
|
|
89
|
+
// Removed and turned into an alias because it is unreasonably expensive for
|
|
90
|
+
// very little benefit.
|
|
91
|
+
PADDING_STRATEGY_CALLBACK = PADDING_STRATEGY_ALIGNED
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
enum SessionType {
|
|
95
|
+
NGHTTP2_SESSION_SERVER,
|
|
96
|
+
NGHTTP2_SESSION_CLIENT
|
|
97
|
+
};
|
|
46
98
|
|
|
47
99
|
template <typename T, void(*fn)(T*)>
|
|
48
100
|
struct Nghttp2Deleter {
|
|
@@ -64,7 +116,6 @@ using Nghttp2SessionCallbacksPointer =
|
|
|
64
116
|
|
|
65
117
|
struct Http2HeadersTraits {
|
|
66
118
|
typedef nghttp2_nv nv_t;
|
|
67
|
-
static const uint8_t kNoneFlag = NGHTTP2_NV_FLAG_NONE;
|
|
68
119
|
};
|
|
69
120
|
|
|
70
121
|
struct Http2RcBufferPointerTraits {
|
|
@@ -92,82 +143,27 @@ struct Http2RcBufferPointerTraits {
|
|
|
92
143
|
using Http2Headers = NgHeaders<Http2HeadersTraits>;
|
|
93
144
|
using Http2RcBufferPointer = NgRcBufPointer<Http2RcBufferPointerTraits>;
|
|
94
145
|
|
|
95
|
-
|
|
96
|
-
enum nghttp2_session_type {
|
|
97
|
-
NGHTTP2_SESSION_SERVER,
|
|
98
|
-
NGHTTP2_SESSION_CLIENT
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
enum nghttp2_stream_flags {
|
|
102
|
-
NGHTTP2_STREAM_FLAG_NONE = 0x0,
|
|
103
|
-
// Writable side has ended
|
|
104
|
-
NGHTTP2_STREAM_FLAG_SHUT = 0x1,
|
|
105
|
-
// Reading has started
|
|
106
|
-
NGHTTP2_STREAM_FLAG_READ_START = 0x2,
|
|
107
|
-
// Reading is paused
|
|
108
|
-
NGHTTP2_STREAM_FLAG_READ_PAUSED = 0x4,
|
|
109
|
-
// Stream is closed
|
|
110
|
-
NGHTTP2_STREAM_FLAG_CLOSED = 0x8,
|
|
111
|
-
// Stream is destroyed
|
|
112
|
-
NGHTTP2_STREAM_FLAG_DESTROYED = 0x10,
|
|
113
|
-
// Stream has trailers
|
|
114
|
-
NGHTTP2_STREAM_FLAG_TRAILERS = 0x20,
|
|
115
|
-
// Stream has received all the data it can
|
|
116
|
-
NGHTTP2_STREAM_FLAG_EOS = 0x40
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
enum nghttp2_stream_options {
|
|
120
|
-
// Stream is not going to have any DATA frames
|
|
121
|
-
STREAM_OPTION_EMPTY_PAYLOAD = 0x1,
|
|
122
|
-
// Stream might have trailing headers
|
|
123
|
-
STREAM_OPTION_GET_TRAILERS = 0x2,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
146
|
struct NgHttp2StreamWrite : public MemoryRetainer {
|
|
127
|
-
|
|
147
|
+
BaseObjectPtr<AsyncWrap> req_wrap;
|
|
128
148
|
uv_buf_t buf;
|
|
129
149
|
|
|
130
150
|
inline explicit NgHttp2StreamWrite(uv_buf_t buf_) : buf(buf_) {}
|
|
131
|
-
inline NgHttp2StreamWrite(
|
|
132
|
-
req_wrap(
|
|
151
|
+
inline NgHttp2StreamWrite(BaseObjectPtr<AsyncWrap> req_wrap, uv_buf_t buf_) :
|
|
152
|
+
req_wrap(std::move(req_wrap)), buf(buf_) {}
|
|
133
153
|
|
|
134
154
|
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
135
155
|
SET_MEMORY_INFO_NAME(NgHttp2StreamWrite)
|
|
136
156
|
SET_SELF_SIZE(NgHttp2StreamWrite)
|
|
137
157
|
};
|
|
138
158
|
|
|
139
|
-
// The Padding Strategy determines the method by which extra padding is
|
|
140
|
-
// selected for HEADERS and DATA frames. These are configurable via the
|
|
141
|
-
// options passed in to a Http2Session object.
|
|
142
|
-
enum padding_strategy_type {
|
|
143
|
-
// No padding strategy. This is the default.
|
|
144
|
-
PADDING_STRATEGY_NONE,
|
|
145
|
-
// Attempts to ensure that the frame is 8-byte aligned
|
|
146
|
-
PADDING_STRATEGY_ALIGNED,
|
|
147
|
-
// Padding will ensure all data frames are maxFrameSize
|
|
148
|
-
PADDING_STRATEGY_MAX,
|
|
149
|
-
// Removed and turned into an alias because it is unreasonably expensive for
|
|
150
|
-
// very little benefit.
|
|
151
|
-
PADDING_STRATEGY_CALLBACK = PADDING_STRATEGY_ALIGNED
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
enum session_state_flags {
|
|
155
|
-
SESSION_STATE_NONE = 0x0,
|
|
156
|
-
SESSION_STATE_HAS_SCOPE = 0x1,
|
|
157
|
-
SESSION_STATE_WRITE_SCHEDULED = 0x2,
|
|
158
|
-
SESSION_STATE_CLOSED = 0x4,
|
|
159
|
-
SESSION_STATE_CLOSING = 0x8,
|
|
160
|
-
SESSION_STATE_SENDING = 0x10,
|
|
161
|
-
SESSION_STATE_WRITE_IN_PROGRESS = 0x20,
|
|
162
|
-
SESSION_STATE_READING_STOPPED = 0x40,
|
|
163
|
-
SESSION_STATE_NGHTTP2_RECV_PAUSED = 0x80
|
|
164
|
-
};
|
|
165
|
-
|
|
166
159
|
typedef uint32_t(*get_setting)(nghttp2_session* session,
|
|
167
160
|
nghttp2_settings_id id);
|
|
168
161
|
|
|
162
|
+
class Http2Ping;
|
|
169
163
|
class Http2Session;
|
|
164
|
+
class Http2Settings;
|
|
170
165
|
class Http2Stream;
|
|
166
|
+
class Origins;
|
|
171
167
|
|
|
172
168
|
// This scope should be present when any call into nghttp2 that may schedule
|
|
173
169
|
// data to be written to the underlying transport is made, and schedules
|
|
@@ -179,8 +175,7 @@ class Http2Scope {
|
|
|
179
175
|
~Http2Scope();
|
|
180
176
|
|
|
181
177
|
private:
|
|
182
|
-
Http2Session
|
|
183
|
-
v8::Local<v8::Object> session_handle_;
|
|
178
|
+
BaseObjectPtr<Http2Session> session_;
|
|
184
179
|
};
|
|
185
180
|
|
|
186
181
|
// The Http2Options class is used to parse the options object passed in to
|
|
@@ -189,7 +184,8 @@ class Http2Scope {
|
|
|
189
184
|
// configured.
|
|
190
185
|
class Http2Options {
|
|
191
186
|
public:
|
|
192
|
-
Http2Options(
|
|
187
|
+
Http2Options(Http2State* http2_state,
|
|
188
|
+
SessionType type);
|
|
193
189
|
|
|
194
190
|
~Http2Options() = default;
|
|
195
191
|
|
|
@@ -197,43 +193,43 @@ class Http2Options {
|
|
|
197
193
|
return options_.get();
|
|
198
194
|
}
|
|
199
195
|
|
|
200
|
-
void
|
|
196
|
+
void set_max_header_pairs(uint32_t max) {
|
|
201
197
|
max_header_pairs_ = max;
|
|
202
198
|
}
|
|
203
199
|
|
|
204
|
-
uint32_t
|
|
200
|
+
uint32_t max_header_pairs() const {
|
|
205
201
|
return max_header_pairs_;
|
|
206
202
|
}
|
|
207
203
|
|
|
208
|
-
void
|
|
204
|
+
void set_padding_strategy(PaddingStrategy val) {
|
|
209
205
|
padding_strategy_ = val;
|
|
210
206
|
}
|
|
211
207
|
|
|
212
|
-
|
|
208
|
+
PaddingStrategy padding_strategy() const {
|
|
213
209
|
return padding_strategy_;
|
|
214
210
|
}
|
|
215
211
|
|
|
216
|
-
void
|
|
212
|
+
void set_max_outstanding_pings(size_t max) {
|
|
217
213
|
max_outstanding_pings_ = max;
|
|
218
214
|
}
|
|
219
215
|
|
|
220
|
-
size_t
|
|
216
|
+
size_t max_outstanding_pings() const {
|
|
221
217
|
return max_outstanding_pings_;
|
|
222
218
|
}
|
|
223
219
|
|
|
224
|
-
void
|
|
220
|
+
void set_max_outstanding_settings(size_t max) {
|
|
225
221
|
max_outstanding_settings_ = max;
|
|
226
222
|
}
|
|
227
223
|
|
|
228
|
-
size_t
|
|
224
|
+
size_t max_outstanding_settings() const {
|
|
229
225
|
return max_outstanding_settings_;
|
|
230
226
|
}
|
|
231
227
|
|
|
232
|
-
void
|
|
228
|
+
void set_max_session_memory(uint64_t max) {
|
|
233
229
|
max_session_memory_ = max;
|
|
234
230
|
}
|
|
235
231
|
|
|
236
|
-
uint64_t
|
|
232
|
+
uint64_t max_session_memory() const {
|
|
237
233
|
return max_session_memory_;
|
|
238
234
|
}
|
|
239
235
|
|
|
@@ -241,7 +237,7 @@ class Http2Options {
|
|
|
241
237
|
Nghttp2OptionPointer options_;
|
|
242
238
|
uint64_t max_session_memory_ = kDefaultMaxSessionMemory;
|
|
243
239
|
uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
|
|
244
|
-
|
|
240
|
+
PaddingStrategy padding_strategy_ = PADDING_STRATEGY_NONE;
|
|
245
241
|
size_t max_outstanding_pings_ = kDefaultMaxPings;
|
|
246
242
|
size_t max_outstanding_settings_ = kDefaultMaxSettings;
|
|
247
243
|
};
|
|
@@ -280,13 +276,13 @@ class Http2Stream : public AsyncWrap,
|
|
|
280
276
|
int options = 0);
|
|
281
277
|
~Http2Stream() override;
|
|
282
278
|
|
|
283
|
-
nghttp2_stream* operator*();
|
|
279
|
+
nghttp2_stream* operator*() const;
|
|
280
|
+
|
|
281
|
+
nghttp2_stream* stream() const;
|
|
284
282
|
|
|
285
283
|
Http2Session* session() { return session_.get(); }
|
|
286
284
|
const Http2Session* session() const { return session_.get(); }
|
|
287
285
|
|
|
288
|
-
void EmitStatistics();
|
|
289
|
-
|
|
290
286
|
// Required for StreamBase
|
|
291
287
|
int ReadStart() override;
|
|
292
288
|
|
|
@@ -310,7 +306,7 @@ class Http2Stream : public AsyncWrap,
|
|
|
310
306
|
void OnTrailers();
|
|
311
307
|
|
|
312
308
|
// Submit a PRIORITY frame for this stream
|
|
313
|
-
int SubmitPriority(
|
|
309
|
+
int SubmitPriority(const Http2Priority& priority, bool silent = false);
|
|
314
310
|
|
|
315
311
|
// Submits an RST_STREAM frame using the given code
|
|
316
312
|
void SubmitRstStream(const uint32_t code);
|
|
@@ -329,42 +325,74 @@ class Http2Stream : public AsyncWrap,
|
|
|
329
325
|
// Destroy this stream instance and free all held memory.
|
|
330
326
|
void Destroy();
|
|
331
327
|
|
|
332
|
-
|
|
333
|
-
return flags_ &
|
|
328
|
+
bool is_destroyed() const {
|
|
329
|
+
return flags_ & kStreamStateDestroyed;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
bool is_writable() const {
|
|
333
|
+
return !(flags_ & kStreamStateShut);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
bool is_paused() const {
|
|
337
|
+
return flags_ & kStreamStateReadPaused;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
bool is_closed() const {
|
|
341
|
+
return flags_ & kStreamStateClosed;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
bool has_trailers() const {
|
|
345
|
+
return flags_ & kStreamStateTrailers;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
void set_has_trailers(bool on = true) {
|
|
349
|
+
if (on)
|
|
350
|
+
flags_ |= kStreamStateTrailers;
|
|
351
|
+
else
|
|
352
|
+
flags_ &= ~kStreamStateTrailers;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
void set_closed() {
|
|
356
|
+
flags_ |= kStreamStateClosed;
|
|
334
357
|
}
|
|
335
358
|
|
|
336
|
-
|
|
337
|
-
|
|
359
|
+
void set_destroyed() {
|
|
360
|
+
flags_ |= kStreamStateDestroyed;
|
|
338
361
|
}
|
|
339
362
|
|
|
340
|
-
|
|
341
|
-
|
|
363
|
+
void set_not_writable() {
|
|
364
|
+
flags_ |= kStreamStateShut;
|
|
342
365
|
}
|
|
343
366
|
|
|
344
|
-
|
|
345
|
-
|
|
367
|
+
void set_reading(bool on = true) {
|
|
368
|
+
if (on) {
|
|
369
|
+
flags_ |= kStreamStateReadStart;
|
|
370
|
+
set_paused(false);
|
|
371
|
+
} else {}
|
|
346
372
|
}
|
|
347
373
|
|
|
348
|
-
|
|
349
|
-
|
|
374
|
+
void set_paused(bool on = true) {
|
|
375
|
+
if (on)
|
|
376
|
+
flags_ |= kStreamStateReadPaused;
|
|
377
|
+
else
|
|
378
|
+
flags_ &= ~kStreamStateReadPaused;
|
|
350
379
|
}
|
|
351
380
|
|
|
352
381
|
// Returns true if this stream is in the reading state, which occurs when
|
|
353
|
-
// the
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
return flags_ &
|
|
357
|
-
!(flags_ & NGHTTP2_STREAM_FLAG_READ_PAUSED);
|
|
382
|
+
// the kStreamStateReadStart flag has been set and the
|
|
383
|
+
// kStreamStateReadPaused flag is *not* set.
|
|
384
|
+
bool is_reading() const {
|
|
385
|
+
return flags_ & kStreamStateReadStart && !is_paused();
|
|
358
386
|
}
|
|
359
387
|
|
|
360
388
|
// Returns the RST_STREAM code used to close this stream
|
|
361
|
-
|
|
389
|
+
int32_t code() const { return code_; }
|
|
362
390
|
|
|
363
391
|
// Returns the stream identifier for this stream
|
|
364
|
-
|
|
392
|
+
int32_t id() const { return id_; }
|
|
365
393
|
|
|
366
|
-
|
|
367
|
-
|
|
394
|
+
void IncrementAvailableOutboundLength(size_t amount);
|
|
395
|
+
void DecrementAvailableOutboundLength(size_t amount);
|
|
368
396
|
|
|
369
397
|
bool AddHeader(nghttp2_rcbuf* name, nghttp2_rcbuf* value, uint8_t flags);
|
|
370
398
|
|
|
@@ -373,6 +401,10 @@ class Http2Stream : public AsyncWrap,
|
|
|
373
401
|
size_t i = 0;
|
|
374
402
|
for (const auto& header : current_headers_ )
|
|
375
403
|
fn(header, i++);
|
|
404
|
+
ClearHeaders();
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
void ClearHeaders() {
|
|
376
408
|
current_headers_.clear();
|
|
377
409
|
}
|
|
378
410
|
|
|
@@ -380,7 +412,7 @@ class Http2Stream : public AsyncWrap,
|
|
|
380
412
|
return current_headers_.size();
|
|
381
413
|
}
|
|
382
414
|
|
|
383
|
-
|
|
415
|
+
nghttp2_headers_category headers_category() const {
|
|
384
416
|
return current_headers_category_;
|
|
385
417
|
}
|
|
386
418
|
|
|
@@ -401,11 +433,7 @@ class Http2Stream : public AsyncWrap,
|
|
|
401
433
|
int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
|
|
402
434
|
uv_stream_t* send_handle) override;
|
|
403
435
|
|
|
404
|
-
void MemoryInfo(MemoryTracker* tracker) const override
|
|
405
|
-
tracker->TrackField("current_headers", current_headers_);
|
|
406
|
-
tracker->TrackField("queue", queue_);
|
|
407
|
-
}
|
|
408
|
-
|
|
436
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
409
437
|
SET_MEMORY_INFO_NAME(Http2Stream)
|
|
410
438
|
SET_SELF_SIZE(Http2Stream)
|
|
411
439
|
|
|
@@ -432,6 +460,7 @@ class Http2Stream : public AsyncWrap,
|
|
|
432
460
|
uint64_t first_byte_sent; // Time first DATA frame byte was sent
|
|
433
461
|
uint64_t sent_bytes;
|
|
434
462
|
uint64_t received_bytes;
|
|
463
|
+
uint64_t id;
|
|
435
464
|
};
|
|
436
465
|
|
|
437
466
|
Statistics statistics_ = {};
|
|
@@ -443,10 +472,12 @@ class Http2Stream : public AsyncWrap,
|
|
|
443
472
|
nghttp2_headers_category category,
|
|
444
473
|
int options);
|
|
445
474
|
|
|
475
|
+
void EmitStatistics();
|
|
476
|
+
|
|
446
477
|
BaseObjectWeakPtr<Http2Session> session_; // The Parent HTTP/2 Session
|
|
447
478
|
int32_t id_ = 0; // The Stream Identifier
|
|
448
479
|
int32_t code_ = NGHTTP2_NO_ERROR; // The RST_STREAM code (if any)
|
|
449
|
-
int flags_ =
|
|
480
|
+
int flags_ = kStreamStateNone; // Internal state flags
|
|
450
481
|
|
|
451
482
|
uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
|
|
452
483
|
uint32_t max_header_length_ = DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE;
|
|
@@ -541,31 +572,30 @@ class Http2Session : public AsyncWrap,
|
|
|
541
572
|
public StreamListener,
|
|
542
573
|
public mem::NgLibMemoryManager<Http2Session, nghttp2_mem> {
|
|
543
574
|
public:
|
|
544
|
-
Http2Session(
|
|
575
|
+
Http2Session(Http2State* http2_state,
|
|
545
576
|
v8::Local<v8::Object> wrap,
|
|
546
|
-
|
|
577
|
+
SessionType type = NGHTTP2_SESSION_SERVER);
|
|
547
578
|
~Http2Session() override;
|
|
548
579
|
|
|
549
|
-
|
|
550
|
-
class Http2Settings;
|
|
551
|
-
|
|
552
|
-
void EmitStatistics();
|
|
553
|
-
|
|
554
|
-
inline StreamBase* underlying_stream() {
|
|
580
|
+
StreamBase* underlying_stream() {
|
|
555
581
|
return static_cast<StreamBase*>(stream_);
|
|
556
582
|
}
|
|
557
583
|
|
|
558
584
|
void Close(uint32_t code = NGHTTP2_NO_ERROR,
|
|
559
585
|
bool socket_closed = false);
|
|
586
|
+
|
|
560
587
|
void Consume(v8::Local<v8::Object> stream);
|
|
588
|
+
|
|
561
589
|
void Goaway(uint32_t code, int32_t lastStreamID,
|
|
562
590
|
const uint8_t* data, size_t len);
|
|
591
|
+
|
|
563
592
|
void AltSvc(int32_t id,
|
|
564
593
|
uint8_t* origin,
|
|
565
594
|
size_t origin_len,
|
|
566
595
|
uint8_t* value,
|
|
567
596
|
size_t value_len);
|
|
568
|
-
|
|
597
|
+
|
|
598
|
+
void Origin(const Origins& origins);
|
|
569
599
|
|
|
570
600
|
uint8_t SendPendingData();
|
|
571
601
|
|
|
@@ -573,25 +603,48 @@ class Http2Session : public AsyncWrap,
|
|
|
573
603
|
// will be a pointer to the Http2Stream instance assigned.
|
|
574
604
|
// This only works if the session is a client session.
|
|
575
605
|
Http2Stream* SubmitRequest(
|
|
576
|
-
|
|
606
|
+
const Http2Priority& priority,
|
|
577
607
|
const Http2Headers& headers,
|
|
578
608
|
int32_t* ret,
|
|
579
609
|
int options = 0);
|
|
580
610
|
|
|
581
|
-
|
|
611
|
+
SessionType type() const { return session_type_; }
|
|
612
|
+
|
|
613
|
+
nghttp2_session* session() const { return session_.get(); }
|
|
582
614
|
|
|
583
|
-
|
|
615
|
+
nghttp2_session* operator*() { return session_.get(); }
|
|
584
616
|
|
|
585
|
-
|
|
617
|
+
uint32_t max_header_pairs() const { return max_header_pairs_; }
|
|
586
618
|
|
|
587
|
-
|
|
619
|
+
const char* TypeName() const;
|
|
588
620
|
|
|
589
|
-
|
|
621
|
+
bool is_destroyed() {
|
|
622
|
+
return (flags_ & kSessionStateClosed) || session_ == nullptr;
|
|
623
|
+
}
|
|
590
624
|
|
|
591
|
-
|
|
592
|
-
|
|
625
|
+
void set_destroyed() {
|
|
626
|
+
flags_ |= kSessionStateClosed;
|
|
593
627
|
}
|
|
594
628
|
|
|
629
|
+
#define IS_FLAG(name, flag) \
|
|
630
|
+
bool is_##name() const { return flags_ & flag; } \
|
|
631
|
+
void set_##name(bool on = true) { \
|
|
632
|
+
if (on) \
|
|
633
|
+
flags_ |= flag; \
|
|
634
|
+
else \
|
|
635
|
+
flags_ &= ~flag; \
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
IS_FLAG(in_scope, kSessionStateHasScope)
|
|
639
|
+
IS_FLAG(write_scheduled, kSessionStateWriteScheduled)
|
|
640
|
+
IS_FLAG(closing, kSessionStateClosing)
|
|
641
|
+
IS_FLAG(sending, kSessionStateSending)
|
|
642
|
+
IS_FLAG(write_in_progress, kSessionStateWriteInProgress)
|
|
643
|
+
IS_FLAG(reading_stopped, kSessionStateReadingStopped)
|
|
644
|
+
IS_FLAG(receive_paused, kSessionStateReceivePaused)
|
|
645
|
+
|
|
646
|
+
#undef IS_FLAG
|
|
647
|
+
|
|
595
648
|
// Schedule a write if nghttp2 indicates it wants to write to the socket.
|
|
596
649
|
void MaybeScheduleWrite();
|
|
597
650
|
|
|
@@ -599,48 +652,39 @@ class Http2Session : public AsyncWrap,
|
|
|
599
652
|
void MaybeStopReading();
|
|
600
653
|
|
|
601
654
|
// Returns pointer to the stream, or nullptr if stream does not exist
|
|
602
|
-
|
|
655
|
+
BaseObjectPtr<Http2Stream> FindStream(int32_t id);
|
|
603
656
|
|
|
604
|
-
|
|
657
|
+
bool CanAddStream();
|
|
605
658
|
|
|
606
659
|
// Adds a stream instance to this session
|
|
607
|
-
|
|
660
|
+
void AddStream(Http2Stream* stream);
|
|
608
661
|
|
|
609
662
|
// Removes a stream instance from this session
|
|
610
|
-
|
|
663
|
+
BaseObjectPtr<Http2Stream> RemoveStream(int32_t id);
|
|
611
664
|
|
|
612
665
|
// Indicates whether there currently exist outgoing buffers for this stream.
|
|
613
666
|
bool HasWritesOnSocketForStream(Http2Stream* stream);
|
|
614
667
|
|
|
615
|
-
// Write data from stream_buf_ to the session
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
void MemoryInfo(MemoryTracker* tracker) const override {
|
|
619
|
-
tracker->TrackField("streams", streams_);
|
|
620
|
-
tracker->TrackField("outstanding_pings", outstanding_pings_);
|
|
621
|
-
tracker->TrackField("outstanding_settings", outstanding_settings_);
|
|
622
|
-
tracker->TrackField("outgoing_buffers", outgoing_buffers_);
|
|
623
|
-
tracker->TrackFieldWithSize("stream_buf", stream_buf_.len);
|
|
624
|
-
tracker->TrackFieldWithSize("outgoing_storage", outgoing_storage_.size());
|
|
625
|
-
tracker->TrackFieldWithSize("pending_rst_streams",
|
|
626
|
-
pending_rst_streams_.size() * sizeof(int32_t));
|
|
627
|
-
tracker->TrackFieldWithSize("nghttp2_memory", current_nghttp2_memory_);
|
|
628
|
-
}
|
|
668
|
+
// Write data from stream_buf_ to the session.
|
|
669
|
+
// This will call the error callback if an error occurs.
|
|
670
|
+
void ConsumeHTTP2Data();
|
|
629
671
|
|
|
672
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
630
673
|
SET_MEMORY_INFO_NAME(Http2Session)
|
|
631
674
|
SET_SELF_SIZE(Http2Session)
|
|
632
675
|
|
|
633
676
|
std::string diagnostic_name() const override;
|
|
634
677
|
|
|
635
678
|
// Schedule an RstStream for after the current write finishes.
|
|
636
|
-
|
|
679
|
+
void AddPendingRstStream(int32_t stream_id) {
|
|
637
680
|
pending_rst_streams_.emplace_back(stream_id);
|
|
638
681
|
}
|
|
639
682
|
|
|
640
|
-
|
|
641
|
-
return pending_rst_streams_.end() !=
|
|
642
|
-
|
|
643
|
-
|
|
683
|
+
bool has_pending_rststream(int32_t stream_id) {
|
|
684
|
+
return pending_rst_streams_.end() !=
|
|
685
|
+
std::find(pending_rst_streams_.begin(),
|
|
686
|
+
pending_rst_streams_.end(),
|
|
687
|
+
stream_id);
|
|
644
688
|
}
|
|
645
689
|
|
|
646
690
|
// Handle reads/writes from the underlying network transport.
|
|
@@ -656,10 +700,13 @@ class Http2Session : public AsyncWrap,
|
|
|
656
700
|
// The JavaScript API
|
|
657
701
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
658
702
|
static void Consume(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
703
|
+
static void Receive(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
659
704
|
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
660
705
|
static void Settings(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
661
706
|
static void Request(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
662
707
|
static void SetNextStreamID(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
708
|
+
static void SetLocalWindowSize(
|
|
709
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
663
710
|
static void Goaway(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
664
711
|
static void UpdateChunksSent(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
665
712
|
static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
@@ -674,11 +721,13 @@ class Http2Session : public AsyncWrap,
|
|
|
674
721
|
return env()->event_loop();
|
|
675
722
|
}
|
|
676
723
|
|
|
724
|
+
Http2State* http2_state() const { return http2_state_.get(); }
|
|
725
|
+
|
|
677
726
|
BaseObjectPtr<Http2Ping> PopPing();
|
|
678
|
-
|
|
727
|
+
bool AddPing(const uint8_t* data, v8::Local<v8::Function> callback);
|
|
679
728
|
|
|
680
729
|
BaseObjectPtr<Http2Settings> PopSettings();
|
|
681
|
-
|
|
730
|
+
bool AddSettings(v8::Local<v8::Function> callback);
|
|
682
731
|
|
|
683
732
|
void IncrementCurrentSessionMemory(uint64_t amount) {
|
|
684
733
|
current_session_memory_ += amount;
|
|
@@ -695,7 +744,7 @@ class Http2Session : public AsyncWrap,
|
|
|
695
744
|
|
|
696
745
|
// Returns the current session memory including memory allocated by nghttp2,
|
|
697
746
|
// the current outbound storage queue, and pending writes.
|
|
698
|
-
uint64_t
|
|
747
|
+
uint64_t current_session_memory() const {
|
|
699
748
|
uint64_t total = current_session_memory_ + sizeof(Http2Session);
|
|
700
749
|
total += current_nghttp2_memory_;
|
|
701
750
|
total += outgoing_storage_.size();
|
|
@@ -703,8 +752,8 @@ class Http2Session : public AsyncWrap,
|
|
|
703
752
|
}
|
|
704
753
|
|
|
705
754
|
// Return true if current_session_memory + amount is less than the max
|
|
706
|
-
bool
|
|
707
|
-
return
|
|
755
|
+
bool has_available_session_memory(uint64_t amount) const {
|
|
756
|
+
return current_session_memory() + amount <= max_session_memory_;
|
|
708
757
|
}
|
|
709
758
|
|
|
710
759
|
struct Statistics {
|
|
@@ -718,11 +767,14 @@ class Http2Session : public AsyncWrap,
|
|
|
718
767
|
int32_t stream_count;
|
|
719
768
|
size_t max_concurrent_streams;
|
|
720
769
|
double stream_average_duration;
|
|
770
|
+
SessionType session_type;
|
|
721
771
|
};
|
|
722
772
|
|
|
723
773
|
Statistics statistics_ = {};
|
|
724
774
|
|
|
725
775
|
private:
|
|
776
|
+
void EmitStatistics();
|
|
777
|
+
|
|
726
778
|
// Frame Padding Strategies
|
|
727
779
|
ssize_t OnDWordAlignedPadding(size_t frameLength,
|
|
728
780
|
size_t maxPayloadLen);
|
|
@@ -739,6 +791,8 @@ class Http2Session : public AsyncWrap,
|
|
|
739
791
|
void HandleAltSvcFrame(const nghttp2_frame* frame);
|
|
740
792
|
void HandleOriginFrame(const nghttp2_frame* frame);
|
|
741
793
|
|
|
794
|
+
void DecrefHeaders(const nghttp2_frame* frame);
|
|
795
|
+
|
|
742
796
|
// nghttp2 callbacks
|
|
743
797
|
static int OnBeginHeadersCallback(
|
|
744
798
|
nghttp2_session* session,
|
|
@@ -807,7 +861,7 @@ class Http2Session : public AsyncWrap,
|
|
|
807
861
|
void* user_data);
|
|
808
862
|
|
|
809
863
|
struct Callbacks {
|
|
810
|
-
|
|
864
|
+
explicit Callbacks(bool kHasGetPaddingCallback);
|
|
811
865
|
|
|
812
866
|
Nghttp2SessionCallbacksPointer callbacks;
|
|
813
867
|
};
|
|
@@ -819,10 +873,10 @@ class Http2Session : public AsyncWrap,
|
|
|
819
873
|
Nghttp2SessionPointer session_;
|
|
820
874
|
|
|
821
875
|
// JS-accessible numeric fields, as indexed by SessionUint8Fields.
|
|
822
|
-
SessionJSFields js_fields_
|
|
876
|
+
AliasedStruct<SessionJSFields> js_fields_;
|
|
823
877
|
|
|
824
878
|
// The session type: client or server
|
|
825
|
-
|
|
879
|
+
SessionType session_type_;
|
|
826
880
|
|
|
827
881
|
// The maximum number of header pairs permitted for streams on this session
|
|
828
882
|
uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
|
|
@@ -834,12 +888,12 @@ class Http2Session : public AsyncWrap,
|
|
|
834
888
|
uint64_t current_nghttp2_memory_ = 0;
|
|
835
889
|
|
|
836
890
|
// The collection of active Http2Streams associated with this session
|
|
837
|
-
std::unordered_map<int32_t, Http2Stream
|
|
891
|
+
std::unordered_map<int32_t, BaseObjectPtr<Http2Stream>> streams_;
|
|
838
892
|
|
|
839
|
-
int flags_ =
|
|
893
|
+
int flags_ = kSessionStateNone;
|
|
840
894
|
|
|
841
895
|
// The StreamBase instance being used for i/o
|
|
842
|
-
|
|
896
|
+
PaddingStrategy padding_strategy_ = PADDING_STRATEGY_NONE;
|
|
843
897
|
|
|
844
898
|
// use this to allow timeout tracking during long-lasting writes
|
|
845
899
|
uint32_t chunks_sent_since_last_write_ = 0;
|
|
@@ -848,8 +902,11 @@ class Http2Session : public AsyncWrap,
|
|
|
848
902
|
// When processing input data, either stream_buf_ab_ or stream_buf_allocation_
|
|
849
903
|
// will be set. stream_buf_ab_ is lazily created from stream_buf_allocation_.
|
|
850
904
|
v8::Global<v8::ArrayBuffer> stream_buf_ab_;
|
|
851
|
-
|
|
905
|
+
std::unique_ptr<v8::BackingStore> stream_buf_allocation_;
|
|
852
906
|
size_t stream_buf_offset_ = 0;
|
|
907
|
+
// Custom error code for errors that originated inside one of the callbacks
|
|
908
|
+
// called by nghttp2_session_mem_recv.
|
|
909
|
+
const char* custom_recv_error_code_ = nullptr;
|
|
853
910
|
|
|
854
911
|
size_t max_outstanding_pings_ = kDefaultMaxPings;
|
|
855
912
|
std::queue<BaseObjectPtr<Http2Ping>> outstanding_pings_;
|
|
@@ -870,6 +927,9 @@ class Http2Session : public AsyncWrap,
|
|
|
870
927
|
uint32_t invalid_frame_count_ = 0;
|
|
871
928
|
|
|
872
929
|
void PushOutgoingBuffer(NgHttp2StreamWrite&& write);
|
|
930
|
+
|
|
931
|
+
BaseObjectPtr<Http2State> http2_state_;
|
|
932
|
+
|
|
873
933
|
void CopyDataIntoOutgoing(const uint8_t* src, size_t src_length);
|
|
874
934
|
void ClearOutgoing(int status);
|
|
875
935
|
|
|
@@ -877,98 +937,43 @@ class Http2Session : public AsyncWrap,
|
|
|
877
937
|
friend class Http2StreamListener;
|
|
878
938
|
};
|
|
879
939
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
Environment* env,
|
|
884
|
-
const Http2Session::Statistics& stats,
|
|
885
|
-
nghttp2_session_type type) :
|
|
886
|
-
performance::PerformanceEntry(
|
|
887
|
-
env, "Http2Session", "http2",
|
|
888
|
-
stats.start_time,
|
|
889
|
-
stats.end_time),
|
|
890
|
-
ping_rtt_(stats.ping_rtt),
|
|
891
|
-
data_sent_(stats.data_sent),
|
|
892
|
-
data_received_(stats.data_received),
|
|
893
|
-
frame_count_(stats.frame_count),
|
|
894
|
-
frame_sent_(stats.frame_sent),
|
|
895
|
-
stream_count_(stats.stream_count),
|
|
896
|
-
max_concurrent_streams_(stats.max_concurrent_streams),
|
|
897
|
-
stream_average_duration_(stats.stream_average_duration),
|
|
898
|
-
session_type_(type) { }
|
|
899
|
-
|
|
900
|
-
uint64_t ping_rtt() const { return ping_rtt_; }
|
|
901
|
-
uint64_t data_sent() const { return data_sent_; }
|
|
902
|
-
uint64_t data_received() const { return data_received_; }
|
|
903
|
-
uint32_t frame_count() const { return frame_count_; }
|
|
904
|
-
uint32_t frame_sent() const { return frame_sent_; }
|
|
905
|
-
int32_t stream_count() const { return stream_count_; }
|
|
906
|
-
size_t max_concurrent_streams() const { return max_concurrent_streams_; }
|
|
907
|
-
double stream_average_duration() const { return stream_average_duration_; }
|
|
908
|
-
nghttp2_session_type type() const { return session_type_; }
|
|
909
|
-
|
|
910
|
-
void Notify(v8::Local<v8::Value> obj) {
|
|
911
|
-
performance::PerformanceEntry::Notify(env(), kind(), obj);
|
|
912
|
-
}
|
|
940
|
+
struct Http2SessionPerformanceEntryTraits {
|
|
941
|
+
static constexpr performance::PerformanceEntryType kType =
|
|
942
|
+
performance::NODE_PERFORMANCE_ENTRY_TYPE_HTTP2;
|
|
913
943
|
|
|
914
|
-
|
|
915
|
-
uint64_t ping_rtt_;
|
|
916
|
-
uint64_t data_sent_;
|
|
917
|
-
uint64_t data_received_;
|
|
918
|
-
uint32_t frame_count_;
|
|
919
|
-
uint32_t frame_sent_;
|
|
920
|
-
int32_t stream_count_;
|
|
921
|
-
size_t max_concurrent_streams_;
|
|
922
|
-
double stream_average_duration_;
|
|
923
|
-
nghttp2_session_type session_type_;
|
|
924
|
-
};
|
|
944
|
+
using Details = Http2Session::Statistics;
|
|
925
945
|
|
|
926
|
-
|
|
927
|
-
: public performance::PerformanceEntry {
|
|
928
|
-
public:
|
|
929
|
-
Http2StreamPerformanceEntry(
|
|
946
|
+
static v8::MaybeLocal<v8::Object> GetDetails(
|
|
930
947
|
Environment* env,
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
env, "Http2Stream", "http2",
|
|
935
|
-
stats.start_time,
|
|
936
|
-
stats.end_time),
|
|
937
|
-
id_(id),
|
|
938
|
-
first_header_(stats.first_header),
|
|
939
|
-
first_byte_(stats.first_byte),
|
|
940
|
-
first_byte_sent_(stats.first_byte_sent),
|
|
941
|
-
sent_bytes_(stats.sent_bytes),
|
|
942
|
-
received_bytes_(stats.received_bytes) { }
|
|
948
|
+
const performance::PerformanceEntry<Http2SessionPerformanceEntryTraits>&
|
|
949
|
+
entry);
|
|
950
|
+
};
|
|
943
951
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
uint64_t first_byte_sent() const { return first_byte_sent_; }
|
|
948
|
-
uint64_t sent_bytes() const { return sent_bytes_; }
|
|
949
|
-
uint64_t received_bytes() const { return received_bytes_; }
|
|
950
|
-
|
|
951
|
-
void Notify(v8::Local<v8::Value> obj) {
|
|
952
|
-
performance::PerformanceEntry::Notify(env(), kind(), obj);
|
|
953
|
-
}
|
|
952
|
+
struct Http2StreamPerformanceEntryTraits {
|
|
953
|
+
static constexpr performance::PerformanceEntryType kType =
|
|
954
|
+
performance::NODE_PERFORMANCE_ENTRY_TYPE_HTTP2;
|
|
954
955
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
uint64_t received_bytes_;
|
|
956
|
+
using Details = Http2Stream::Statistics;
|
|
957
|
+
|
|
958
|
+
static v8::MaybeLocal<v8::Object> GetDetails(
|
|
959
|
+
Environment* env,
|
|
960
|
+
const performance::PerformanceEntry<Http2StreamPerformanceEntryTraits>&
|
|
961
|
+
entry);
|
|
962
962
|
};
|
|
963
963
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
964
|
+
using Http2SessionPerformanceEntry =
|
|
965
|
+
performance::PerformanceEntry<Http2SessionPerformanceEntryTraits>;
|
|
966
|
+
using Http2StreamPerformanceEntry =
|
|
967
|
+
performance::PerformanceEntry<Http2StreamPerformanceEntryTraits>;
|
|
967
968
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
969
|
+
class Http2Ping : public AsyncWrap {
|
|
970
|
+
public:
|
|
971
|
+
explicit Http2Ping(
|
|
972
|
+
Http2Session* session,
|
|
973
|
+
v8::Local<v8::Object> obj,
|
|
974
|
+
v8::Local<v8::Function> callback);
|
|
971
975
|
|
|
976
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
972
977
|
SET_MEMORY_INFO_NAME(Http2Ping)
|
|
973
978
|
SET_SELF_SIZE(Http2Ping)
|
|
974
979
|
|
|
@@ -976,45 +981,57 @@ class Http2Session::Http2Ping : public AsyncWrap {
|
|
|
976
981
|
void Done(bool ack, const uint8_t* payload = nullptr);
|
|
977
982
|
void DetachFromSession();
|
|
978
983
|
|
|
984
|
+
v8::Local<v8::Function> callback() const;
|
|
985
|
+
|
|
979
986
|
private:
|
|
980
|
-
Http2Session
|
|
987
|
+
BaseObjectWeakPtr<Http2Session> session_;
|
|
988
|
+
v8::Global<v8::Function> callback_;
|
|
981
989
|
uint64_t startTime_;
|
|
982
990
|
};
|
|
983
991
|
|
|
984
992
|
// The Http2Settings class is used to parse the settings passed in for
|
|
985
993
|
// an Http2Session, converting those into an array of nghttp2_settings_entry
|
|
986
994
|
// structs.
|
|
987
|
-
class
|
|
995
|
+
class Http2Settings : public AsyncWrap {
|
|
988
996
|
public:
|
|
989
|
-
Http2Settings(
|
|
990
|
-
Http2Session* session,
|
|
997
|
+
Http2Settings(Http2Session* session,
|
|
991
998
|
v8::Local<v8::Object> obj,
|
|
999
|
+
v8::Local<v8::Function> callback,
|
|
992
1000
|
uint64_t start_time = uv_hrtime());
|
|
993
1001
|
|
|
994
|
-
void MemoryInfo(MemoryTracker* tracker) const override
|
|
995
|
-
tracker->TrackField("session", session_);
|
|
996
|
-
}
|
|
997
|
-
|
|
1002
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
998
1003
|
SET_MEMORY_INFO_NAME(Http2Settings)
|
|
999
1004
|
SET_SELF_SIZE(Http2Settings)
|
|
1000
1005
|
|
|
1001
1006
|
void Send();
|
|
1002
1007
|
void Done(bool ack);
|
|
1003
1008
|
|
|
1009
|
+
v8::Local<v8::Function> callback() const;
|
|
1010
|
+
|
|
1004
1011
|
// Returns a Buffer instance with the serialized SETTINGS payload
|
|
1005
1012
|
v8::Local<v8::Value> Pack();
|
|
1006
1013
|
|
|
1014
|
+
static v8::Local<v8::Value> Pack(Http2State* state);
|
|
1015
|
+
|
|
1007
1016
|
// Resets the default values in the settings buffer
|
|
1008
|
-
static void RefreshDefaults(
|
|
1017
|
+
static void RefreshDefaults(Http2State* http2_state);
|
|
1009
1018
|
|
|
1010
1019
|
// Update the local or remote settings for the given session
|
|
1011
|
-
static void Update(
|
|
1012
|
-
Http2Session* session,
|
|
1020
|
+
static void Update(Http2Session* session,
|
|
1013
1021
|
get_setting fn);
|
|
1014
1022
|
|
|
1015
1023
|
private:
|
|
1016
|
-
|
|
1017
|
-
|
|
1024
|
+
static size_t Init(
|
|
1025
|
+
Http2State* http2_state,
|
|
1026
|
+
nghttp2_settings_entry* entries);
|
|
1027
|
+
|
|
1028
|
+
static v8::Local<v8::Value> Pack(
|
|
1029
|
+
Environment* env,
|
|
1030
|
+
size_t count,
|
|
1031
|
+
const nghttp2_settings_entry* entries);
|
|
1032
|
+
|
|
1033
|
+
BaseObjectWeakPtr<Http2Session> session_;
|
|
1034
|
+
v8::Global<v8::Function> callback_;
|
|
1018
1035
|
uint64_t startTime_;
|
|
1019
1036
|
size_t count_ = 0;
|
|
1020
1037
|
nghttp2_settings_entry entries_[IDX_SETTINGS_COUNT];
|
|
@@ -1022,14 +1039,13 @@ class Http2Session::Http2Settings : public AsyncWrap {
|
|
|
1022
1039
|
|
|
1023
1040
|
class Origins {
|
|
1024
1041
|
public:
|
|
1025
|
-
Origins(
|
|
1026
|
-
v8::Local<v8::Context> context,
|
|
1042
|
+
Origins(Environment* env,
|
|
1027
1043
|
v8::Local<v8::String> origin_string,
|
|
1028
1044
|
size_t origin_count);
|
|
1029
1045
|
~Origins() = default;
|
|
1030
1046
|
|
|
1031
|
-
nghttp2_origin_entry* operator*() {
|
|
1032
|
-
return
|
|
1047
|
+
const nghttp2_origin_entry* operator*() const {
|
|
1048
|
+
return static_cast<const nghttp2_origin_entry*>(bs_->Data());
|
|
1033
1049
|
}
|
|
1034
1050
|
|
|
1035
1051
|
size_t length() const {
|
|
@@ -1038,9 +1054,89 @@ class Origins {
|
|
|
1038
1054
|
|
|
1039
1055
|
private:
|
|
1040
1056
|
size_t count_;
|
|
1041
|
-
|
|
1057
|
+
std::unique_ptr<v8::BackingStore> bs_;
|
|
1042
1058
|
};
|
|
1043
1059
|
|
|
1060
|
+
#define HTTP2_HIDDEN_CONSTANTS(V) \
|
|
1061
|
+
V(NGHTTP2_HCAT_REQUEST) \
|
|
1062
|
+
V(NGHTTP2_HCAT_RESPONSE) \
|
|
1063
|
+
V(NGHTTP2_HCAT_PUSH_RESPONSE) \
|
|
1064
|
+
V(NGHTTP2_HCAT_HEADERS) \
|
|
1065
|
+
V(NGHTTP2_NV_FLAG_NONE) \
|
|
1066
|
+
V(NGHTTP2_NV_FLAG_NO_INDEX) \
|
|
1067
|
+
V(NGHTTP2_ERR_DEFERRED) \
|
|
1068
|
+
V(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE) \
|
|
1069
|
+
V(NGHTTP2_ERR_INVALID_ARGUMENT) \
|
|
1070
|
+
V(NGHTTP2_ERR_STREAM_CLOSED) \
|
|
1071
|
+
V(NGHTTP2_ERR_NOMEM) \
|
|
1072
|
+
V(STREAM_OPTION_EMPTY_PAYLOAD) \
|
|
1073
|
+
V(STREAM_OPTION_GET_TRAILERS)
|
|
1074
|
+
|
|
1075
|
+
#define HTTP2_ERROR_CODES(V) \
|
|
1076
|
+
V(NGHTTP2_NO_ERROR) \
|
|
1077
|
+
V(NGHTTP2_PROTOCOL_ERROR) \
|
|
1078
|
+
V(NGHTTP2_INTERNAL_ERROR) \
|
|
1079
|
+
V(NGHTTP2_FLOW_CONTROL_ERROR) \
|
|
1080
|
+
V(NGHTTP2_SETTINGS_TIMEOUT) \
|
|
1081
|
+
V(NGHTTP2_STREAM_CLOSED) \
|
|
1082
|
+
V(NGHTTP2_FRAME_SIZE_ERROR) \
|
|
1083
|
+
V(NGHTTP2_REFUSED_STREAM) \
|
|
1084
|
+
V(NGHTTP2_CANCEL) \
|
|
1085
|
+
V(NGHTTP2_COMPRESSION_ERROR) \
|
|
1086
|
+
V(NGHTTP2_CONNECT_ERROR) \
|
|
1087
|
+
V(NGHTTP2_ENHANCE_YOUR_CALM) \
|
|
1088
|
+
V(NGHTTP2_INADEQUATE_SECURITY) \
|
|
1089
|
+
V(NGHTTP2_HTTP_1_1_REQUIRED) \
|
|
1090
|
+
|
|
1091
|
+
#define HTTP2_CONSTANTS(V) \
|
|
1092
|
+
V(NGHTTP2_ERR_FRAME_SIZE_ERROR) \
|
|
1093
|
+
V(NGHTTP2_SESSION_SERVER) \
|
|
1094
|
+
V(NGHTTP2_SESSION_CLIENT) \
|
|
1095
|
+
V(NGHTTP2_STREAM_STATE_IDLE) \
|
|
1096
|
+
V(NGHTTP2_STREAM_STATE_OPEN) \
|
|
1097
|
+
V(NGHTTP2_STREAM_STATE_RESERVED_LOCAL) \
|
|
1098
|
+
V(NGHTTP2_STREAM_STATE_RESERVED_REMOTE) \
|
|
1099
|
+
V(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL) \
|
|
1100
|
+
V(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE) \
|
|
1101
|
+
V(NGHTTP2_STREAM_STATE_CLOSED) \
|
|
1102
|
+
V(NGHTTP2_FLAG_NONE) \
|
|
1103
|
+
V(NGHTTP2_FLAG_END_STREAM) \
|
|
1104
|
+
V(NGHTTP2_FLAG_END_HEADERS) \
|
|
1105
|
+
V(NGHTTP2_FLAG_ACK) \
|
|
1106
|
+
V(NGHTTP2_FLAG_PADDED) \
|
|
1107
|
+
V(NGHTTP2_FLAG_PRIORITY) \
|
|
1108
|
+
V(DEFAULT_SETTINGS_HEADER_TABLE_SIZE) \
|
|
1109
|
+
V(DEFAULT_SETTINGS_ENABLE_PUSH) \
|
|
1110
|
+
V(DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS) \
|
|
1111
|
+
V(DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE) \
|
|
1112
|
+
V(DEFAULT_SETTINGS_MAX_FRAME_SIZE) \
|
|
1113
|
+
V(DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE) \
|
|
1114
|
+
V(DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL) \
|
|
1115
|
+
V(MAX_MAX_FRAME_SIZE) \
|
|
1116
|
+
V(MIN_MAX_FRAME_SIZE) \
|
|
1117
|
+
V(MAX_INITIAL_WINDOW_SIZE) \
|
|
1118
|
+
V(NGHTTP2_SETTINGS_HEADER_TABLE_SIZE) \
|
|
1119
|
+
V(NGHTTP2_SETTINGS_ENABLE_PUSH) \
|
|
1120
|
+
V(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS) \
|
|
1121
|
+
V(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE) \
|
|
1122
|
+
V(NGHTTP2_SETTINGS_MAX_FRAME_SIZE) \
|
|
1123
|
+
V(NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE) \
|
|
1124
|
+
V(NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL) \
|
|
1125
|
+
V(PADDING_STRATEGY_NONE) \
|
|
1126
|
+
V(PADDING_STRATEGY_ALIGNED) \
|
|
1127
|
+
V(PADDING_STRATEGY_MAX) \
|
|
1128
|
+
V(PADDING_STRATEGY_CALLBACK) \
|
|
1129
|
+
HTTP2_ERROR_CODES(V)
|
|
1130
|
+
|
|
1131
|
+
#define HTTP2_SETTINGS(V) \
|
|
1132
|
+
V(HEADER_TABLE_SIZE) \
|
|
1133
|
+
V(ENABLE_PUSH) \
|
|
1134
|
+
V(MAX_CONCURRENT_STREAMS) \
|
|
1135
|
+
V(INITIAL_WINDOW_SIZE) \
|
|
1136
|
+
V(MAX_FRAME_SIZE) \
|
|
1137
|
+
V(MAX_HEADER_LIST_SIZE) \
|
|
1138
|
+
V(ENABLE_CONNECT_PROTOCOL) \
|
|
1139
|
+
|
|
1044
1140
|
} // namespace http2
|
|
1045
1141
|
} // namespace node
|
|
1046
1142
|
|