@encharm/cws 4.4.1 → 4.5.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.
Files changed (485) hide show
  1. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  2. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  3. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  4. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  5. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  6. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  7. package/dist/bindings/cws_win32_x64_node108.node +0 -0
  8. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  9. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  10. package/dist/bindings/cws_win32_x64_node83.node +0 -0
  11. package/dist/bindings/cws_win32_x64_node93.node +0 -0
  12. package/package.json +1 -1
  13. package/src/Addon.h +8 -23
  14. package/src/Socket.h +0 -1
  15. package/src/headers/22/acorn_version.h +6 -0
  16. package/src/headers/22/aliased_buffer-inl.h +243 -0
  17. package/src/headers/22/aliased_buffer.h +206 -0
  18. package/src/headers/{18 → 22}/async_wrap-inl.h +8 -6
  19. package/src/headers/{18 → 22}/async_wrap.h +65 -59
  20. package/src/headers/{16 → 22}/base_object-inl.h +57 -117
  21. package/src/headers/{18 → 22}/base_object.h +58 -30
  22. package/src/headers/22/base_object_types.h +74 -0
  23. package/src/headers/22/blob_serializer_deserializer-inl.h +385 -0
  24. package/src/headers/22/blob_serializer_deserializer.h +132 -0
  25. package/src/headers/{16 → 22}/callback_queue.h +1 -0
  26. package/src/headers/{16 → 22}/cares_wrap.h +27 -20
  27. package/src/headers/22/cjs_module_lexer_version.h +6 -0
  28. package/src/headers/22/cleanup_queue-inl.h +62 -0
  29. package/src/headers/22/cleanup_queue.h +85 -0
  30. package/src/headers/22/compile_cache.h +104 -0
  31. package/src/headers/{18 → 22}/crypto/crypto_clienthello.h +1 -1
  32. package/src/headers/{18 → 22}/crypto/crypto_context.h +31 -7
  33. package/src/headers/{18 → 22}/crypto/crypto_keys.h +118 -148
  34. package/src/headers/{18 → 22}/crypto/crypto_tls.h +20 -5
  35. package/src/headers/{18 → 22}/crypto/crypto_util.h +219 -263
  36. package/src/headers/22/crypto/ncrypto.h +752 -0
  37. package/src/headers/{16 → 22}/debug_utils-inl.h +15 -7
  38. package/src/headers/{18 → 22}/debug_utils.h +25 -19
  39. package/src/headers/22/encoding_binding.h +59 -0
  40. package/src/headers/{14 → 22}/env-inl.h +276 -409
  41. package/src/headers/22/env.h +1266 -0
  42. package/src/headers/22/env_properties.h +497 -0
  43. package/src/headers/{18 → 22}/handle_wrap.h +2 -0
  44. package/src/headers/{18 → 22}/histogram.h +88 -48
  45. package/src/headers/{16 → 22}/inspector_agent.h +17 -1
  46. package/src/headers/{16 → 22}/inspector_profiler.h +15 -13
  47. package/src/headers/{18 → 22}/js_native_api.h +78 -30
  48. package/src/headers/{18 → 22}/js_native_api_types.h +46 -1
  49. package/src/headers/{18 → 22}/js_native_api_v8.h +206 -161
  50. package/src/headers/{18 → 22}/js_native_api_v8_internals.h +6 -0
  51. package/src/headers/22/json_parser.h +40 -0
  52. package/src/headers/{16 → 22}/json_utils.h +19 -8
  53. package/src/headers/{18 → 22}/memory_tracker-inl.h +16 -13
  54. package/src/headers/{14 → 22}/memory_tracker.h +13 -8
  55. package/src/headers/{16 → 22}/module_wrap.h +49 -19
  56. package/src/headers/22/ncrypto/ncrypto.h +752 -0
  57. package/src/headers/{18 → 22}/node.h +465 -68
  58. package/src/headers/{18 → 22}/node_api.h +66 -81
  59. package/src/headers/{18 → 22}/node_api_internals.h +8 -4
  60. package/src/headers/{18 → 22}/node_api_types.h +5 -0
  61. package/src/headers/22/node_binding.h +154 -0
  62. package/src/headers/{18 → 22}/node_blob.h +46 -78
  63. package/src/headers/{18 → 22}/node_bob-inl.h +1 -2
  64. package/src/headers/{18 → 22}/node_bob.h +2 -6
  65. package/src/headers/{18 → 22}/node_buffer.h +1 -1
  66. package/src/headers/22/node_builtins.h +220 -0
  67. package/src/headers/{18 → 22}/node_constants.h +3 -5
  68. package/src/headers/22/node_context_data.h +168 -0
  69. package/src/headers/22/node_contextify.h +199 -0
  70. package/src/headers/{16 → 22}/node_crypto.h +1 -2
  71. package/src/headers/22/node_dotenv.h +45 -0
  72. package/src/headers/{18 → 22}/node_errors.h +86 -27
  73. package/src/headers/22/node_exit_code.h +54 -0
  74. package/src/headers/22/node_external_reference.h +249 -0
  75. package/src/headers/{18 → 22}/node_file-inl.h +127 -30
  76. package/src/headers/{16 → 22}/node_file.h +122 -11
  77. package/src/headers/{18 → 22}/node_http2.h +28 -11
  78. package/src/headers/{16 → 22}/node_http2_state.h +34 -25
  79. package/src/headers/{18 → 22}/node_http_common-inl.h +2 -1
  80. package/src/headers/{18 → 22}/node_http_common.h +56 -55
  81. package/src/headers/{16 → 22}/node_i18n.h +5 -18
  82. package/src/headers/{18 → 22}/node_internals.h +121 -59
  83. package/src/headers/{18 → 22}/node_main_instance.h +4 -31
  84. package/src/headers/{18 → 22}/node_messaging.h +27 -10
  85. package/src/headers/{18 → 22}/node_metadata.h +23 -1
  86. package/src/headers/{18 → 22}/node_options-inl.h +24 -11
  87. package/src/headers/{18 → 22}/node_options.h +124 -39
  88. package/src/headers/{18 → 22}/node_perf.h +0 -2
  89. package/src/headers/{18 → 22}/node_perf_common.h +20 -9
  90. package/src/headers/{18 → 22}/node_platform.h +11 -5
  91. package/src/headers/{18 → 22}/node_process.h +26 -14
  92. package/src/headers/22/node_realm-inl.h +145 -0
  93. package/src/headers/22/node_realm.h +184 -0
  94. package/src/headers/{16 → 22}/node_report.h +13 -17
  95. package/src/headers/{16 → 22}/node_revert.h +3 -3
  96. package/src/headers/{16 → 22}/node_root_certs.h +902 -461
  97. package/src/headers/22/node_sea.h +64 -0
  98. package/src/headers/22/node_shadow_realm.h +46 -0
  99. package/src/headers/22/node_snapshot_builder.h +57 -0
  100. package/src/headers/22/node_snapshotable.h +174 -0
  101. package/src/headers/{18 → 22}/node_sockaddr.h +2 -2
  102. package/src/headers/{16 → 22}/node_stat_watcher.h +2 -1
  103. package/src/headers/22/node_threadsafe_cow-inl.h +54 -0
  104. package/src/headers/22/node_threadsafe_cow.h +105 -0
  105. package/src/headers/22/node_union_bytes.h +81 -0
  106. package/src/headers/22/node_url.h +96 -0
  107. package/src/headers/22/node_v8.h +77 -0
  108. package/src/headers/{14 → 22}/node_v8_platform-inl.h +17 -6
  109. package/src/headers/{18 → 22}/node_version.h +20 -8
  110. package/src/headers/22/node_wasi.h +185 -0
  111. package/src/headers/{14 → 22}/node_watchdog.h +2 -0
  112. package/src/headers/{18 → 22}/node_worker.h +7 -2
  113. package/src/headers/22/permission/child_process_permission.h +31 -0
  114. package/src/headers/22/permission/fs_permission.h +167 -0
  115. package/src/headers/22/permission/inspector_permission.h +31 -0
  116. package/src/headers/22/permission/permission.h +99 -0
  117. package/src/headers/22/permission/permission_base.h +60 -0
  118. package/src/headers/22/permission/wasi_permission.h +31 -0
  119. package/src/headers/22/permission/worker_permission.h +31 -0
  120. package/src/headers/{16 → 22}/req_wrap-inl.h +7 -6
  121. package/src/headers/{14 → 22}/spawn_sync.h +3 -3
  122. package/src/headers/{18 → 22}/stream_base-inl.h +0 -135
  123. package/src/headers/{18 → 22}/stream_base.h +35 -16
  124. package/src/headers/{18 → 22}/stream_pipe.h +3 -4
  125. package/src/headers/{16 → 22}/stream_wrap.h +2 -1
  126. package/src/headers/{18 → 22}/string_bytes.h +5 -14
  127. package/src/headers/{14 → 22}/string_decoder-inl.h +0 -6
  128. package/src/headers/{16 → 22}/string_decoder.h +0 -1
  129. package/src/headers/{18 → 22}/tcp_wrap.h +1 -1
  130. package/src/headers/{18 → 22}/threadpoolwork-inl.h +14 -1
  131. package/src/headers/22/timers.h +76 -0
  132. package/src/headers/{18 → 22}/tracing/trace_event.h +7 -5
  133. package/src/headers/{16 → 22}/udp_wrap.h +8 -5
  134. package/src/headers/22/undici_version.h +6 -0
  135. package/src/headers/{18 → 22}/util-inl.h +97 -127
  136. package/src/headers/{18 → 22}/util.h +293 -106
  137. package/src/headers/{18 → 22}/v8-fast-api-calls.h +103 -58
  138. package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
  139. package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
  140. package/dist/bindings/cws_darwin_x64_node83.node +0 -0
  141. package/dist/bindings/cws_darwin_x64_node93.node +0 -0
  142. package/dist/bindings/cws_linux_arm64_node83.node +0 -0
  143. package/dist/bindings/cws_linux_arm64_node93.node +0 -0
  144. package/dist/bindings/cws_linux_x64_node83.node +0 -0
  145. package/dist/bindings/cws_linux_x64_node93.node +0 -0
  146. package/src/headers/14/aliased_buffer.h +0 -263
  147. package/src/headers/14/allocated_buffer-inl.h +0 -110
  148. package/src/headers/14/allocated_buffer.h +0 -73
  149. package/src/headers/14/async_wrap-inl.h +0 -94
  150. package/src/headers/14/async_wrap.h +0 -230
  151. package/src/headers/14/base64.h +0 -183
  152. package/src/headers/14/base_object-inl.h +0 -371
  153. package/src/headers/14/base_object.h +0 -281
  154. package/src/headers/14/callback_queue-inl.h +0 -97
  155. package/src/headers/14/callback_queue.h +0 -78
  156. package/src/headers/14/debug_utils-inl.h +0 -223
  157. package/src/headers/14/debug_utils.h +0 -181
  158. package/src/headers/14/env.h +0 -1388
  159. package/src/headers/14/handle_wrap.h +0 -117
  160. package/src/headers/14/histogram-inl.h +0 -83
  161. package/src/headers/14/histogram.h +0 -98
  162. package/src/headers/14/inspector_agent.h +0 -149
  163. package/src/headers/14/inspector_profiler.h +0 -137
  164. package/src/headers/14/js_native_api.h +0 -544
  165. package/src/headers/14/js_native_api_types.h +0 -143
  166. package/src/headers/14/js_native_api_v8.h +0 -301
  167. package/src/headers/14/js_native_api_v8_internals.h +0 -38
  168. package/src/headers/14/json_utils.h +0 -161
  169. package/src/headers/14/memory_tracker-inl.h +0 -355
  170. package/src/headers/14/module_wrap.h +0 -99
  171. package/src/headers/14/node.h +0 -1032
  172. package/src/headers/14/node_api.h +0 -255
  173. package/src/headers/14/node_api_types.h +0 -44
  174. package/src/headers/14/node_binding.h +0 -99
  175. package/src/headers/14/node_buffer.h +0 -92
  176. package/src/headers/14/node_constants.h +0 -84
  177. package/src/headers/14/node_context_data.h +0 -44
  178. package/src/headers/14/node_contextify.h +0 -161
  179. package/src/headers/14/node_crypto.h +0 -865
  180. package/src/headers/14/node_crypto_bio.h +0 -195
  181. package/src/headers/14/node_crypto_clienthello-inl.h +0 -91
  182. package/src/headers/14/node_crypto_clienthello.h +0 -132
  183. package/src/headers/14/node_crypto_common.h +0 -138
  184. package/src/headers/14/node_crypto_groups.h +0 -415
  185. package/src/headers/14/node_dtrace.h +0 -86
  186. package/src/headers/14/node_errors.h +0 -214
  187. package/src/headers/14/node_file-inl.h +0 -306
  188. package/src/headers/14/node_file.h +0 -417
  189. package/src/headers/14/node_http2.h +0 -1191
  190. package/src/headers/14/node_http2_state.h +0 -149
  191. package/src/headers/14/node_http_common-inl.h +0 -194
  192. package/src/headers/14/node_http_common.h +0 -529
  193. package/src/headers/14/node_i18n.h +0 -144
  194. package/src/headers/14/node_internals.h +0 -405
  195. package/src/headers/14/node_main_instance.h +0 -96
  196. package/src/headers/14/node_mem.h +0 -45
  197. package/src/headers/14/node_messaging.h +0 -303
  198. package/src/headers/14/node_metadata.h +0 -109
  199. package/src/headers/14/node_mutex.h +0 -247
  200. package/src/headers/14/node_native_module.h +0 -101
  201. package/src/headers/14/node_native_module_env.h +0 -66
  202. package/src/headers/14/node_options-inl.h +0 -451
  203. package/src/headers/14/node_options.h +0 -481
  204. package/src/headers/14/node_perf.h +0 -181
  205. package/src/headers/14/node_perf_common.h +0 -97
  206. package/src/headers/14/node_platform.h +0 -189
  207. package/src/headers/14/node_process.h +0 -40
  208. package/src/headers/14/node_report.h +0 -47
  209. package/src/headers/14/node_revert.h +0 -72
  210. package/src/headers/14/node_root_certs.h +0 -3458
  211. package/src/headers/14/node_sockaddr-inl.h +0 -170
  212. package/src/headers/14/node_sockaddr.h +0 -123
  213. package/src/headers/14/node_stat_watcher.h +0 -70
  214. package/src/headers/14/node_union_bytes.h +0 -103
  215. package/src/headers/14/node_url.h +0 -188
  216. package/src/headers/14/node_version.h +0 -98
  217. package/src/headers/14/node_wasi.h +0 -108
  218. package/src/headers/14/node_win32_etw_provider-inl.h +0 -287
  219. package/src/headers/14/node_win32_etw_provider.h +0 -99
  220. package/src/headers/14/node_worker.h +0 -141
  221. package/src/headers/14/pipe_wrap.h +0 -78
  222. package/src/headers/14/req_wrap-inl.h +0 -170
  223. package/src/headers/14/req_wrap.h +0 -77
  224. package/src/headers/14/stream_base-inl.h +0 -275
  225. package/src/headers/14/stream_base.h +0 -434
  226. package/src/headers/14/stream_pipe.h +0 -73
  227. package/src/headers/14/stream_wrap.h +0 -130
  228. package/src/headers/14/string_bytes.h +0 -129
  229. package/src/headers/14/string_decoder.h +0 -50
  230. package/src/headers/14/string_search.h +0 -638
  231. package/src/headers/14/tcp_wrap.h +0 -101
  232. package/src/headers/14/threadpoolwork-inl.h +0 -57
  233. package/src/headers/14/tls_wrap.h +0 -222
  234. package/src/headers/14/tracing/agent.h +0 -195
  235. package/src/headers/14/tracing/node_trace_buffer.h +0 -83
  236. package/src/headers/14/tracing/node_trace_writer.h +0 -75
  237. package/src/headers/14/tracing/trace_event.h +0 -720
  238. package/src/headers/14/tracing/traced_value.h +0 -70
  239. package/src/headers/14/tty_wrap.h +0 -64
  240. package/src/headers/14/udp_wrap.h +0 -227
  241. package/src/headers/14/util-inl.h +0 -566
  242. package/src/headers/14/util.h +0 -804
  243. package/src/headers/14/v8abbr.h +0 -124
  244. package/src/headers/16/aliased_buffer.h +0 -315
  245. package/src/headers/16/aliased_struct-inl.h +0 -54
  246. package/src/headers/16/aliased_struct.h +0 -63
  247. package/src/headers/16/allocated_buffer-inl.h +0 -110
  248. package/src/headers/16/allocated_buffer.h +0 -73
  249. package/src/headers/16/async_wrap-inl.h +0 -94
  250. package/src/headers/16/async_wrap.h +0 -246
  251. package/src/headers/16/base64-inl.h +0 -189
  252. package/src/headers/16/base64.h +0 -69
  253. package/src/headers/16/base_object.h +0 -294
  254. package/src/headers/16/connect_wrap.h +0 -26
  255. package/src/headers/16/connection_wrap.h +0 -30
  256. package/src/headers/16/crypto/crypto_aes.h +0 -89
  257. package/src/headers/16/crypto/crypto_bio.h +0 -194
  258. package/src/headers/16/crypto/crypto_cipher.h +0 -286
  259. package/src/headers/16/crypto/crypto_clienthello-inl.h +0 -90
  260. package/src/headers/16/crypto/crypto_clienthello.h +0 -131
  261. package/src/headers/16/crypto/crypto_common.h +0 -187
  262. package/src/headers/16/crypto/crypto_context.h +0 -147
  263. package/src/headers/16/crypto/crypto_dh.h +0 -157
  264. package/src/headers/16/crypto/crypto_dsa.h +0 -76
  265. package/src/headers/16/crypto/crypto_ec.h +0 -169
  266. package/src/headers/16/crypto/crypto_groups.h +0 -415
  267. package/src/headers/16/crypto/crypto_hash.h +0 -89
  268. package/src/headers/16/crypto/crypto_hkdf.h +0 -66
  269. package/src/headers/16/crypto/crypto_hmac.h +0 -94
  270. package/src/headers/16/crypto/crypto_keygen.h +0 -301
  271. package/src/headers/16/crypto/crypto_keys.h +0 -412
  272. package/src/headers/16/crypto/crypto_pbkdf2.h +0 -76
  273. package/src/headers/16/crypto/crypto_random.h +0 -130
  274. package/src/headers/16/crypto/crypto_rsa.h +0 -141
  275. package/src/headers/16/crypto/crypto_scrypt.h +0 -87
  276. package/src/headers/16/crypto/crypto_sig.h +0 -167
  277. package/src/headers/16/crypto/crypto_spkac.h +0 -20
  278. package/src/headers/16/crypto/crypto_timing.h +0 -20
  279. package/src/headers/16/crypto/crypto_tls.h +0 -292
  280. package/src/headers/16/crypto/crypto_util.h +0 -736
  281. package/src/headers/16/crypto/crypto_x509.h +0 -141
  282. package/src/headers/16/debug_utils.h +0 -184
  283. package/src/headers/16/diagnosticfilename-inl.h +0 -33
  284. package/src/headers/16/env-inl.h +0 -1277
  285. package/src/headers/16/env.h +0 -1629
  286. package/src/headers/16/handle_wrap.h +0 -121
  287. package/src/headers/16/histogram-inl.h +0 -88
  288. package/src/headers/16/histogram.h +0 -216
  289. package/src/headers/16/inspector_io.h +0 -78
  290. package/src/headers/16/inspector_socket.h +0 -60
  291. package/src/headers/16/inspector_socket_server.h +0 -110
  292. package/src/headers/16/js_native_api.h +0 -561
  293. package/src/headers/16/js_native_api_types.h +0 -160
  294. package/src/headers/16/js_native_api_v8.h +0 -451
  295. package/src/headers/16/js_native_api_v8_internals.h +0 -39
  296. package/src/headers/16/js_stream.h +0 -52
  297. package/src/headers/16/memory_tracker-inl.h +0 -356
  298. package/src/headers/16/memory_tracker.h +0 -284
  299. package/src/headers/16/node.d +0 -315
  300. package/src/headers/16/node.h +0 -1132
  301. package/src/headers/16/node.stp +0 -146
  302. package/src/headers/16/node_api.h +0 -275
  303. package/src/headers/16/node_api_internals.h +0 -30
  304. package/src/headers/16/node_api_types.h +0 -50
  305. package/src/headers/16/node_binding.h +0 -99
  306. package/src/headers/16/node_blob.h +0 -191
  307. package/src/headers/16/node_bob-inl.h +0 -37
  308. package/src/headers/16/node_bob.h +0 -111
  309. package/src/headers/16/node_buffer.h +0 -92
  310. package/src/headers/16/node_constants.h +0 -84
  311. package/src/headers/16/node_context_data.h +0 -44
  312. package/src/headers/16/node_contextify.h +0 -196
  313. package/src/headers/16/node_dir.h +0 -52
  314. package/src/headers/16/node_dtrace.h +0 -86
  315. package/src/headers/16/node_errors.h +0 -277
  316. package/src/headers/16/node_external_reference.h +0 -129
  317. package/src/headers/16/node_file-inl.h +0 -306
  318. package/src/headers/16/node_http2.h +0 -1140
  319. package/src/headers/16/node_http_common-inl.h +0 -200
  320. package/src/headers/16/node_http_common.h +0 -531
  321. package/src/headers/16/node_internals.h +0 -421
  322. package/src/headers/16/node_main_instance.h +0 -103
  323. package/src/headers/16/node_mem-inl.h +0 -112
  324. package/src/headers/16/node_messaging.h +0 -373
  325. package/src/headers/16/node_metadata.h +0 -122
  326. package/src/headers/16/node_native_module.h +0 -101
  327. package/src/headers/16/node_native_module_env.h +0 -68
  328. package/src/headers/16/node_object_wrap.h +0 -132
  329. package/src/headers/16/node_options-inl.h +0 -477
  330. package/src/headers/16/node_options.h +0 -494
  331. package/src/headers/16/node_perf.h +0 -185
  332. package/src/headers/16/node_perf_common.h +0 -89
  333. package/src/headers/16/node_platform.h +0 -192
  334. package/src/headers/16/node_process.h +0 -43
  335. package/src/headers/16/node_provider.d +0 -80
  336. package/src/headers/16/node_snapshotable.h +0 -137
  337. package/src/headers/16/node_sockaddr-inl.h +0 -266
  338. package/src/headers/16/node_sockaddr.h +0 -405
  339. package/src/headers/16/node_union_bytes.h +0 -103
  340. package/src/headers/16/node_url.h +0 -205
  341. package/src/headers/16/node_v8.h +0 -41
  342. package/src/headers/16/node_v8_platform-inl.h +0 -194
  343. package/src/headers/16/node_version.h +0 -98
  344. package/src/headers/16/node_wasi.h +0 -108
  345. package/src/headers/16/node_watchdog.h +0 -152
  346. package/src/headers/16/node_win32_etw_provider-inl.h +0 -288
  347. package/src/headers/16/node_win32_etw_provider.h +0 -99
  348. package/src/headers/16/node_worker.h +0 -145
  349. package/src/headers/16/req_wrap.h +0 -77
  350. package/src/headers/16/spawn_sync.h +0 -242
  351. package/src/headers/16/stream_base-inl.h +0 -303
  352. package/src/headers/16/stream_base.h +0 -454
  353. package/src/headers/16/stream_pipe.h +0 -73
  354. package/src/headers/16/string_bytes.h +0 -122
  355. package/src/headers/16/string_decoder-inl.h +0 -37
  356. package/src/headers/16/string_search.h +0 -638
  357. package/src/headers/16/tcp_wrap.h +0 -103
  358. package/src/headers/16/threadpoolwork-inl.h +0 -57
  359. package/src/headers/16/timer_wrap.h +0 -84
  360. package/src/headers/16/tracing/agent.h +0 -195
  361. package/src/headers/16/tracing/node_trace_buffer.h +0 -83
  362. package/src/headers/16/tracing/node_trace_writer.h +0 -75
  363. package/src/headers/16/tracing/trace_event.h +0 -720
  364. package/src/headers/16/tracing/trace_event_common.h +0 -1109
  365. package/src/headers/16/tracing/traced_value.h +0 -70
  366. package/src/headers/16/tty_wrap.h +0 -66
  367. package/src/headers/16/util-inl.h +0 -575
  368. package/src/headers/16/util.h +0 -824
  369. package/src/headers/16/v8abbr.h +0 -123
  370. package/src/headers/16/v8ustack.d +0 -695
  371. package/src/headers/18/aliased_buffer.h +0 -315
  372. package/src/headers/18/aliased_struct-inl.h +0 -54
  373. package/src/headers/18/aliased_struct.h +0 -63
  374. package/src/headers/18/base64-inl.h +0 -189
  375. package/src/headers/18/base64.h +0 -69
  376. package/src/headers/18/base_object-inl.h +0 -374
  377. package/src/headers/18/callback_queue-inl.h +0 -97
  378. package/src/headers/18/callback_queue.h +0 -78
  379. package/src/headers/18/cares_wrap.h +0 -523
  380. package/src/headers/18/connect_wrap.h +0 -26
  381. package/src/headers/18/connection_wrap.h +0 -30
  382. package/src/headers/18/crypto/crypto_aes.h +0 -89
  383. package/src/headers/18/crypto/crypto_bio.h +0 -194
  384. package/src/headers/18/crypto/crypto_cipher.h +0 -291
  385. package/src/headers/18/crypto/crypto_clienthello-inl.h +0 -90
  386. package/src/headers/18/crypto/crypto_common.h +0 -151
  387. package/src/headers/18/crypto/crypto_dh.h +0 -156
  388. package/src/headers/18/crypto/crypto_dsa.h +0 -77
  389. package/src/headers/18/crypto/crypto_ec.h +0 -170
  390. package/src/headers/18/crypto/crypto_groups.h +0 -415
  391. package/src/headers/18/crypto/crypto_hash.h +0 -89
  392. package/src/headers/18/crypto/crypto_hkdf.h +0 -65
  393. package/src/headers/18/crypto/crypto_hmac.h +0 -94
  394. package/src/headers/18/crypto/crypto_keygen.h +0 -305
  395. package/src/headers/18/crypto/crypto_pbkdf2.h +0 -76
  396. package/src/headers/18/crypto/crypto_random.h +0 -130
  397. package/src/headers/18/crypto/crypto_rsa.h +0 -141
  398. package/src/headers/18/crypto/crypto_scrypt.h +0 -87
  399. package/src/headers/18/crypto/crypto_sig.h +0 -168
  400. package/src/headers/18/crypto/crypto_spkac.h +0 -21
  401. package/src/headers/18/crypto/crypto_timing.h +0 -20
  402. package/src/headers/18/crypto/crypto_x509.h +0 -143
  403. package/src/headers/18/debug_utils-inl.h +0 -223
  404. package/src/headers/18/diagnosticfilename-inl.h +0 -33
  405. package/src/headers/18/env-inl.h +0 -1308
  406. package/src/headers/18/env.h +0 -1667
  407. package/src/headers/18/inspector_agent.h +0 -144
  408. package/src/headers/18/inspector_io.h +0 -78
  409. package/src/headers/18/inspector_profiler.h +0 -149
  410. package/src/headers/18/inspector_socket.h +0 -60
  411. package/src/headers/18/inspector_socket_server.h +0 -110
  412. package/src/headers/18/js_stream.h +0 -52
  413. package/src/headers/18/json_utils.h +0 -161
  414. package/src/headers/18/memory_tracker.h +0 -284
  415. package/src/headers/18/module_wrap.h +0 -116
  416. package/src/headers/18/node_binding.h +0 -99
  417. package/src/headers/18/node_context_data.h +0 -44
  418. package/src/headers/18/node_contextify.h +0 -196
  419. package/src/headers/18/node_crypto.h +0 -57
  420. package/src/headers/18/node_dir.h +0 -52
  421. package/src/headers/18/node_dtrace.h +0 -86
  422. package/src/headers/18/node_external_reference.h +0 -145
  423. package/src/headers/18/node_file.h +0 -426
  424. package/src/headers/18/node_http2_state.h +0 -149
  425. package/src/headers/18/node_i18n.h +0 -145
  426. package/src/headers/18/node_mem-inl.h +0 -112
  427. package/src/headers/18/node_mem.h +0 -45
  428. package/src/headers/18/node_mutex.h +0 -323
  429. package/src/headers/18/node_native_module.h +0 -109
  430. package/src/headers/18/node_native_module_env.h +0 -71
  431. package/src/headers/18/node_object_wrap.h +0 -132
  432. package/src/headers/18/node_process-inl.h +0 -26
  433. package/src/headers/18/node_report.h +0 -47
  434. package/src/headers/18/node_revert.h +0 -82
  435. package/src/headers/18/node_root_certs.h +0 -3246
  436. package/src/headers/18/node_snapshot_builder.h +0 -43
  437. package/src/headers/18/node_snapshotable.h +0 -130
  438. package/src/headers/18/node_stat_watcher.h +0 -72
  439. package/src/headers/18/node_union_bytes.h +0 -103
  440. package/src/headers/18/node_url.h +0 -205
  441. package/src/headers/18/node_v8.h +0 -41
  442. package/src/headers/18/node_v8_platform-inl.h +0 -194
  443. package/src/headers/18/node_wasi.h +0 -108
  444. package/src/headers/18/node_watchdog.h +0 -152
  445. package/src/headers/18/node_win32_etw_provider-inl.h +0 -288
  446. package/src/headers/18/node_win32_etw_provider.h +0 -99
  447. package/src/headers/18/pipe_wrap.h +0 -80
  448. package/src/headers/18/req_wrap-inl.h +0 -170
  449. package/src/headers/18/spawn_sync.h +0 -242
  450. package/src/headers/18/stream_wrap.h +0 -133
  451. package/src/headers/18/string_decoder-inl.h +0 -37
  452. package/src/headers/18/string_decoder.h +0 -50
  453. package/src/headers/18/string_search.h +0 -638
  454. package/src/headers/18/tracing/node_trace_buffer.h +0 -83
  455. package/src/headers/18/tracing/node_trace_writer.h +0 -75
  456. package/src/headers/18/tracing/trace_event_common.h +0 -1109
  457. package/src/headers/18/tracing/traced_value.h +0 -70
  458. package/src/headers/18/udp_wrap.h +0 -227
  459. package/src/headers/18/v8abbr.h +0 -123
  460. /package/src/headers/{14 → 22}/aliased_struct-inl.h +0 -0
  461. /package/src/headers/{14 → 22}/aliased_struct.h +0 -0
  462. /package/src/headers/{16 → 22}/callback_queue-inl.h +0 -0
  463. /package/src/headers/{14 → 22}/connect_wrap.h +0 -0
  464. /package/src/headers/{14 → 22}/connection_wrap.h +0 -0
  465. /package/src/headers/{14 → 22}/diagnosticfilename-inl.h +0 -0
  466. /package/src/headers/{18 → 22}/histogram-inl.h +0 -0
  467. /package/src/headers/{14 → 22}/inspector_io.h +0 -0
  468. /package/src/headers/{14 → 22}/inspector_socket.h +0 -0
  469. /package/src/headers/{14 → 22}/inspector_socket_server.h +0 -0
  470. /package/src/headers/{14 → 22}/js_stream.h +0 -0
  471. /package/src/headers/{14 → 22}/node_dir.h +0 -0
  472. /package/src/headers/{14 → 22}/node_mem-inl.h +0 -0
  473. /package/src/headers/{16 → 22}/node_mem.h +0 -0
  474. /package/src/headers/{16 → 22}/node_mutex.h +0 -0
  475. /package/src/headers/{14 → 22}/node_object_wrap.h +0 -0
  476. /package/src/headers/{16 → 22}/node_process-inl.h +0 -0
  477. /package/src/headers/{18 → 22}/node_sockaddr-inl.h +0 -0
  478. /package/src/headers/{18 → 22}/node_wasm_web_api.h +0 -0
  479. /package/src/headers/{16 → 22}/pipe_wrap.h +0 -0
  480. /package/src/headers/{18 → 22}/req_wrap.h +0 -0
  481. /package/src/headers/{18 → 22}/timer_wrap-inl.h +0 -0
  482. /package/src/headers/{18 → 22}/timer_wrap.h +0 -0
  483. /package/src/headers/{18 → 22}/tracing/agent.h +0 -0
  484. /package/src/headers/{14 → 22}/tracing/trace_event_common.h +0 -0
  485. /package/src/headers/{18 → 22}/tty_wrap.h +0 -0
@@ -1,1191 +0,0 @@
1
- #ifndef SRC_NODE_HTTP2_H_
2
- #define SRC_NODE_HTTP2_H_
3
-
4
- #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
-
6
- // FIXME(joyeecheung): nghttp2.h needs stdint.h to compile on Windows
7
- #include <cstdint>
8
- #include "nghttp2/nghttp2.h"
9
-
10
- #include "allocated_buffer.h"
11
- #include "aliased_struct.h"
12
- #include "node_http2_state.h"
13
- #include "node_http_common.h"
14
- #include "node_mem.h"
15
- #include "node_perf.h"
16
- #include "stream_base.h"
17
- #include "string_bytes.h"
18
-
19
- #include <algorithm>
20
- #include <queue>
21
-
22
- namespace node {
23
- namespace http2 {
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
-
29
- // We strictly limit the number of outstanding unacknowledged PINGS a user
30
- // may send in order to prevent abuse. The current default cap is 10. The
31
- // user may set a different limit using a per Http2Session configuration
32
- // option.
33
- constexpr size_t kDefaultMaxPings = 10;
34
-
35
- // Also strictly limit the number of outstanding SETTINGS frames a user sends
36
- constexpr size_t kDefaultMaxSettings = 10;
37
-
38
- // Default maximum total memory cap for Http2Session.
39
- constexpr uint64_t kDefaultMaxSessionMemory = 10000000;
40
-
41
- // These are the standard HTTP/2 defaults as specified by the RFC
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
- };
98
-
99
- template <typename T, void(*fn)(T*)>
100
- struct Nghttp2Deleter {
101
- void operator()(T* ptr) const noexcept { fn(ptr); }
102
- };
103
-
104
- using Nghttp2OptionPointer =
105
- std::unique_ptr<nghttp2_option,
106
- Nghttp2Deleter<nghttp2_option, nghttp2_option_del>>;
107
-
108
- using Nghttp2SessionPointer =
109
- std::unique_ptr<nghttp2_session,
110
- Nghttp2Deleter<nghttp2_session, nghttp2_session_del>>;
111
-
112
- using Nghttp2SessionCallbacksPointer =
113
- std::unique_ptr<nghttp2_session_callbacks,
114
- Nghttp2Deleter<nghttp2_session_callbacks,
115
- nghttp2_session_callbacks_del>>;
116
-
117
- struct Http2HeadersTraits {
118
- typedef nghttp2_nv nv_t;
119
- static const uint8_t kNoneFlag = NGHTTP2_NV_FLAG_NONE;
120
- };
121
-
122
- struct Http2RcBufferPointerTraits {
123
- typedef nghttp2_rcbuf rcbuf_t;
124
- typedef nghttp2_vec vector_t;
125
-
126
- static void inc(rcbuf_t* buf) {
127
- CHECK_NOT_NULL(buf);
128
- nghttp2_rcbuf_incref(buf);
129
- }
130
- static void dec(rcbuf_t* buf) {
131
- CHECK_NOT_NULL(buf);
132
- nghttp2_rcbuf_decref(buf);
133
- }
134
- static vector_t get_vec(rcbuf_t* buf) {
135
- CHECK_NOT_NULL(buf);
136
- return nghttp2_rcbuf_get_buf(buf);
137
- }
138
- static bool is_static(const rcbuf_t* buf) {
139
- CHECK_NOT_NULL(buf);
140
- return nghttp2_rcbuf_is_static(buf);
141
- }
142
- };
143
-
144
- using Http2Headers = NgHeaders<Http2HeadersTraits>;
145
- using Http2RcBufferPointer = NgRcBufPointer<Http2RcBufferPointerTraits>;
146
-
147
- struct NgHttp2StreamWrite : public MemoryRetainer {
148
- WriteWrap* req_wrap = nullptr;
149
- uv_buf_t buf;
150
-
151
- inline explicit NgHttp2StreamWrite(uv_buf_t buf_) : buf(buf_) {}
152
- inline NgHttp2StreamWrite(WriteWrap* req, uv_buf_t buf_) :
153
- req_wrap(req), buf(buf_) {}
154
-
155
- void MemoryInfo(MemoryTracker* tracker) const override;
156
- SET_MEMORY_INFO_NAME(NgHttp2StreamWrite)
157
- SET_SELF_SIZE(NgHttp2StreamWrite)
158
- };
159
-
160
- typedef uint32_t(*get_setting)(nghttp2_session* session,
161
- nghttp2_settings_id id);
162
-
163
- class Http2Ping;
164
- class Http2Session;
165
- class Http2Settings;
166
- class Http2Stream;
167
- class Origins;
168
-
169
- // This scope should be present when any call into nghttp2 that may schedule
170
- // data to be written to the underlying transport is made, and schedules
171
- // such a write automatically once the scope is exited.
172
- class Http2Scope {
173
- public:
174
- explicit Http2Scope(Http2Stream* stream);
175
- explicit Http2Scope(Http2Session* session);
176
- ~Http2Scope();
177
-
178
- private:
179
- BaseObjectPtr<Http2Session> session_;
180
- };
181
-
182
- // The Http2Options class is used to parse the options object passed in to
183
- // a Http2Session object and convert those into an appropriate nghttp2_option
184
- // struct. This is the primary mechanism by which the Http2Session object is
185
- // configured.
186
- class Http2Options {
187
- public:
188
- Http2Options(Http2State* http2_state,
189
- SessionType type);
190
-
191
- ~Http2Options() = default;
192
-
193
- nghttp2_option* operator*() const {
194
- return options_.get();
195
- }
196
-
197
- void set_max_header_pairs(uint32_t max) {
198
- max_header_pairs_ = max;
199
- }
200
-
201
- uint32_t max_header_pairs() const {
202
- return max_header_pairs_;
203
- }
204
-
205
- void set_padding_strategy(PaddingStrategy val) {
206
- padding_strategy_ = val;
207
- }
208
-
209
- PaddingStrategy padding_strategy() const {
210
- return padding_strategy_;
211
- }
212
-
213
- void set_max_outstanding_pings(size_t max) {
214
- max_outstanding_pings_ = max;
215
- }
216
-
217
- size_t max_outstanding_pings() const {
218
- return max_outstanding_pings_;
219
- }
220
-
221
- void set_max_outstanding_settings(size_t max) {
222
- max_outstanding_settings_ = max;
223
- }
224
-
225
- size_t max_outstanding_settings() const {
226
- return max_outstanding_settings_;
227
- }
228
-
229
- void set_max_session_memory(uint64_t max) {
230
- max_session_memory_ = max;
231
- }
232
-
233
- uint64_t max_session_memory() const {
234
- return max_session_memory_;
235
- }
236
-
237
- private:
238
- Nghttp2OptionPointer options_;
239
- uint64_t max_session_memory_ = kDefaultMaxSessionMemory;
240
- uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
241
- PaddingStrategy padding_strategy_ = PADDING_STRATEGY_NONE;
242
- size_t max_outstanding_pings_ = kDefaultMaxPings;
243
- size_t max_outstanding_settings_ = kDefaultMaxSettings;
244
- };
245
-
246
- struct Http2Priority : public nghttp2_priority_spec {
247
- Http2Priority(Environment* env,
248
- v8::Local<v8::Value> parent,
249
- v8::Local<v8::Value> weight,
250
- v8::Local<v8::Value> exclusive);
251
- };
252
-
253
- class Http2StreamListener : public StreamListener {
254
- public:
255
- uv_buf_t OnStreamAlloc(size_t suggested_size) override;
256
- void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
257
- };
258
-
259
- struct Http2HeaderTraits {
260
- typedef Http2RcBufferPointer rcbufferpointer_t;
261
- typedef Http2Session allocator_t;
262
-
263
- // HTTP/2 does not support identifying header names by token id.
264
- // HTTP/3 will, however, so we prepare for that now.
265
- static const char* ToHttpHeaderName(int32_t token) { return nullptr; }
266
- };
267
-
268
- using Http2Header = NgHeader<Http2HeaderTraits>;
269
-
270
- class Http2Stream : public AsyncWrap,
271
- public StreamBase {
272
- public:
273
- static Http2Stream* New(
274
- Http2Session* session,
275
- int32_t id,
276
- nghttp2_headers_category category = NGHTTP2_HCAT_HEADERS,
277
- int options = 0);
278
- ~Http2Stream() override;
279
-
280
- nghttp2_stream* operator*() const;
281
-
282
- nghttp2_stream* stream() const;
283
-
284
- Http2Session* session() { return session_.get(); }
285
- const Http2Session* session() const { return session_.get(); }
286
-
287
- // Required for StreamBase
288
- int ReadStart() override;
289
-
290
- // Required for StreamBase
291
- int ReadStop() override;
292
-
293
- // Required for StreamBase
294
- ShutdownWrap* CreateShutdownWrap(v8::Local<v8::Object> object) override;
295
- int DoShutdown(ShutdownWrap* req_wrap) override;
296
-
297
- bool HasWantsWrite() const override { return true; }
298
-
299
- // Initiate a response on this stream.
300
- int SubmitResponse(const Http2Headers& headers, int options);
301
-
302
- // Submit informational headers for this stream
303
- int SubmitInfo(const Http2Headers& headers);
304
-
305
- // Submit trailing headers for this stream
306
- int SubmitTrailers(const Http2Headers& headers);
307
- void OnTrailers();
308
-
309
- // Submit a PRIORITY frame for this stream
310
- int SubmitPriority(const Http2Priority& priority, bool silent = false);
311
-
312
- // Submits an RST_STREAM frame using the given code
313
- void SubmitRstStream(const uint32_t code);
314
-
315
- void FlushRstStream();
316
-
317
- // Submits a PUSH_PROMISE frame with this stream as the parent.
318
- Http2Stream* SubmitPushPromise(
319
- const Http2Headers& headers,
320
- int32_t* ret,
321
- int options = 0);
322
-
323
-
324
- void Close(int32_t code);
325
-
326
- // Destroy this stream instance and free all held memory.
327
- void Destroy();
328
-
329
- bool is_destroyed() const {
330
- return flags_ & kStreamStateDestroyed;
331
- }
332
-
333
- bool is_writable() const {
334
- return !(flags_ & kStreamStateShut);
335
- }
336
-
337
- bool is_paused() const {
338
- return flags_ & kStreamStateReadPaused;
339
- }
340
-
341
- bool is_closed() const {
342
- return flags_ & kStreamStateClosed;
343
- }
344
-
345
- bool has_trailers() const {
346
- return flags_ & kStreamStateTrailers;
347
- }
348
-
349
- void set_has_trailers(bool on = true) {
350
- if (on)
351
- flags_ |= kStreamStateTrailers;
352
- else
353
- flags_ &= ~kStreamStateTrailers;
354
- }
355
-
356
- void set_closed() {
357
- flags_ |= kStreamStateClosed;
358
- }
359
-
360
- void set_destroyed() {
361
- flags_ |= kStreamStateDestroyed;
362
- }
363
-
364
- void set_not_writable() {
365
- flags_ |= kStreamStateShut;
366
- }
367
-
368
- void set_reading(bool on = true) {
369
- if (on) {
370
- flags_ |= kStreamStateReadStart;
371
- set_paused(false);
372
- } else {}
373
- }
374
-
375
- void set_paused(bool on = true) {
376
- if (on)
377
- flags_ |= kStreamStateReadPaused;
378
- else
379
- flags_ &= ~kStreamStateReadPaused;
380
- }
381
-
382
- // Returns true if this stream is in the reading state, which occurs when
383
- // the kStreamStateReadStart flag has been set and the
384
- // kStreamStateReadPaused flag is *not* set.
385
- bool is_reading() const {
386
- return flags_ & kStreamStateReadStart && !is_paused();
387
- }
388
-
389
- // Returns the RST_STREAM code used to close this stream
390
- int32_t code() const { return code_; }
391
-
392
- // Returns the stream identifier for this stream
393
- int32_t id() const { return id_; }
394
-
395
- void IncrementAvailableOutboundLength(size_t amount);
396
- void DecrementAvailableOutboundLength(size_t amount);
397
-
398
- bool AddHeader(nghttp2_rcbuf* name, nghttp2_rcbuf* value, uint8_t flags);
399
-
400
- template <typename Fn>
401
- void TransferHeaders(Fn&& fn) {
402
- size_t i = 0;
403
- for (const auto& header : current_headers_ )
404
- fn(header, i++);
405
- current_headers_.clear();
406
- }
407
-
408
- size_t headers_count() const {
409
- return current_headers_.size();
410
- }
411
-
412
- nghttp2_headers_category headers_category() const {
413
- return current_headers_category_;
414
- }
415
-
416
- void StartHeaders(nghttp2_headers_category category);
417
-
418
- // Required for StreamBase
419
- bool IsAlive() override {
420
- return true;
421
- }
422
-
423
- // Required for StreamBase
424
- bool IsClosing() override {
425
- return false;
426
- }
427
-
428
- AsyncWrap* GetAsyncWrap() override { return this; }
429
-
430
- int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
431
- uv_stream_t* send_handle) override;
432
-
433
- void MemoryInfo(MemoryTracker* tracker) const override;
434
- SET_MEMORY_INFO_NAME(Http2Stream)
435
- SET_SELF_SIZE(Http2Stream)
436
-
437
- std::string diagnostic_name() const override;
438
-
439
- // JavaScript API
440
- static void GetID(const v8::FunctionCallbackInfo<v8::Value>& args);
441
- static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
442
- static void Priority(const v8::FunctionCallbackInfo<v8::Value>& args);
443
- static void PushPromise(const v8::FunctionCallbackInfo<v8::Value>& args);
444
- static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
445
- static void Info(const v8::FunctionCallbackInfo<v8::Value>& args);
446
- static void Trailers(const v8::FunctionCallbackInfo<v8::Value>& args);
447
- static void Respond(const v8::FunctionCallbackInfo<v8::Value>& args);
448
- static void RstStream(const v8::FunctionCallbackInfo<v8::Value>& args);
449
-
450
- class Provider;
451
-
452
- struct Statistics {
453
- uint64_t start_time;
454
- uint64_t end_time;
455
- uint64_t first_header; // Time first header was received
456
- uint64_t first_byte; // Time first DATA frame byte was received
457
- uint64_t first_byte_sent; // Time first DATA frame byte was sent
458
- uint64_t sent_bytes;
459
- uint64_t received_bytes;
460
- };
461
-
462
- Statistics statistics_ = {};
463
-
464
- private:
465
- Http2Stream(Http2Session* session,
466
- v8::Local<v8::Object> obj,
467
- int32_t id,
468
- nghttp2_headers_category category,
469
- int options);
470
-
471
- void EmitStatistics();
472
-
473
- BaseObjectWeakPtr<Http2Session> session_; // The Parent HTTP/2 Session
474
- int32_t id_ = 0; // The Stream Identifier
475
- int32_t code_ = NGHTTP2_NO_ERROR; // The RST_STREAM code (if any)
476
- int flags_ = kStreamStateNone; // Internal state flags
477
-
478
- uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
479
- uint32_t max_header_length_ = DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE;
480
-
481
- // The Current Headers block... As headers are received for this stream,
482
- // they are temporarily stored here until the OnFrameReceived is called
483
- // signalling the end of the HEADERS frame
484
- nghttp2_headers_category current_headers_category_ = NGHTTP2_HCAT_HEADERS;
485
- uint32_t current_headers_length_ = 0; // total number of octets
486
- std::vector<Http2Header> current_headers_;
487
-
488
- // This keeps track of the amount of data read from the socket while the
489
- // socket was in paused mode. When `ReadStart()` is called (and not before
490
- // then), we tell nghttp2 that we consumed that data to get proper
491
- // backpressure handling.
492
- size_t inbound_consumed_data_while_paused_ = 0;
493
-
494
- // Outbound Data... This is the data written by the JS layer that is
495
- // waiting to be written out to the socket.
496
- std::queue<NgHttp2StreamWrite> queue_;
497
- size_t available_outbound_length_ = 0;
498
-
499
- Http2StreamListener stream_listener_;
500
-
501
- friend class Http2Session;
502
- };
503
-
504
- class Http2Stream::Provider {
505
- public:
506
- Provider(Http2Stream* stream, int options);
507
- explicit Provider(int options);
508
- virtual ~Provider();
509
-
510
- nghttp2_data_provider* operator*() {
511
- return !empty_ ? &provider_ : nullptr;
512
- }
513
-
514
- class FD;
515
- class Stream;
516
- protected:
517
- nghttp2_data_provider provider_;
518
-
519
- private:
520
- bool empty_ = false;
521
- };
522
-
523
- class Http2Stream::Provider::Stream : public Http2Stream::Provider {
524
- public:
525
- Stream(Http2Stream* stream, int options);
526
- explicit Stream(int options);
527
-
528
- static ssize_t OnRead(nghttp2_session* session,
529
- int32_t id,
530
- uint8_t* buf,
531
- size_t length,
532
- uint32_t* flags,
533
- nghttp2_data_source* source,
534
- void* user_data);
535
- };
536
-
537
- struct SessionJSFields {
538
- uint8_t bitfield;
539
- uint8_t priority_listener_count;
540
- uint8_t frame_error_listener_count;
541
- uint32_t max_invalid_frames = 1000;
542
- uint32_t max_rejected_streams = 100;
543
- };
544
-
545
- // Indices for js_fields_, which serves as a way to communicate data with JS
546
- // land fast. In particular, we store information about the number/presence
547
- // of certain event listeners in JS, and skip calls from C++ into JS if they
548
- // are missing.
549
- enum SessionUint8Fields {
550
- kBitfield = offsetof(SessionJSFields, bitfield), // See below
551
- kSessionPriorityListenerCount =
552
- offsetof(SessionJSFields, priority_listener_count),
553
- kSessionFrameErrorListenerCount =
554
- offsetof(SessionJSFields, frame_error_listener_count),
555
- kSessionMaxInvalidFrames = offsetof(SessionJSFields, max_invalid_frames),
556
- kSessionMaxRejectedStreams = offsetof(SessionJSFields, max_rejected_streams),
557
- kSessionUint8FieldCount = sizeof(SessionJSFields)
558
- };
559
-
560
- enum SessionBitfieldFlags {
561
- kSessionHasRemoteSettingsListeners,
562
- kSessionRemoteSettingsIsUpToDate,
563
- kSessionHasPingListeners,
564
- kSessionHasAltsvcListeners
565
- };
566
-
567
- class Http2Session : public AsyncWrap,
568
- public StreamListener,
569
- public mem::NgLibMemoryManager<Http2Session, nghttp2_mem> {
570
- public:
571
- Http2Session(Http2State* http2_state,
572
- v8::Local<v8::Object> wrap,
573
- SessionType type = NGHTTP2_SESSION_SERVER);
574
- ~Http2Session() override;
575
-
576
- StreamBase* underlying_stream() {
577
- return static_cast<StreamBase*>(stream_);
578
- }
579
-
580
- void Close(uint32_t code = NGHTTP2_NO_ERROR,
581
- bool socket_closed = false);
582
-
583
- void Consume(v8::Local<v8::Object> stream);
584
-
585
- void Goaway(uint32_t code, int32_t lastStreamID,
586
- const uint8_t* data, size_t len);
587
-
588
- void AltSvc(int32_t id,
589
- uint8_t* origin,
590
- size_t origin_len,
591
- uint8_t* value,
592
- size_t value_len);
593
-
594
- void Origin(const Origins& origins);
595
-
596
- uint8_t SendPendingData();
597
-
598
- // Submits a new request. If the request is a success, assigned
599
- // will be a pointer to the Http2Stream instance assigned.
600
- // This only works if the session is a client session.
601
- Http2Stream* SubmitRequest(
602
- const Http2Priority& priority,
603
- const Http2Headers& headers,
604
- int32_t* ret,
605
- int options = 0);
606
-
607
- SessionType type() const { return session_type_; }
608
-
609
- nghttp2_session* session() const { return session_.get(); }
610
-
611
- nghttp2_session* operator*() { return session_.get(); }
612
-
613
- uint32_t max_header_pairs() const { return max_header_pairs_; }
614
-
615
- const char* TypeName() const;
616
-
617
- bool is_destroyed() {
618
- return (flags_ & kSessionStateClosed) || session_ == nullptr;
619
- }
620
-
621
- void set_destroyed() {
622
- flags_ |= kSessionStateClosed;
623
- }
624
-
625
- #define IS_FLAG(name, flag) \
626
- bool is_##name() const { return flags_ & flag; } \
627
- void set_##name(bool on = true) { \
628
- if (on) \
629
- flags_ |= flag; \
630
- else \
631
- flags_ &= ~flag; \
632
- }
633
-
634
- IS_FLAG(in_scope, kSessionStateHasScope)
635
- IS_FLAG(write_scheduled, kSessionStateWriteScheduled)
636
- IS_FLAG(closing, kSessionStateClosing)
637
- IS_FLAG(sending, kSessionStateSending)
638
- IS_FLAG(write_in_progress, kSessionStateWriteInProgress)
639
- IS_FLAG(reading_stopped, kSessionStateReadingStopped)
640
- IS_FLAG(receive_paused, kSessionStateReceivePaused)
641
-
642
- #undef IS_FLAG
643
-
644
- // Schedule a write if nghttp2 indicates it wants to write to the socket.
645
- void MaybeScheduleWrite();
646
-
647
- // Stop reading if nghttp2 doesn't want to anymore.
648
- void MaybeStopReading();
649
-
650
- // Returns pointer to the stream, or nullptr if stream does not exist
651
- BaseObjectPtr<Http2Stream> FindStream(int32_t id);
652
-
653
- bool CanAddStream();
654
-
655
- // Adds a stream instance to this session
656
- void AddStream(Http2Stream* stream);
657
-
658
- // Removes a stream instance from this session
659
- BaseObjectPtr<Http2Stream> RemoveStream(int32_t id);
660
-
661
- // Indicates whether there currently exist outgoing buffers for this stream.
662
- bool HasWritesOnSocketForStream(Http2Stream* stream);
663
-
664
- // Write data from stream_buf_ to the session
665
- ssize_t ConsumeHTTP2Data();
666
-
667
- void MemoryInfo(MemoryTracker* tracker) const override;
668
- SET_MEMORY_INFO_NAME(Http2Session)
669
- SET_SELF_SIZE(Http2Session)
670
-
671
- std::string diagnostic_name() const override;
672
-
673
- // Schedule an RstStream for after the current write finishes.
674
- void AddPendingRstStream(int32_t stream_id) {
675
- pending_rst_streams_.emplace_back(stream_id);
676
- }
677
-
678
- bool has_pending_rststream(int32_t stream_id) {
679
- return pending_rst_streams_.end() !=
680
- std::find(pending_rst_streams_.begin(),
681
- pending_rst_streams_.end(),
682
- stream_id);
683
- }
684
-
685
- // Handle reads/writes from the underlying network transport.
686
- uv_buf_t OnStreamAlloc(size_t suggested_size) override;
687
- void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
688
- void OnStreamAfterWrite(WriteWrap* w, int status) override;
689
-
690
- // Implementation for mem::NgLibMemoryManager
691
- void CheckAllocatedSize(size_t previous_size) const;
692
- void IncreaseAllocatedSize(size_t size);
693
- void DecreaseAllocatedSize(size_t size);
694
-
695
- // The JavaScript API
696
- static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
697
- static void Consume(const v8::FunctionCallbackInfo<v8::Value>& args);
698
- static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
699
- static void Settings(const v8::FunctionCallbackInfo<v8::Value>& args);
700
- static void Request(const v8::FunctionCallbackInfo<v8::Value>& args);
701
- static void SetNextStreamID(const v8::FunctionCallbackInfo<v8::Value>& args);
702
- static void Goaway(const v8::FunctionCallbackInfo<v8::Value>& args);
703
- static void UpdateChunksSent(const v8::FunctionCallbackInfo<v8::Value>& args);
704
- static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
705
- static void Ping(const v8::FunctionCallbackInfo<v8::Value>& args);
706
- static void AltSvc(const v8::FunctionCallbackInfo<v8::Value>& args);
707
- static void Origin(const v8::FunctionCallbackInfo<v8::Value>& args);
708
-
709
- template <get_setting fn>
710
- static void RefreshSettings(const v8::FunctionCallbackInfo<v8::Value>& args);
711
-
712
- uv_loop_t* event_loop() const {
713
- return env()->event_loop();
714
- }
715
-
716
- Http2State* http2_state() const { return http2_state_.get(); }
717
-
718
- BaseObjectPtr<Http2Ping> PopPing();
719
- bool AddPing(const uint8_t* data, v8::Local<v8::Function> callback);
720
-
721
- BaseObjectPtr<Http2Settings> PopSettings();
722
- bool AddSettings(v8::Local<v8::Function> callback);
723
-
724
- void IncrementCurrentSessionMemory(uint64_t amount) {
725
- current_session_memory_ += amount;
726
- }
727
-
728
- void DecrementCurrentSessionMemory(uint64_t amount) {
729
- DCHECK_LE(amount, current_session_memory_);
730
- current_session_memory_ -= amount;
731
- }
732
-
733
- // Tell our custom memory allocator that this rcbuf is independent of
734
- // this session now, and may outlive it.
735
- void StopTrackingRcbuf(nghttp2_rcbuf* buf);
736
-
737
- // Returns the current session memory including memory allocated by nghttp2,
738
- // the current outbound storage queue, and pending writes.
739
- uint64_t current_session_memory() const {
740
- uint64_t total = current_session_memory_ + sizeof(Http2Session);
741
- total += current_nghttp2_memory_;
742
- total += outgoing_storage_.size();
743
- return total;
744
- }
745
-
746
- // Return true if current_session_memory + amount is less than the max
747
- bool has_available_session_memory(uint64_t amount) const {
748
- return current_session_memory() + amount <= max_session_memory_;
749
- }
750
-
751
- struct Statistics {
752
- uint64_t start_time;
753
- uint64_t end_time;
754
- uint64_t ping_rtt;
755
- uint64_t data_sent;
756
- uint64_t data_received;
757
- uint32_t frame_count;
758
- uint32_t frame_sent;
759
- int32_t stream_count;
760
- size_t max_concurrent_streams;
761
- double stream_average_duration;
762
- };
763
-
764
- Statistics statistics_ = {};
765
-
766
- private:
767
- void EmitStatistics();
768
-
769
- // Frame Padding Strategies
770
- ssize_t OnDWordAlignedPadding(size_t frameLength,
771
- size_t maxPayloadLen);
772
- ssize_t OnMaxFrameSizePadding(size_t frameLength,
773
- size_t maxPayloadLen);
774
-
775
- // Frame Handler
776
- int HandleDataFrame(const nghttp2_frame* frame);
777
- void HandleGoawayFrame(const nghttp2_frame* frame);
778
- void HandleHeadersFrame(const nghttp2_frame* frame);
779
- void HandlePriorityFrame(const nghttp2_frame* frame);
780
- void HandleSettingsFrame(const nghttp2_frame* frame);
781
- void HandlePingFrame(const nghttp2_frame* frame);
782
- void HandleAltSvcFrame(const nghttp2_frame* frame);
783
- void HandleOriginFrame(const nghttp2_frame* frame);
784
-
785
- // nghttp2 callbacks
786
- static int OnBeginHeadersCallback(
787
- nghttp2_session* session,
788
- const nghttp2_frame* frame,
789
- void* user_data);
790
- static int OnHeaderCallback(
791
- nghttp2_session* session,
792
- const nghttp2_frame* frame,
793
- nghttp2_rcbuf* name,
794
- nghttp2_rcbuf* value,
795
- uint8_t flags,
796
- void* user_data);
797
- static int OnFrameReceive(
798
- nghttp2_session* session,
799
- const nghttp2_frame* frame,
800
- void* user_data);
801
- static int OnFrameNotSent(
802
- nghttp2_session* session,
803
- const nghttp2_frame* frame,
804
- int error_code,
805
- void* user_data);
806
- static int OnFrameSent(
807
- nghttp2_session* session,
808
- const nghttp2_frame* frame,
809
- void* user_data);
810
- static int OnStreamClose(
811
- nghttp2_session* session,
812
- int32_t id,
813
- uint32_t code,
814
- void* user_data);
815
- static int OnInvalidHeader(
816
- nghttp2_session* session,
817
- const nghttp2_frame* frame,
818
- nghttp2_rcbuf* name,
819
- nghttp2_rcbuf* value,
820
- uint8_t flags,
821
- void* user_data);
822
- static int OnDataChunkReceived(
823
- nghttp2_session* session,
824
- uint8_t flags,
825
- int32_t id,
826
- const uint8_t* data,
827
- size_t len,
828
- void* user_data);
829
- static ssize_t OnSelectPadding(
830
- nghttp2_session* session,
831
- const nghttp2_frame* frame,
832
- size_t maxPayloadLen,
833
- void* user_data);
834
- static int OnNghttpError(
835
- nghttp2_session* session,
836
- const char* message,
837
- size_t len,
838
- void* user_data);
839
- static int OnSendData(
840
- nghttp2_session* session,
841
- nghttp2_frame* frame,
842
- const uint8_t* framehd,
843
- size_t length,
844
- nghttp2_data_source* source,
845
- void* user_data);
846
- static int OnInvalidFrame(
847
- nghttp2_session* session,
848
- const nghttp2_frame* frame,
849
- int lib_error_code,
850
- void* user_data);
851
-
852
- struct Callbacks {
853
- explicit Callbacks(bool kHasGetPaddingCallback);
854
-
855
- Nghttp2SessionCallbacksPointer callbacks;
856
- };
857
-
858
- /* Use callback_struct_saved[kHasGetPaddingCallback ? 1 : 0] */
859
- static const Callbacks callback_struct_saved[2];
860
-
861
- // The underlying nghttp2_session handle
862
- Nghttp2SessionPointer session_;
863
-
864
- // JS-accessible numeric fields, as indexed by SessionUint8Fields.
865
- AliasedStruct<SessionJSFields> js_fields_;
866
-
867
- // The session type: client or server
868
- SessionType session_type_;
869
-
870
- // The maximum number of header pairs permitted for streams on this session
871
- uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
872
-
873
- // The maximum amount of memory allocated for this session
874
- uint64_t max_session_memory_ = kDefaultMaxSessionMemory;
875
- uint64_t current_session_memory_ = 0;
876
- // The amount of memory allocated by nghttp2 internals
877
- uint64_t current_nghttp2_memory_ = 0;
878
-
879
- // The collection of active Http2Streams associated with this session
880
- std::unordered_map<int32_t, BaseObjectPtr<Http2Stream>> streams_;
881
-
882
- int flags_ = kSessionStateNone;
883
-
884
- // The StreamBase instance being used for i/o
885
- PaddingStrategy padding_strategy_ = PADDING_STRATEGY_NONE;
886
-
887
- // use this to allow timeout tracking during long-lasting writes
888
- uint32_t chunks_sent_since_last_write_ = 0;
889
-
890
- uv_buf_t stream_buf_ = uv_buf_init(nullptr, 0);
891
- // When processing input data, either stream_buf_ab_ or stream_buf_allocation_
892
- // will be set. stream_buf_ab_ is lazily created from stream_buf_allocation_.
893
- v8::Global<v8::ArrayBuffer> stream_buf_ab_;
894
- AllocatedBuffer stream_buf_allocation_;
895
- size_t stream_buf_offset_ = 0;
896
-
897
- size_t max_outstanding_pings_ = kDefaultMaxPings;
898
- std::queue<BaseObjectPtr<Http2Ping>> outstanding_pings_;
899
-
900
- size_t max_outstanding_settings_ = kDefaultMaxSettings;
901
- std::queue<BaseObjectPtr<Http2Settings>> outstanding_settings_;
902
-
903
- std::vector<NgHttp2StreamWrite> outgoing_buffers_;
904
- std::vector<uint8_t> outgoing_storage_;
905
- size_t outgoing_length_ = 0;
906
- std::vector<int32_t> pending_rst_streams_;
907
- // Count streams that have been rejected while being opened. Exceeding a fixed
908
- // limit will result in the session being destroyed, as an indication of a
909
- // misbehaving peer. This counter is reset once new streams are being
910
- // accepted again.
911
- uint32_t rejected_stream_count_ = 0;
912
- // Also use the invalid frame count as a measure for rejecting input frames.
913
- uint32_t invalid_frame_count_ = 0;
914
-
915
- void PushOutgoingBuffer(NgHttp2StreamWrite&& write);
916
-
917
- BaseObjectPtr<Http2State> http2_state_;
918
-
919
- void CopyDataIntoOutgoing(const uint8_t* src, size_t src_length);
920
- void ClearOutgoing(int status);
921
-
922
- friend class Http2Scope;
923
- friend class Http2StreamListener;
924
- };
925
-
926
- class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
927
- public:
928
- Http2SessionPerformanceEntry(
929
- Http2State* http2_state,
930
- const Http2Session::Statistics& stats,
931
- SessionType type) :
932
- performance::PerformanceEntry(
933
- http2_state->env(), "Http2Session", "http2",
934
- stats.start_time,
935
- stats.end_time),
936
- ping_rtt_(stats.ping_rtt),
937
- data_sent_(stats.data_sent),
938
- data_received_(stats.data_received),
939
- frame_count_(stats.frame_count),
940
- frame_sent_(stats.frame_sent),
941
- stream_count_(stats.stream_count),
942
- max_concurrent_streams_(stats.max_concurrent_streams),
943
- stream_average_duration_(stats.stream_average_duration),
944
- session_type_(type),
945
- http2_state_(http2_state) { }
946
-
947
- uint64_t ping_rtt() const { return ping_rtt_; }
948
- uint64_t data_sent() const { return data_sent_; }
949
- uint64_t data_received() const { return data_received_; }
950
- uint32_t frame_count() const { return frame_count_; }
951
- uint32_t frame_sent() const { return frame_sent_; }
952
- int32_t stream_count() const { return stream_count_; }
953
- size_t max_concurrent_streams() const { return max_concurrent_streams_; }
954
- double stream_average_duration() const { return stream_average_duration_; }
955
- SessionType type() const { return session_type_; }
956
- Http2State* http2_state() const { return http2_state_.get(); }
957
-
958
- void Notify(v8::Local<v8::Value> obj) {
959
- performance::PerformanceEntry::Notify(env(), kind(), obj);
960
- }
961
-
962
- private:
963
- uint64_t ping_rtt_;
964
- uint64_t data_sent_;
965
- uint64_t data_received_;
966
- uint32_t frame_count_;
967
- uint32_t frame_sent_;
968
- int32_t stream_count_;
969
- size_t max_concurrent_streams_;
970
- double stream_average_duration_;
971
- SessionType session_type_;
972
- BaseObjectPtr<Http2State> http2_state_;
973
- };
974
-
975
- class Http2StreamPerformanceEntry
976
- : public performance::PerformanceEntry {
977
- public:
978
- Http2StreamPerformanceEntry(
979
- Http2State* http2_state,
980
- int32_t id,
981
- const Http2Stream::Statistics& stats) :
982
- performance::PerformanceEntry(
983
- http2_state->env(), "Http2Stream", "http2",
984
- stats.start_time,
985
- stats.end_time),
986
- id_(id),
987
- first_header_(stats.first_header),
988
- first_byte_(stats.first_byte),
989
- first_byte_sent_(stats.first_byte_sent),
990
- sent_bytes_(stats.sent_bytes),
991
- received_bytes_(stats.received_bytes),
992
- http2_state_(http2_state) { }
993
-
994
- int32_t id() const { return id_; }
995
- uint64_t first_header() const { return first_header_; }
996
- uint64_t first_byte() const { return first_byte_; }
997
- uint64_t first_byte_sent() const { return first_byte_sent_; }
998
- uint64_t sent_bytes() const { return sent_bytes_; }
999
- uint64_t received_bytes() const { return received_bytes_; }
1000
- Http2State* http2_state() const { return http2_state_.get(); }
1001
-
1002
- void Notify(v8::Local<v8::Value> obj) {
1003
- performance::PerformanceEntry::Notify(env(), kind(), obj);
1004
- }
1005
-
1006
- private:
1007
- int32_t id_;
1008
- uint64_t first_header_;
1009
- uint64_t first_byte_;
1010
- uint64_t first_byte_sent_;
1011
- uint64_t sent_bytes_;
1012
- uint64_t received_bytes_;
1013
- BaseObjectPtr<Http2State> http2_state_;
1014
- };
1015
-
1016
- class Http2Ping : public AsyncWrap {
1017
- public:
1018
- explicit Http2Ping(
1019
- Http2Session* session,
1020
- v8::Local<v8::Object> obj,
1021
- v8::Local<v8::Function> callback);
1022
-
1023
- void MemoryInfo(MemoryTracker* tracker) const override;
1024
- SET_MEMORY_INFO_NAME(Http2Ping)
1025
- SET_SELF_SIZE(Http2Ping)
1026
-
1027
- void Send(const uint8_t* payload);
1028
- void Done(bool ack, const uint8_t* payload = nullptr);
1029
- void DetachFromSession();
1030
-
1031
- v8::Local<v8::Function> callback() const;
1032
-
1033
- private:
1034
- BaseObjectWeakPtr<Http2Session> session_;
1035
- v8::Global<v8::Function> callback_;
1036
- uint64_t startTime_;
1037
- };
1038
-
1039
- // The Http2Settings class is used to parse the settings passed in for
1040
- // an Http2Session, converting those into an array of nghttp2_settings_entry
1041
- // structs.
1042
- class Http2Settings : public AsyncWrap {
1043
- public:
1044
- Http2Settings(Http2Session* session,
1045
- v8::Local<v8::Object> obj,
1046
- v8::Local<v8::Function> callback,
1047
- uint64_t start_time = uv_hrtime());
1048
-
1049
- void MemoryInfo(MemoryTracker* tracker) const override;
1050
- SET_MEMORY_INFO_NAME(Http2Settings)
1051
- SET_SELF_SIZE(Http2Settings)
1052
-
1053
- void Send();
1054
- void Done(bool ack);
1055
-
1056
- v8::Local<v8::Function> callback() const;
1057
-
1058
- // Returns a Buffer instance with the serialized SETTINGS payload
1059
- v8::Local<v8::Value> Pack();
1060
-
1061
- static v8::Local<v8::Value> Pack(Http2State* state);
1062
-
1063
- // Resets the default values in the settings buffer
1064
- static void RefreshDefaults(Http2State* http2_state);
1065
-
1066
- // Update the local or remote settings for the given session
1067
- static void Update(Http2Session* session,
1068
- get_setting fn);
1069
-
1070
- private:
1071
- static size_t Init(
1072
- Http2State* http2_state,
1073
- nghttp2_settings_entry* entries);
1074
-
1075
- static v8::Local<v8::Value> Pack(
1076
- Environment* env,
1077
- size_t count,
1078
- const nghttp2_settings_entry* entries);
1079
-
1080
- BaseObjectWeakPtr<Http2Session> session_;
1081
- v8::Global<v8::Function> callback_;
1082
- uint64_t startTime_;
1083
- size_t count_ = 0;
1084
- nghttp2_settings_entry entries_[IDX_SETTINGS_COUNT];
1085
- };
1086
-
1087
- class Origins {
1088
- public:
1089
- Origins(Environment* env,
1090
- v8::Local<v8::String> origin_string,
1091
- size_t origin_count);
1092
- ~Origins() = default;
1093
-
1094
- const nghttp2_origin_entry* operator*() const {
1095
- return reinterpret_cast<const nghttp2_origin_entry*>(buf_.data());
1096
- }
1097
-
1098
- size_t length() const {
1099
- return count_;
1100
- }
1101
-
1102
- private:
1103
- size_t count_;
1104
- AllocatedBuffer buf_;
1105
- };
1106
-
1107
- #define HTTP2_HIDDEN_CONSTANTS(V) \
1108
- V(NGHTTP2_HCAT_REQUEST) \
1109
- V(NGHTTP2_HCAT_RESPONSE) \
1110
- V(NGHTTP2_HCAT_PUSH_RESPONSE) \
1111
- V(NGHTTP2_HCAT_HEADERS) \
1112
- V(NGHTTP2_NV_FLAG_NONE) \
1113
- V(NGHTTP2_NV_FLAG_NO_INDEX) \
1114
- V(NGHTTP2_ERR_DEFERRED) \
1115
- V(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE) \
1116
- V(NGHTTP2_ERR_INVALID_ARGUMENT) \
1117
- V(NGHTTP2_ERR_STREAM_CLOSED) \
1118
- V(STREAM_OPTION_EMPTY_PAYLOAD) \
1119
- V(STREAM_OPTION_GET_TRAILERS)
1120
-
1121
- #define HTTP2_ERROR_CODES(V) \
1122
- V(NGHTTP2_NO_ERROR) \
1123
- V(NGHTTP2_PROTOCOL_ERROR) \
1124
- V(NGHTTP2_INTERNAL_ERROR) \
1125
- V(NGHTTP2_FLOW_CONTROL_ERROR) \
1126
- V(NGHTTP2_SETTINGS_TIMEOUT) \
1127
- V(NGHTTP2_STREAM_CLOSED) \
1128
- V(NGHTTP2_FRAME_SIZE_ERROR) \
1129
- V(NGHTTP2_REFUSED_STREAM) \
1130
- V(NGHTTP2_CANCEL) \
1131
- V(NGHTTP2_COMPRESSION_ERROR) \
1132
- V(NGHTTP2_CONNECT_ERROR) \
1133
- V(NGHTTP2_ENHANCE_YOUR_CALM) \
1134
- V(NGHTTP2_INADEQUATE_SECURITY) \
1135
- V(NGHTTP2_HTTP_1_1_REQUIRED) \
1136
-
1137
- #define HTTP2_CONSTANTS(V) \
1138
- V(NGHTTP2_ERR_FRAME_SIZE_ERROR) \
1139
- V(NGHTTP2_SESSION_SERVER) \
1140
- V(NGHTTP2_SESSION_CLIENT) \
1141
- V(NGHTTP2_STREAM_STATE_IDLE) \
1142
- V(NGHTTP2_STREAM_STATE_OPEN) \
1143
- V(NGHTTP2_STREAM_STATE_RESERVED_LOCAL) \
1144
- V(NGHTTP2_STREAM_STATE_RESERVED_REMOTE) \
1145
- V(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL) \
1146
- V(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE) \
1147
- V(NGHTTP2_STREAM_STATE_CLOSED) \
1148
- V(NGHTTP2_FLAG_NONE) \
1149
- V(NGHTTP2_FLAG_END_STREAM) \
1150
- V(NGHTTP2_FLAG_END_HEADERS) \
1151
- V(NGHTTP2_FLAG_ACK) \
1152
- V(NGHTTP2_FLAG_PADDED) \
1153
- V(NGHTTP2_FLAG_PRIORITY) \
1154
- V(DEFAULT_SETTINGS_HEADER_TABLE_SIZE) \
1155
- V(DEFAULT_SETTINGS_ENABLE_PUSH) \
1156
- V(DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS) \
1157
- V(DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE) \
1158
- V(DEFAULT_SETTINGS_MAX_FRAME_SIZE) \
1159
- V(DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE) \
1160
- V(DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL) \
1161
- V(MAX_MAX_FRAME_SIZE) \
1162
- V(MIN_MAX_FRAME_SIZE) \
1163
- V(MAX_INITIAL_WINDOW_SIZE) \
1164
- V(NGHTTP2_SETTINGS_HEADER_TABLE_SIZE) \
1165
- V(NGHTTP2_SETTINGS_ENABLE_PUSH) \
1166
- V(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS) \
1167
- V(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE) \
1168
- V(NGHTTP2_SETTINGS_MAX_FRAME_SIZE) \
1169
- V(NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE) \
1170
- V(NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL) \
1171
- V(PADDING_STRATEGY_NONE) \
1172
- V(PADDING_STRATEGY_ALIGNED) \
1173
- V(PADDING_STRATEGY_MAX) \
1174
- V(PADDING_STRATEGY_CALLBACK) \
1175
- HTTP2_ERROR_CODES(V)
1176
-
1177
- #define HTTP2_SETTINGS(V) \
1178
- V(HEADER_TABLE_SIZE) \
1179
- V(ENABLE_PUSH) \
1180
- V(MAX_CONCURRENT_STREAMS) \
1181
- V(INITIAL_WINDOW_SIZE) \
1182
- V(MAX_FRAME_SIZE) \
1183
- V(MAX_HEADER_LIST_SIZE) \
1184
- V(ENABLE_CONNECT_PROTOCOL) \
1185
-
1186
- } // namespace http2
1187
- } // namespace node
1188
-
1189
- #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
1190
-
1191
- #endif // SRC_NODE_HTTP2_H_