@encharm/cws 4.3.0 → 4.4.1
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/README.md +5 -7
- package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
- package/dist/bindings/cws_darwin_x64_node108.node +0 -0
- package/dist/bindings/cws_darwin_x64_node115.node +0 -0
- package/dist/bindings/cws_darwin_x64_node83.node +0 -0
- package/dist/bindings/cws_darwin_x64_node93.node +0 -0
- package/dist/bindings/cws_linux_arm64_node108.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node83.node +0 -0
- package/dist/bindings/cws_linux_arm64_node93.node +0 -0
- package/dist/bindings/cws_linux_x64_node108.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node83.node +0 -0
- package/dist/bindings/cws_linux_x64_node93.node +0 -0
- package/dist/bindings/cws_win32_x64_node108.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node83.node +0 -0
- package/dist/bindings/cws_win32_x64_node93.node +0 -0
- package/dist/shared.js +1 -1
- package/package.json +5 -5
- package/src/Addon.cpp +4 -12
- package/src/Addon.h +67 -91
- package/src/Socket.h +1 -0
- package/src/cSNode.cpp +3 -8
- package/src/headers/20/acorn_version.h +6 -0
- package/src/headers/20/aliased_buffer-inl.h +243 -0
- package/src/headers/20/aliased_buffer.h +206 -0
- package/src/headers/20/aliased_struct-inl.h +54 -0
- package/src/headers/20/aliased_struct.h +63 -0
- package/src/headers/20/async_wrap-inl.h +93 -0
- package/src/headers/20/async_wrap.h +252 -0
- package/src/headers/20/base64-inl.h +193 -0
- package/src/headers/20/base64.h +53 -0
- package/src/headers/20/base64_version.h +6 -0
- package/src/headers/20/base_object-inl.h +316 -0
- package/src/headers/20/base_object.h +320 -0
- package/src/headers/20/base_object_types.h +73 -0
- package/src/headers/20/blob_serializer_deserializer-inl.h +361 -0
- package/src/headers/20/blob_serializer_deserializer.h +132 -0
- package/src/headers/20/callback_queue-inl.h +97 -0
- package/src/headers/20/callback_queue.h +79 -0
- package/src/headers/20/cares_wrap.h +524 -0
- package/src/headers/20/cjs_module_lexer_version.h +6 -0
- package/src/headers/20/cleanup_queue-inl.h +62 -0
- package/src/headers/20/cleanup_queue.h +85 -0
- package/src/headers/20/connect_wrap.h +26 -0
- package/src/headers/20/connection_wrap.h +30 -0
- package/src/headers/20/cppgc/DEPS +8 -0
- package/src/headers/20/cppgc/OWNERS +2 -0
- package/src/headers/20/cppgc/README.md +135 -0
- package/src/headers/20/cppgc/allocation.h +310 -0
- package/src/headers/20/cppgc/common.h +28 -0
- package/src/headers/20/cppgc/cross-thread-persistent.h +466 -0
- package/src/headers/20/cppgc/custom-space.h +97 -0
- package/src/headers/20/cppgc/default-platform.h +67 -0
- package/src/headers/20/cppgc/ephemeron-pair.h +30 -0
- package/src/headers/20/cppgc/explicit-management.h +100 -0
- package/src/headers/20/cppgc/garbage-collected.h +106 -0
- package/src/headers/20/cppgc/heap-consistency.h +309 -0
- package/src/headers/20/cppgc/heap-handle.h +48 -0
- package/src/headers/20/cppgc/heap-state.h +82 -0
- package/src/headers/20/cppgc/heap-statistics.h +120 -0
- package/src/headers/20/cppgc/heap.h +202 -0
- package/src/headers/20/cppgc/internal/api-constants.h +68 -0
- package/src/headers/20/cppgc/internal/atomic-entry-flag.h +48 -0
- package/src/headers/20/cppgc/internal/base-page-handle.h +45 -0
- package/src/headers/20/cppgc/internal/caged-heap-local-data.h +111 -0
- package/src/headers/20/cppgc/internal/caged-heap.h +61 -0
- package/src/headers/20/cppgc/internal/compiler-specific.h +38 -0
- package/src/headers/20/cppgc/internal/finalizer-trait.h +93 -0
- package/src/headers/20/cppgc/internal/gc-info.h +157 -0
- package/src/headers/20/cppgc/internal/logging.h +50 -0
- package/src/headers/20/cppgc/internal/member-storage.h +248 -0
- package/src/headers/20/cppgc/internal/name-trait.h +137 -0
- package/src/headers/20/cppgc/internal/persistent-node.h +214 -0
- package/src/headers/20/cppgc/internal/pointer-policies.h +243 -0
- package/src/headers/20/cppgc/internal/write-barrier.h +487 -0
- package/src/headers/20/cppgc/liveness-broker.h +78 -0
- package/src/headers/20/cppgc/macros.h +35 -0
- package/src/headers/20/cppgc/member.h +604 -0
- package/src/headers/20/cppgc/name-provider.h +65 -0
- package/src/headers/20/cppgc/object-size-trait.h +58 -0
- package/src/headers/20/cppgc/persistent.h +373 -0
- package/src/headers/20/cppgc/platform.h +158 -0
- package/src/headers/20/cppgc/prefinalizer.h +75 -0
- package/src/headers/20/cppgc/process-heap-statistics.h +36 -0
- package/src/headers/20/cppgc/sentinel-pointer.h +32 -0
- package/src/headers/20/cppgc/source-location.h +92 -0
- package/src/headers/20/cppgc/testing.h +106 -0
- package/src/headers/20/cppgc/trace-trait.h +120 -0
- package/src/headers/20/cppgc/type-traits.h +250 -0
- package/src/headers/20/cppgc/visitor.h +426 -0
- package/src/headers/20/crypto/crypto_clienthello.h +131 -0
- package/src/headers/20/crypto/crypto_context.h +160 -0
- package/src/headers/20/crypto/crypto_keys.h +419 -0
- package/src/headers/20/crypto/crypto_tls.h +304 -0
- package/src/headers/20/crypto/crypto_util.h +806 -0
- package/src/headers/20/crypto_clienthello.h +131 -0
- package/src/headers/20/debug_utils-inl.h +226 -0
- package/src/headers/20/debug_utils.h +188 -0
- package/src/headers/20/diagnosticfilename-inl.h +33 -0
- package/src/headers/20/encoding_binding.h +59 -0
- package/src/headers/20/env-inl.h +923 -0
- package/src/headers/20/env.h +1193 -0
- package/src/headers/20/env_properties.h +446 -0
- package/src/headers/20/handle_wrap.h +123 -0
- package/src/headers/20/histogram-inl.h +107 -0
- package/src/headers/20/histogram.h +240 -0
- package/src/headers/20/inspector_agent.h +144 -0
- package/src/headers/20/inspector_io.h +78 -0
- package/src/headers/20/inspector_profiler.h +149 -0
- package/src/headers/20/inspector_socket.h +60 -0
- package/src/headers/20/inspector_socket_server.h +110 -0
- package/src/headers/20/js_native_api.h +601 -0
- package/src/headers/20/js_native_api_types.h +168 -0
- package/src/headers/20/js_native_api_v8.h +463 -0
- package/src/headers/20/js_native_api_v8_internals.h +45 -0
- package/src/headers/20/js_stream.h +52 -0
- package/src/headers/20/json_parser.h +38 -0
- package/src/headers/20/json_utils.h +172 -0
- package/src/headers/20/memory_tracker-inl.h +356 -0
- package/src/headers/20/memory_tracker.h +289 -0
- package/src/headers/20/module_wrap.h +117 -0
- package/src/headers/20/node.h +1516 -0
- package/src/headers/20/node_api.h +261 -0
- package/src/headers/20/node_api_internals.h +42 -0
- package/src/headers/20/node_api_types.h +52 -0
- package/src/headers/20/node_binding.h +142 -0
- package/src/headers/20/node_blob.h +159 -0
- package/src/headers/20/node_bob-inl.h +36 -0
- package/src/headers/20/node_bob.h +107 -0
- package/src/headers/20/node_buffer.h +92 -0
- package/src/headers/20/node_builtins.h +197 -0
- package/src/headers/20/node_constants.h +82 -0
- package/src/headers/20/node_context_data.h +98 -0
- package/src/headers/20/node_contextify.h +206 -0
- package/src/headers/20/node_crypto.h +56 -0
- package/src/headers/20/node_dir.h +52 -0
- package/src/headers/20/node_dotenv.h +37 -0
- package/src/headers/20/node_errors.h +313 -0
- package/src/headers/20/node_exit_code.h +54 -0
- package/src/headers/20/node_external_reference.h +172 -0
- package/src/headers/20/node_file-inl.h +389 -0
- package/src/headers/20/node_file.h +537 -0
- package/src/headers/20/node_http2.h +1146 -0
- package/src/headers/20/node_http2_state.h +147 -0
- package/src/headers/20/node_http_common-inl.h +201 -0
- package/src/headers/20/node_http_common.h +532 -0
- package/src/headers/20/node_i18n.h +145 -0
- package/src/headers/20/node_internals.h +443 -0
- package/src/headers/20/node_main_instance.h +67 -0
- package/src/headers/20/node_mem-inl.h +112 -0
- package/src/headers/20/node_mem.h +45 -0
- package/src/headers/20/node_messaging.h +377 -0
- package/src/headers/20/node_metadata.h +138 -0
- package/src/headers/20/node_mutex.h +323 -0
- package/src/headers/20/node_object_wrap.h +132 -0
- package/src/headers/20/node_options-inl.h +478 -0
- package/src/headers/20/node_options.h +538 -0
- package/src/headers/20/node_perf.h +166 -0
- package/src/headers/20/node_perf_common.h +98 -0
- package/src/headers/20/node_platform.h +195 -0
- package/src/headers/20/node_process-inl.h +26 -0
- package/src/headers/20/node_process.h +99 -0
- package/src/headers/20/node_realm-inl.h +139 -0
- package/src/headers/20/node_realm.h +184 -0
- package/src/headers/20/node_report.h +42 -0
- package/src/headers/20/node_revert.h +82 -0
- package/src/headers/20/node_root_certs.h +3443 -0
- package/src/headers/20/node_sea.h +56 -0
- package/src/headers/20/node_shadow_realm.h +46 -0
- package/src/headers/20/node_snapshot_builder.h +54 -0
- package/src/headers/20/node_snapshotable.h +164 -0
- package/src/headers/20/node_sockaddr-inl.h +266 -0
- package/src/headers/20/node_sockaddr.h +405 -0
- package/src/headers/20/node_stat_watcher.h +73 -0
- package/src/headers/20/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/20/node_threadsafe_cow.h +105 -0
- package/src/headers/20/node_union_bytes.h +81 -0
- package/src/headers/20/node_url.h +92 -0
- package/src/headers/20/node_v8.h +77 -0
- package/src/headers/20/node_v8_platform-inl.h +205 -0
- package/src/headers/20/node_version.h +109 -0
- package/src/headers/20/node_wasi.h +184 -0
- package/src/headers/20/node_wasm_web_api.h +55 -0
- package/src/headers/20/node_watchdog.h +154 -0
- package/src/headers/20/node_worker.h +151 -0
- package/src/headers/20/permission/child_process_permission.h +29 -0
- package/src/headers/20/permission/fs_permission.h +154 -0
- package/src/headers/20/permission/inspector_permission.h +29 -0
- package/src/headers/20/permission/permission.h +74 -0
- package/src/headers/20/permission/permission_base.h +53 -0
- package/src/headers/20/permission/worker_permission.h +29 -0
- package/src/headers/20/pipe_wrap.h +80 -0
- package/src/headers/20/req_wrap-inl.h +171 -0
- package/src/headers/20/req_wrap.h +77 -0
- package/src/headers/20/spawn_sync.h +242 -0
- package/src/headers/20/stream_base-inl.h +173 -0
- package/src/headers/20/stream_base.h +469 -0
- package/src/headers/20/stream_pipe.h +76 -0
- package/src/headers/20/stream_wrap.h +131 -0
- package/src/headers/20/string_bytes.h +120 -0
- package/src/headers/20/string_decoder-inl.h +37 -0
- package/src/headers/20/string_decoder.h +50 -0
- package/src/headers/20/string_search.h +638 -0
- package/src/headers/20/tcp_wrap.h +105 -0
- package/src/headers/20/threadpoolwork-inl.h +70 -0
- package/src/headers/20/timer_wrap-inl.h +32 -0
- package/src/headers/20/timer_wrap.h +85 -0
- package/src/headers/20/timers.h +70 -0
- package/src/headers/20/tracing/agent.h +195 -0
- package/src/headers/20/tracing/node_trace_buffer.h +83 -0
- package/src/headers/20/tracing/node_trace_writer.h +75 -0
- package/src/headers/20/tracing/trace_event.h +720 -0
- package/src/headers/20/tracing/trace_event_common.h +1109 -0
- package/src/headers/20/tracing/traced_value.h +70 -0
- package/src/headers/20/tty_wrap.h +65 -0
- package/src/headers/20/udp_wrap.h +227 -0
- package/src/headers/20/undici_version.h +6 -0
- package/src/headers/20/util-inl.h +623 -0
- package/src/headers/20/util.h +988 -0
- package/src/headers/20/v8-cppgc.h +245 -0
- package/src/headers/20/v8-fast-api-calls.h +957 -0
- package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
- package/dist/bindings/cws_darwin_x64_node64.node +0 -0
- package/dist/bindings/cws_darwin_x64_node72.node +0 -0
- package/dist/bindings/cws_darwin_x64_node79.node +0 -0
- package/dist/bindings/cws_linux_x64_node64.node +0 -0
- package/dist/bindings/cws_linux_x64_node72.node +0 -0
- package/dist/bindings/cws_linux_x64_node79.node +0 -0
- package/dist/bindings/cws_win32_x64_node64.node +0 -0
- package/dist/bindings/cws_win32_x64_node72.node +0 -0
- package/dist/bindings/cws_win32_x64_node79.node +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#ifndef SRC_NODE_HTTP2_STATE_H_
|
|
2
|
+
#define SRC_NODE_HTTP2_STATE_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "aliased_buffer.h"
|
|
7
|
+
|
|
8
|
+
struct nghttp2_rcbuf;
|
|
9
|
+
|
|
10
|
+
namespace node {
|
|
11
|
+
namespace http2 {
|
|
12
|
+
|
|
13
|
+
enum Http2SettingsIndex {
|
|
14
|
+
IDX_SETTINGS_HEADER_TABLE_SIZE,
|
|
15
|
+
IDX_SETTINGS_ENABLE_PUSH,
|
|
16
|
+
IDX_SETTINGS_INITIAL_WINDOW_SIZE,
|
|
17
|
+
IDX_SETTINGS_MAX_FRAME_SIZE,
|
|
18
|
+
IDX_SETTINGS_MAX_CONCURRENT_STREAMS,
|
|
19
|
+
IDX_SETTINGS_MAX_HEADER_LIST_SIZE,
|
|
20
|
+
IDX_SETTINGS_ENABLE_CONNECT_PROTOCOL,
|
|
21
|
+
IDX_SETTINGS_COUNT
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
enum Http2SessionStateIndex {
|
|
25
|
+
IDX_SESSION_STATE_EFFECTIVE_LOCAL_WINDOW_SIZE,
|
|
26
|
+
IDX_SESSION_STATE_EFFECTIVE_RECV_DATA_LENGTH,
|
|
27
|
+
IDX_SESSION_STATE_NEXT_STREAM_ID,
|
|
28
|
+
IDX_SESSION_STATE_LOCAL_WINDOW_SIZE,
|
|
29
|
+
IDX_SESSION_STATE_LAST_PROC_STREAM_ID,
|
|
30
|
+
IDX_SESSION_STATE_REMOTE_WINDOW_SIZE,
|
|
31
|
+
IDX_SESSION_STATE_OUTBOUND_QUEUE_SIZE,
|
|
32
|
+
IDX_SESSION_STATE_HD_DEFLATE_DYNAMIC_TABLE_SIZE,
|
|
33
|
+
IDX_SESSION_STATE_HD_INFLATE_DYNAMIC_TABLE_SIZE,
|
|
34
|
+
IDX_SESSION_STATE_COUNT
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
enum Http2StreamStateIndex {
|
|
38
|
+
IDX_STREAM_STATE,
|
|
39
|
+
IDX_STREAM_STATE_WEIGHT,
|
|
40
|
+
IDX_STREAM_STATE_SUM_DEPENDENCY_WEIGHT,
|
|
41
|
+
IDX_STREAM_STATE_LOCAL_CLOSE,
|
|
42
|
+
IDX_STREAM_STATE_REMOTE_CLOSE,
|
|
43
|
+
IDX_STREAM_STATE_LOCAL_WINDOW_SIZE,
|
|
44
|
+
IDX_STREAM_STATE_COUNT
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
enum Http2OptionsIndex {
|
|
48
|
+
IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE,
|
|
49
|
+
IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS,
|
|
50
|
+
IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH,
|
|
51
|
+
IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS,
|
|
52
|
+
IDX_OPTIONS_PADDING_STRATEGY,
|
|
53
|
+
IDX_OPTIONS_MAX_HEADER_LIST_PAIRS,
|
|
54
|
+
IDX_OPTIONS_MAX_OUTSTANDING_PINGS,
|
|
55
|
+
IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS,
|
|
56
|
+
IDX_OPTIONS_MAX_SESSION_MEMORY,
|
|
57
|
+
IDX_OPTIONS_MAX_SETTINGS,
|
|
58
|
+
IDX_OPTIONS_FLAGS
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
enum Http2StreamStatisticsIndex {
|
|
62
|
+
IDX_STREAM_STATS_ID,
|
|
63
|
+
IDX_STREAM_STATS_TIMETOFIRSTBYTE,
|
|
64
|
+
IDX_STREAM_STATS_TIMETOFIRSTHEADER,
|
|
65
|
+
IDX_STREAM_STATS_TIMETOFIRSTBYTESENT,
|
|
66
|
+
IDX_STREAM_STATS_SENTBYTES,
|
|
67
|
+
IDX_STREAM_STATS_RECEIVEDBYTES,
|
|
68
|
+
IDX_STREAM_STATS_COUNT
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
enum Http2SessionStatisticsIndex {
|
|
72
|
+
IDX_SESSION_STATS_TYPE,
|
|
73
|
+
IDX_SESSION_STATS_PINGRTT,
|
|
74
|
+
IDX_SESSION_STATS_FRAMESRECEIVED,
|
|
75
|
+
IDX_SESSION_STATS_FRAMESSENT,
|
|
76
|
+
IDX_SESSION_STATS_STREAMCOUNT,
|
|
77
|
+
IDX_SESSION_STATS_STREAMAVERAGEDURATION,
|
|
78
|
+
IDX_SESSION_STATS_DATA_SENT,
|
|
79
|
+
IDX_SESSION_STATS_DATA_RECEIVED,
|
|
80
|
+
IDX_SESSION_STATS_MAX_CONCURRENT_STREAMS,
|
|
81
|
+
IDX_SESSION_STATS_COUNT
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
class Http2State : public BaseObject {
|
|
85
|
+
public:
|
|
86
|
+
Http2State(Realm* realm, v8::Local<v8::Object> obj)
|
|
87
|
+
: BaseObject(realm, obj),
|
|
88
|
+
root_buffer(realm->isolate(), sizeof(http2_state_internal)),
|
|
89
|
+
session_state_buffer(
|
|
90
|
+
realm->isolate(),
|
|
91
|
+
offsetof(http2_state_internal, session_state_buffer),
|
|
92
|
+
IDX_SESSION_STATE_COUNT,
|
|
93
|
+
root_buffer),
|
|
94
|
+
stream_state_buffer(realm->isolate(),
|
|
95
|
+
offsetof(http2_state_internal, stream_state_buffer),
|
|
96
|
+
IDX_STREAM_STATE_COUNT,
|
|
97
|
+
root_buffer),
|
|
98
|
+
stream_stats_buffer(realm->isolate(),
|
|
99
|
+
offsetof(http2_state_internal, stream_stats_buffer),
|
|
100
|
+
IDX_STREAM_STATS_COUNT,
|
|
101
|
+
root_buffer),
|
|
102
|
+
session_stats_buffer(
|
|
103
|
+
realm->isolate(),
|
|
104
|
+
offsetof(http2_state_internal, session_stats_buffer),
|
|
105
|
+
IDX_SESSION_STATS_COUNT,
|
|
106
|
+
root_buffer),
|
|
107
|
+
options_buffer(realm->isolate(),
|
|
108
|
+
offsetof(http2_state_internal, options_buffer),
|
|
109
|
+
IDX_OPTIONS_FLAGS + 1,
|
|
110
|
+
root_buffer),
|
|
111
|
+
settings_buffer(realm->isolate(),
|
|
112
|
+
offsetof(http2_state_internal, settings_buffer),
|
|
113
|
+
IDX_SETTINGS_COUNT + 1,
|
|
114
|
+
root_buffer) {}
|
|
115
|
+
|
|
116
|
+
AliasedUint8Array root_buffer;
|
|
117
|
+
AliasedFloat64Array session_state_buffer;
|
|
118
|
+
AliasedFloat64Array stream_state_buffer;
|
|
119
|
+
AliasedFloat64Array stream_stats_buffer;
|
|
120
|
+
AliasedFloat64Array session_stats_buffer;
|
|
121
|
+
AliasedUint32Array options_buffer;
|
|
122
|
+
AliasedUint32Array settings_buffer;
|
|
123
|
+
|
|
124
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
125
|
+
SET_SELF_SIZE(Http2State)
|
|
126
|
+
SET_MEMORY_INFO_NAME(Http2State)
|
|
127
|
+
|
|
128
|
+
SET_BINDING_ID(http2_binding_data)
|
|
129
|
+
|
|
130
|
+
private:
|
|
131
|
+
struct http2_state_internal {
|
|
132
|
+
// doubles first so that they are always sizeof(double)-aligned
|
|
133
|
+
double session_state_buffer[IDX_SESSION_STATE_COUNT];
|
|
134
|
+
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
|
|
135
|
+
double stream_stats_buffer[IDX_STREAM_STATS_COUNT];
|
|
136
|
+
double session_stats_buffer[IDX_SESSION_STATS_COUNT];
|
|
137
|
+
uint32_t options_buffer[IDX_OPTIONS_FLAGS + 1];
|
|
138
|
+
uint32_t settings_buffer[IDX_SETTINGS_COUNT + 1];
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
} // namespace http2
|
|
143
|
+
} // namespace node
|
|
144
|
+
|
|
145
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
146
|
+
|
|
147
|
+
#endif // SRC_NODE_HTTP2_STATE_H_
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#ifndef SRC_NODE_HTTP_COMMON_INL_H_
|
|
2
|
+
#define SRC_NODE_HTTP_COMMON_INL_H_
|
|
3
|
+
|
|
4
|
+
#include "node_http_common.h"
|
|
5
|
+
#include "node.h"
|
|
6
|
+
#include "node_mem-inl.h"
|
|
7
|
+
#include "env-inl.h"
|
|
8
|
+
#include "v8.h"
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
|
|
12
|
+
namespace node {
|
|
13
|
+
|
|
14
|
+
template <typename T>
|
|
15
|
+
NgHeaders<T>::NgHeaders(Environment* env, v8::Local<v8::Array> headers) {
|
|
16
|
+
v8::Local<v8::Value> header_string =
|
|
17
|
+
headers->Get(env->context(), 0).ToLocalChecked();
|
|
18
|
+
v8::Local<v8::Value> header_count =
|
|
19
|
+
headers->Get(env->context(), 1).ToLocalChecked();
|
|
20
|
+
CHECK(header_count->IsUint32());
|
|
21
|
+
CHECK(header_string->IsString());
|
|
22
|
+
count_ = header_count.As<v8::Uint32>()->Value();
|
|
23
|
+
int header_string_len = header_string.As<v8::String>()->Length();
|
|
24
|
+
|
|
25
|
+
if (count_ == 0) {
|
|
26
|
+
CHECK_EQ(header_string_len, 0);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
buf_.AllocateSufficientStorage((alignof(nv_t) - 1) +
|
|
31
|
+
count_ * sizeof(nv_t) +
|
|
32
|
+
header_string_len);
|
|
33
|
+
|
|
34
|
+
char* start = AlignUp(buf_.out(), alignof(nv_t));
|
|
35
|
+
char* header_contents = start + (count_ * sizeof(nv_t));
|
|
36
|
+
nv_t* const nva = reinterpret_cast<nv_t*>(start);
|
|
37
|
+
|
|
38
|
+
CHECK_LE(header_contents + header_string_len, *buf_ + buf_.length());
|
|
39
|
+
CHECK_EQ(header_string.As<v8::String>()->WriteOneByte(
|
|
40
|
+
env->isolate(),
|
|
41
|
+
reinterpret_cast<uint8_t*>(header_contents),
|
|
42
|
+
0,
|
|
43
|
+
header_string_len,
|
|
44
|
+
v8::String::NO_NULL_TERMINATION),
|
|
45
|
+
header_string_len);
|
|
46
|
+
|
|
47
|
+
size_t n = 0;
|
|
48
|
+
char* p;
|
|
49
|
+
for (p = header_contents; p < header_contents + header_string_len; n++) {
|
|
50
|
+
if (n >= count_) {
|
|
51
|
+
static uint8_t zero = '\0';
|
|
52
|
+
nva[0].name = nva[0].value = &zero;
|
|
53
|
+
nva[0].namelen = nva[0].valuelen = 1;
|
|
54
|
+
count_ = 1;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
nva[n].name = reinterpret_cast<uint8_t*>(p);
|
|
59
|
+
nva[n].namelen = strlen(p);
|
|
60
|
+
p += nva[n].namelen + 1;
|
|
61
|
+
nva[n].value = reinterpret_cast<uint8_t*>(p);
|
|
62
|
+
nva[n].valuelen = strlen(p);
|
|
63
|
+
p += nva[n].valuelen + 1;
|
|
64
|
+
nva[n].flags = *p;
|
|
65
|
+
p++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
size_t GetClientMaxHeaderPairs(size_t max_header_pairs) {
|
|
70
|
+
static constexpr size_t min_header_pairs = 1;
|
|
71
|
+
return std::max(max_header_pairs, min_header_pairs);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
size_t GetServerMaxHeaderPairs(size_t max_header_pairs) {
|
|
75
|
+
static constexpr size_t min_header_pairs = 4;
|
|
76
|
+
return std::max(max_header_pairs, min_header_pairs);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
template <typename allocator_t>
|
|
80
|
+
std::string NgHeaderBase<allocator_t>::ToString() const {
|
|
81
|
+
std::string ret = name();
|
|
82
|
+
ret += " = ";
|
|
83
|
+
ret += value();
|
|
84
|
+
return ret;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
template <typename T>
|
|
88
|
+
bool NgHeader<T>::IsZeroLength(
|
|
89
|
+
NgHeader<T>::rcbuf_t* name,
|
|
90
|
+
NgHeader<T>::rcbuf_t* value) {
|
|
91
|
+
return IsZeroLength(-1, name, value);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
template <typename T>
|
|
95
|
+
bool NgHeader<T>::IsZeroLength(
|
|
96
|
+
int32_t token,
|
|
97
|
+
NgHeader<T>::rcbuf_t* name,
|
|
98
|
+
NgHeader<T>::rcbuf_t* value) {
|
|
99
|
+
|
|
100
|
+
if (NgHeader<T>::rcbufferpointer_t::IsZeroLength(value))
|
|
101
|
+
return true;
|
|
102
|
+
|
|
103
|
+
const char* header_name = T::ToHttpHeaderName(token);
|
|
104
|
+
return header_name != nullptr ||
|
|
105
|
+
NgHeader<T>::rcbufferpointer_t::IsZeroLength(name);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
template <typename T>
|
|
109
|
+
NgHeader<T>::NgHeader(
|
|
110
|
+
Environment* env,
|
|
111
|
+
NgHeader<T>::rcbuf_t* name,
|
|
112
|
+
NgHeader<T>::rcbuf_t* value,
|
|
113
|
+
uint8_t flags)
|
|
114
|
+
: NgHeader<T>(env, -1, name, value, flags) {}
|
|
115
|
+
|
|
116
|
+
template <typename T>
|
|
117
|
+
NgHeader<T>::NgHeader(
|
|
118
|
+
Environment* env,
|
|
119
|
+
int32_t token,
|
|
120
|
+
NgHeader<T>::rcbuf_t* name,
|
|
121
|
+
NgHeader<T>::rcbuf_t* value,
|
|
122
|
+
uint8_t flags) : env_(env), token_(token), flags_(flags) {
|
|
123
|
+
if (token == -1) {
|
|
124
|
+
CHECK_NOT_NULL(name);
|
|
125
|
+
name_.reset(name, true); // Internalizable
|
|
126
|
+
}
|
|
127
|
+
CHECK_NOT_NULL(value);
|
|
128
|
+
name_.reset(name, true); // Internalizable
|
|
129
|
+
value_.reset(value);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
template <typename T>
|
|
133
|
+
NgHeader<T>::NgHeader(NgHeader<T>&& other) noexcept
|
|
134
|
+
: env_(other.env_),
|
|
135
|
+
name_(std::move(other.name_)),
|
|
136
|
+
value_(std::move(other.value_)),
|
|
137
|
+
token_(other.token_),
|
|
138
|
+
flags_(other.flags_) {
|
|
139
|
+
other.token_ = -1;
|
|
140
|
+
other.flags_ = 0;
|
|
141
|
+
other.env_ = nullptr;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
template <typename T>
|
|
145
|
+
void NgHeader<T>::MemoryInfo(MemoryTracker* tracker) const {
|
|
146
|
+
tracker->TrackField("name", name_);
|
|
147
|
+
tracker->TrackField("value", value_);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
template <typename T>
|
|
151
|
+
v8::MaybeLocal<v8::String> NgHeader<T>::GetName(
|
|
152
|
+
NgHeader<T>::allocator_t* allocator) const {
|
|
153
|
+
|
|
154
|
+
// Not all instances will support using token id's for header names.
|
|
155
|
+
// HTTP/2 specifically does not support it.
|
|
156
|
+
const char* header_name = T::ToHttpHeaderName(token_);
|
|
157
|
+
|
|
158
|
+
// If header_name is not nullptr, then it is a known header with
|
|
159
|
+
// a statically defined name. We can safely internalize it here.
|
|
160
|
+
if (header_name != nullptr) {
|
|
161
|
+
auto& static_str_map = env_->isolate_data()->static_str_map;
|
|
162
|
+
v8::Eternal<v8::String> eternal = static_str_map[header_name];
|
|
163
|
+
if (eternal.IsEmpty()) {
|
|
164
|
+
v8::Local<v8::String> str = OneByteString(env_->isolate(), header_name);
|
|
165
|
+
eternal.Set(env_->isolate(), str);
|
|
166
|
+
return str;
|
|
167
|
+
}
|
|
168
|
+
return eternal.Get(env_->isolate());
|
|
169
|
+
}
|
|
170
|
+
return rcbufferpointer_t::External::New(allocator, name_);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
template <typename T>
|
|
174
|
+
v8::MaybeLocal<v8::String> NgHeader<T>::GetValue(
|
|
175
|
+
NgHeader<T>::allocator_t* allocator) const {
|
|
176
|
+
return rcbufferpointer_t::External::New(allocator, value_);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
template <typename T>
|
|
180
|
+
std::string NgHeader<T>::name() const {
|
|
181
|
+
return name_.str();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
template <typename T>
|
|
185
|
+
std::string NgHeader<T>::value() const {
|
|
186
|
+
return value_.str();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
template <typename T>
|
|
190
|
+
size_t NgHeader<T>::length() const {
|
|
191
|
+
return name_.len() + value_.len();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
template <typename T>
|
|
195
|
+
uint8_t NgHeader<T>::flags() const {
|
|
196
|
+
return flags_;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
} // namespace node
|
|
200
|
+
|
|
201
|
+
#endif // SRC_NODE_HTTP_COMMON_INL_H_
|