@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.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 (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/node/include/acorn_version.h +6 -0
  4. package/dist/node/include/aliased_buffer-inl.h +244 -0
  5. package/dist/node/include/aliased_buffer.h +206 -0
  6. package/dist/node/include/aliased_struct-inl.h +54 -0
  7. package/dist/node/include/aliased_struct.h +63 -0
  8. package/dist/node/include/amaro_version.h +6 -0
  9. package/dist/node/include/async_context_frame.h +33 -0
  10. package/dist/node/include/async_wrap-inl.h +96 -0
  11. package/dist/node/include/async_wrap.h +243 -0
  12. package/dist/node/include/base_object-inl.h +335 -0
  13. package/dist/node/include/base_object.h +342 -0
  14. package/dist/node/include/base_object_types.h +74 -0
  15. package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
  16. package/dist/node/include/blob_serializer_deserializer.h +132 -0
  17. package/dist/node/include/callback_queue-inl.h +97 -0
  18. package/dist/node/include/callback_queue.h +79 -0
  19. package/dist/node/include/cares_wrap.h +447 -0
  20. package/dist/node/include/cjs_module_lexer_version.h +6 -0
  21. package/dist/node/include/cleanup_queue-inl.h +36 -0
  22. package/dist/node/include/cleanup_queue.h +79 -0
  23. package/dist/node/include/compile_cache.h +104 -0
  24. package/dist/node/include/connect_wrap.h +26 -0
  25. package/dist/node/include/connection_wrap.h +30 -0
  26. package/dist/node/include/cppgc/allocation.h +310 -0
  27. package/dist/node/include/cppgc/common.h +28 -0
  28. package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
  29. package/dist/node/include/cppgc/custom-space.h +97 -0
  30. package/dist/node/include/cppgc/default-platform.h +67 -0
  31. package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
  32. package/dist/node/include/cppgc/explicit-management.h +100 -0
  33. package/dist/node/include/cppgc/garbage-collected.h +106 -0
  34. package/dist/node/include/cppgc/heap-consistency.h +309 -0
  35. package/dist/node/include/cppgc/heap-handle.h +48 -0
  36. package/dist/node/include/cppgc/heap-state.h +82 -0
  37. package/dist/node/include/cppgc/heap-statistics.h +120 -0
  38. package/dist/node/include/cppgc/heap.h +202 -0
  39. package/dist/node/include/cppgc/internal/api-constants.h +87 -0
  40. package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
  41. package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
  42. package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
  43. package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
  44. package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
  45. package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
  46. package/dist/node/include/cppgc/internal/gc-info.h +148 -0
  47. package/dist/node/include/cppgc/internal/logging.h +50 -0
  48. package/dist/node/include/cppgc/internal/member-storage.h +256 -0
  49. package/dist/node/include/cppgc/internal/name-trait.h +137 -0
  50. package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
  51. package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
  52. package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
  53. package/dist/node/include/cppgc/liveness-broker.h +78 -0
  54. package/dist/node/include/cppgc/macros.h +35 -0
  55. package/dist/node/include/cppgc/member.h +629 -0
  56. package/dist/node/include/cppgc/name-provider.h +65 -0
  57. package/dist/node/include/cppgc/object-size-trait.h +58 -0
  58. package/dist/node/include/cppgc/persistent.h +377 -0
  59. package/dist/node/include/cppgc/platform.h +163 -0
  60. package/dist/node/include/cppgc/prefinalizer.h +75 -0
  61. package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
  62. package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
  63. package/dist/node/include/cppgc/source-location.h +16 -0
  64. package/dist/node/include/cppgc/testing.h +106 -0
  65. package/dist/node/include/cppgc/trace-trait.h +128 -0
  66. package/dist/node/include/cppgc/type-traits.h +271 -0
  67. package/dist/node/include/cppgc/visitor.h +504 -0
  68. package/dist/node/include/crypto/crypto_aes.h +88 -0
  69. package/dist/node/include/crypto/crypto_bio.h +193 -0
  70. package/dist/node/include/crypto/crypto_cipher.h +293 -0
  71. package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
  72. package/dist/node/include/crypto/crypto_clienthello.h +131 -0
  73. package/dist/node/include/crypto/crypto_common.h +64 -0
  74. package/dist/node/include/crypto/crypto_context.h +171 -0
  75. package/dist/node/include/crypto/crypto_dh.h +126 -0
  76. package/dist/node/include/crypto/crypto_dsa.h +52 -0
  77. package/dist/node/include/crypto/crypto_ec.h +164 -0
  78. package/dist/node/include/crypto/crypto_hash.h +91 -0
  79. package/dist/node/include/crypto/crypto_hkdf.h +61 -0
  80. package/dist/node/include/crypto/crypto_hmac.h +92 -0
  81. package/dist/node/include/crypto/crypto_keygen.h +299 -0
  82. package/dist/node/include/crypto/crypto_keys.h +392 -0
  83. package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
  84. package/dist/node/include/crypto/crypto_random.h +124 -0
  85. package/dist/node/include/crypto/crypto_rsa.h +136 -0
  86. package/dist/node/include/crypto/crypto_scrypt.h +85 -0
  87. package/dist/node/include/crypto/crypto_sig.h +165 -0
  88. package/dist/node/include/crypto/crypto_spkac.h +21 -0
  89. package/dist/node/include/crypto/crypto_timing.h +20 -0
  90. package/dist/node/include/crypto/crypto_tls.h +305 -0
  91. package/dist/node/include/crypto/crypto_util.h +725 -0
  92. package/dist/node/include/crypto/crypto_x509.h +140 -0
  93. package/dist/node/include/dataqueue/queue.h +306 -0
  94. package/dist/node/include/debug_utils-inl.h +278 -0
  95. package/dist/node/include/debug_utils.h +196 -0
  96. package/dist/node/include/diagnosticfilename-inl.h +33 -0
  97. package/dist/node/include/embedded_data.h +17 -0
  98. package/dist/node/include/encoding_binding.h +61 -0
  99. package/dist/node/include/env-inl.h +984 -0
  100. package/dist/node/include/env.h +1287 -0
  101. package/dist/node/include/env_properties.h +540 -0
  102. package/dist/node/include/handle_wrap.h +123 -0
  103. package/dist/node/include/histogram-inl.h +107 -0
  104. package/dist/node/include/histogram.h +279 -0
  105. package/dist/node/include/inspector/io_agent.h +30 -0
  106. package/dist/node/include/inspector/main_thread_interface.h +116 -0
  107. package/dist/node/include/inspector/network_agent.h +94 -0
  108. package/dist/node/include/inspector/network_inspector.h +45 -0
  109. package/dist/node/include/inspector/network_requests_buffer.h +195 -0
  110. package/dist/node/include/inspector/network_resource_manager.h +29 -0
  111. package/dist/node/include/inspector/node_json.h +24 -0
  112. package/dist/node/include/inspector/node_string.h +101 -0
  113. package/dist/node/include/inspector/protocol_helper.h +27 -0
  114. package/dist/node/include/inspector/runtime_agent.h +41 -0
  115. package/dist/node/include/inspector/target_agent.h +75 -0
  116. package/dist/node/include/inspector/tracing_agent.h +43 -0
  117. package/dist/node/include/inspector/worker_agent.h +40 -0
  118. package/dist/node/include/inspector/worker_inspector.h +124 -0
  119. package/dist/node/include/inspector_agent.h +165 -0
  120. package/dist/node/include/inspector_io.h +78 -0
  121. package/dist/node/include/inspector_profiler.h +149 -0
  122. package/dist/node/include/inspector_socket.h +60 -0
  123. package/dist/node/include/inspector_socket_server.h +110 -0
  124. package/dist/node/include/js_native_api.h +607 -0
  125. package/dist/node/include/js_native_api_types.h +226 -0
  126. package/dist/node/include/js_native_api_v8.h +485 -0
  127. package/dist/node/include/js_native_api_v8_internals.h +45 -0
  128. package/dist/node/include/js_stream.h +52 -0
  129. package/dist/node/include/json_utils.h +172 -0
  130. package/dist/node/include/large_pages/node_large_page.h +34 -0
  131. package/dist/node/include/libplatform/libplatform-export.h +29 -0
  132. package/dist/node/include/libplatform/libplatform.h +112 -0
  133. package/dist/node/include/libplatform/v8-tracing.h +333 -0
  134. package/dist/node/include/memory_tracker-inl.h +359 -0
  135. package/dist/node/include/memory_tracker.h +289 -0
  136. package/dist/node/include/module_wrap.h +216 -0
  137. package/dist/node/include/node.h +1593 -0
  138. package/dist/node/include/node_api.h +265 -0
  139. package/dist/node/include/node_api_internals.h +48 -0
  140. package/dist/node/include/node_api_types.h +56 -0
  141. package/dist/node/include/node_binding.h +161 -0
  142. package/dist/node/include/node_blob.h +159 -0
  143. package/dist/node/include/node_bob-inl.h +36 -0
  144. package/dist/node/include/node_bob.h +107 -0
  145. package/dist/node/include/node_buffer.h +92 -0
  146. package/dist/node/include/node_builtins.h +220 -0
  147. package/dist/node/include/node_config_file.h +46 -0
  148. package/dist/node/include/node_constants.h +82 -0
  149. package/dist/node/include/node_context_data.h +168 -0
  150. package/dist/node/include/node_contextify.h +204 -0
  151. package/dist/node/include/node_crypto.h +56 -0
  152. package/dist/node/include/node_debug.h +30 -0
  153. package/dist/node/include/node_dir.h +52 -0
  154. package/dist/node/include/node_dotenv.h +45 -0
  155. package/dist/node/include/node_errors.h +380 -0
  156. package/dist/node/include/node_exit_code.h +54 -0
  157. package/dist/node/include/node_external_reference.h +165 -0
  158. package/dist/node/include/node_file-inl.h +406 -0
  159. package/dist/node/include/node_file.h +537 -0
  160. package/dist/node/include/node_http2.h +1177 -0
  161. package/dist/node/include/node_http2_state.h +159 -0
  162. package/dist/node/include/node_http_common-inl.h +202 -0
  163. package/dist/node/include/node_http_common.h +535 -0
  164. package/dist/node/include/node_i18n.h +132 -0
  165. package/dist/node/include/node_internals.h +483 -0
  166. package/dist/node/include/node_main_instance.h +67 -0
  167. package/dist/node/include/node_mem-inl.h +113 -0
  168. package/dist/node/include/node_mem.h +45 -0
  169. package/dist/node/include/node_messaging.h +389 -0
  170. package/dist/node/include/node_metadata.h +164 -0
  171. package/dist/node/include/node_modules.h +91 -0
  172. package/dist/node/include/node_mutex.h +323 -0
  173. package/dist/node/include/node_object_wrap.h +132 -0
  174. package/dist/node/include/node_options-inl.h +490 -0
  175. package/dist/node/include/node_options.h +615 -0
  176. package/dist/node/include/node_perf.h +166 -0
  177. package/dist/node/include/node_perf_common.h +102 -0
  178. package/dist/node/include/node_platform.h +238 -0
  179. package/dist/node/include/node_process-inl.h +26 -0
  180. package/dist/node/include/node_process.h +112 -0
  181. package/dist/node/include/node_realm-inl.h +151 -0
  182. package/dist/node/include/node_realm.h +183 -0
  183. package/dist/node/include/node_report.h +43 -0
  184. package/dist/node/include/node_revert.h +82 -0
  185. package/dist/node/include/node_root_certs.h +3520 -0
  186. package/dist/node/include/node_sea.h +74 -0
  187. package/dist/node/include/node_shadow_realm.h +46 -0
  188. package/dist/node/include/node_snapshot_builder.h +57 -0
  189. package/dist/node/include/node_snapshotable.h +174 -0
  190. package/dist/node/include/node_sockaddr-inl.h +257 -0
  191. package/dist/node/include/node_sockaddr.h +394 -0
  192. package/dist/node/include/node_sqlite.h +270 -0
  193. package/dist/node/include/node_stat_watcher.h +73 -0
  194. package/dist/node/include/node_task_runner.h +92 -0
  195. package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
  196. package/dist/node/include/node_threadsafe_cow.h +105 -0
  197. package/dist/node/include/node_union_bytes.h +81 -0
  198. package/dist/node/include/node_url.h +96 -0
  199. package/dist/node/include/node_v8.h +77 -0
  200. package/dist/node/include/node_v8_platform-inl.h +185 -0
  201. package/dist/node/include/node_version.h +110 -0
  202. package/dist/node/include/node_wasi.h +184 -0
  203. package/dist/node/include/node_wasm_web_api.h +55 -0
  204. package/dist/node/include/node_watchdog.h +154 -0
  205. package/dist/node/include/node_webstorage.h +60 -0
  206. package/dist/node/include/node_worker.h +158 -0
  207. package/dist/node/include/path.h +33 -0
  208. package/dist/node/include/permission/addon_permission.h +31 -0
  209. package/dist/node/include/permission/child_process_permission.h +31 -0
  210. package/dist/node/include/permission/fs_permission.h +167 -0
  211. package/dist/node/include/permission/inspector_permission.h +31 -0
  212. package/dist/node/include/permission/permission.h +138 -0
  213. package/dist/node/include/permission/permission_base.h +65 -0
  214. package/dist/node/include/permission/wasi_permission.h +31 -0
  215. package/dist/node/include/permission/worker_permission.h +31 -0
  216. package/dist/node/include/pipe_wrap.h +80 -0
  217. package/dist/node/include/quic/application.h +159 -0
  218. package/dist/node/include/quic/bindingdata.h +272 -0
  219. package/dist/node/include/quic/cid.h +127 -0
  220. package/dist/node/include/quic/data.h +148 -0
  221. package/dist/node/include/quic/defs.h +245 -0
  222. package/dist/node/include/quic/endpoint.h +458 -0
  223. package/dist/node/include/quic/http3.h +15 -0
  224. package/dist/node/include/quic/logstream.h +81 -0
  225. package/dist/node/include/quic/packet.h +152 -0
  226. package/dist/node/include/quic/preferredaddress.h +72 -0
  227. package/dist/node/include/quic/session.h +443 -0
  228. package/dist/node/include/quic/sessionticket.h +108 -0
  229. package/dist/node/include/quic/streams.h +232 -0
  230. package/dist/node/include/quic/tlscontext.h +227 -0
  231. package/dist/node/include/quic/tokens.h +256 -0
  232. package/dist/node/include/quic/transportparams.h +165 -0
  233. package/dist/node/include/req_wrap-inl.h +171 -0
  234. package/dist/node/include/req_wrap.h +77 -0
  235. package/dist/node/include/spawn_sync.h +243 -0
  236. package/dist/node/include/stream_base-inl.h +173 -0
  237. package/dist/node/include/stream_base.h +478 -0
  238. package/dist/node/include/stream_pipe.h +76 -0
  239. package/dist/node/include/stream_wrap.h +132 -0
  240. package/dist/node/include/string_bytes.h +113 -0
  241. package/dist/node/include/string_decoder-inl.h +31 -0
  242. package/dist/node/include/string_decoder.h +49 -0
  243. package/dist/node/include/tcp_wrap.h +105 -0
  244. package/dist/node/include/threadpoolwork-inl.h +70 -0
  245. package/dist/node/include/timer_wrap-inl.h +32 -0
  246. package/dist/node/include/timer_wrap.h +85 -0
  247. package/dist/node/include/timers.h +70 -0
  248. package/dist/node/include/tracing/agent.h +195 -0
  249. package/dist/node/include/tracing/node_trace_buffer.h +83 -0
  250. package/dist/node/include/tracing/node_trace_writer.h +75 -0
  251. package/dist/node/include/tracing/trace_event.h +722 -0
  252. package/dist/node/include/tracing/trace_event_common.h +1109 -0
  253. package/dist/node/include/tracing/traced_value.h +129 -0
  254. package/dist/node/include/tty_wrap.h +65 -0
  255. package/dist/node/include/udp_wrap.h +230 -0
  256. package/dist/node/include/undici_version.h +6 -0
  257. package/dist/node/include/util-inl.h +700 -0
  258. package/dist/node/include/util.h +1021 -0
  259. package/dist/node/include/uv/aix.h +32 -0
  260. package/dist/node/include/uv/bsd.h +34 -0
  261. package/dist/node/include/uv/darwin.h +61 -0
  262. package/dist/node/include/uv/errno.h +483 -0
  263. package/dist/node/include/uv/linux.h +34 -0
  264. package/dist/node/include/uv/os390.h +33 -0
  265. package/dist/node/include/uv/posix.h +31 -0
  266. package/dist/node/include/uv/sunos.h +44 -0
  267. package/dist/node/include/uv/threadpool.h +37 -0
  268. package/dist/node/include/uv/tree.h +521 -0
  269. package/dist/node/include/uv/unix.h +512 -0
  270. package/dist/node/include/uv/version.h +43 -0
  271. package/dist/node/include/uv/win.h +698 -0
  272. package/dist/node/include/uv.h +1990 -0
  273. package/dist/node/include/v8-array-buffer.h +525 -0
  274. package/dist/node/include/v8-callbacks.h +462 -0
  275. package/dist/node/include/v8-container.h +183 -0
  276. package/dist/node/include/v8-context.h +485 -0
  277. package/dist/node/include/v8-cppgc.h +245 -0
  278. package/dist/node/include/v8-data.h +80 -0
  279. package/dist/node/include/v8-date.h +48 -0
  280. package/dist/node/include/v8-debug.h +168 -0
  281. package/dist/node/include/v8-embedder-heap.h +82 -0
  282. package/dist/node/include/v8-embedder-state-scope.h +52 -0
  283. package/dist/node/include/v8-exception.h +223 -0
  284. package/dist/node/include/v8-extension.h +62 -0
  285. package/dist/node/include/v8-external.h +37 -0
  286. package/dist/node/include/v8-fast-api-calls.h +984 -0
  287. package/dist/node/include/v8-forward.h +82 -0
  288. package/dist/node/include/v8-function-callback.h +607 -0
  289. package/dist/node/include/v8-function.h +140 -0
  290. package/dist/node/include/v8-handle-base.h +137 -0
  291. package/dist/node/include/v8-initialization.h +289 -0
  292. package/dist/node/include/v8-inspector-protocol.h +13 -0
  293. package/dist/node/include/v8-inspector.h +419 -0
  294. package/dist/node/include/v8-internal.h +1397 -0
  295. package/dist/node/include/v8-isolate.h +1767 -0
  296. package/dist/node/include/v8-json.h +47 -0
  297. package/dist/node/include/v8-local-handle.h +758 -0
  298. package/dist/node/include/v8-locker.h +138 -0
  299. package/dist/node/include/v8-maybe.h +160 -0
  300. package/dist/node/include/v8-memory-span.h +198 -0
  301. package/dist/node/include/v8-message.h +233 -0
  302. package/dist/node/include/v8-metrics.h +264 -0
  303. package/dist/node/include/v8-microtask-queue.h +157 -0
  304. package/dist/node/include/v8-microtask.h +28 -0
  305. package/dist/node/include/v8-object.h +824 -0
  306. package/dist/node/include/v8-persistent-handle.h +582 -0
  307. package/dist/node/include/v8-platform.h +1358 -0
  308. package/dist/node/include/v8-primitive-object.h +118 -0
  309. package/dist/node/include/v8-primitive.h +877 -0
  310. package/dist/node/include/v8-profiler.h +1302 -0
  311. package/dist/node/include/v8-promise.h +174 -0
  312. package/dist/node/include/v8-proxy.h +50 -0
  313. package/dist/node/include/v8-regexp.h +106 -0
  314. package/dist/node/include/v8-script.h +904 -0
  315. package/dist/node/include/v8-snapshot.h +266 -0
  316. package/dist/node/include/v8-source-location.h +92 -0
  317. package/dist/node/include/v8-statistics.h +238 -0
  318. package/dist/node/include/v8-template.h +1297 -0
  319. package/dist/node/include/v8-traced-handle.h +432 -0
  320. package/dist/node/include/v8-typed-array.h +390 -0
  321. package/dist/node/include/v8-unwinder-state.h +31 -0
  322. package/dist/node/include/v8-unwinder.h +132 -0
  323. package/dist/node/include/v8-util.h +665 -0
  324. package/dist/node/include/v8-value-serializer-version.h +24 -0
  325. package/dist/node/include/v8-value-serializer.h +316 -0
  326. package/dist/node/include/v8-value.h +655 -0
  327. package/dist/node/include/v8-version-string.h +38 -0
  328. package/dist/node/include/v8-version.h +20 -0
  329. package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
  330. package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
  331. package/dist/node/include/v8-wasm.h +201 -0
  332. package/dist/node/include/v8-weak-callback-info.h +80 -0
  333. package/dist/node/include/v8.h +88 -0
  334. package/dist/node/include/v8config.h +981 -0
  335. package/dist/node/include/zlib_version.h +6 -0
  336. package/dist/node/libnode.dll +0 -0
  337. package/dist/node/libnode.lib +0 -0
  338. package/dist/node/libnodebuildinfo.json +10 -0
  339. package/dist/node/link_node.lib +0 -0
  340. package/dist/node/link_node.node +0 -0
  341. package/index.js +5 -0
  342. package/libnode.release.json +8 -0
  343. package/package.json +29 -1
@@ -0,0 +1,535 @@
1
+ #ifndef SRC_NODE_HTTP_COMMON_H_
2
+ #define SRC_NODE_HTTP_COMMON_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "v8.h"
7
+ #include "node_mem.h"
8
+
9
+ #include <string>
10
+
11
+ namespace node {
12
+
13
+ class Environment;
14
+
15
+ #define MAX_MAX_HEADER_LIST_SIZE 16777215u
16
+ #define DEFAULT_MAX_HEADER_LIST_PAIRS 128u
17
+ #define DEFAULT_MAX_HEADER_LENGTH 8192
18
+
19
+ #define HTTP_SPECIAL_HEADERS(V) \
20
+ V(STATUS, ":status") \
21
+ V(METHOD, ":method") \
22
+ V(AUTHORITY, ":authority") \
23
+ V(SCHEME, ":scheme") \
24
+ V(PATH, ":path") \
25
+ V(PROTOCOL, ":protocol")
26
+
27
+ #define HTTP_REGULAR_HEADERS(V) \
28
+ V(ACCEPT_ENCODING, "accept-encoding") \
29
+ V(ACCEPT_LANGUAGE, "accept-language") \
30
+ V(ACCEPT_RANGES, "accept-ranges") \
31
+ V(ACCEPT, "accept") \
32
+ V(ACCESS_CONTROL_ALLOW_CREDENTIALS, "access-control-allow-credentials") \
33
+ V(ACCESS_CONTROL_ALLOW_HEADERS, "access-control-allow-headers") \
34
+ V(ACCESS_CONTROL_ALLOW_METHODS, "access-control-allow-methods") \
35
+ V(ACCESS_CONTROL_ALLOW_ORIGIN, "access-control-allow-origin") \
36
+ V(ACCESS_CONTROL_EXPOSE_HEADERS, "access-control-expose-headers") \
37
+ V(ACCESS_CONTROL_REQUEST_HEADERS, "access-control-request-headers") \
38
+ V(ACCESS_CONTROL_REQUEST_METHOD, "access-control-request-method") \
39
+ V(AGE, "age") \
40
+ V(AUTHORIZATION, "authorization") \
41
+ V(CACHE_CONTROL, "cache-control") \
42
+ V(CONNECTION, "connection") \
43
+ V(CONTENT_DISPOSITION, "content-disposition") \
44
+ V(CONTENT_ENCODING, "content-encoding") \
45
+ V(CONTENT_LENGTH, "content-length") \
46
+ V(CONTENT_TYPE, "content-type") \
47
+ V(COOKIE, "cookie") \
48
+ V(DATE, "date") \
49
+ V(ETAG, "etag") \
50
+ V(FORWARDED, "forwarded") \
51
+ V(HOST, "host") \
52
+ V(IF_MODIFIED_SINCE, "if-modified-since") \
53
+ V(IF_NONE_MATCH, "if-none-match") \
54
+ V(IF_RANGE, "if-range") \
55
+ V(LAST_MODIFIED, "last-modified") \
56
+ V(LINK, "link") \
57
+ V(LOCATION, "location") \
58
+ V(RANGE, "range") \
59
+ V(REFERER, "referer") \
60
+ V(SERVER, "server") \
61
+ V(SET_COOKIE, "set-cookie") \
62
+ V(STRICT_TRANSPORT_SECURITY, "strict-transport-security") \
63
+ V(TRANSFER_ENCODING, "transfer-encoding") \
64
+ V(TE, "te") \
65
+ V(UPGRADE_INSECURE_REQUESTS, "upgrade-insecure-requests") \
66
+ V(UPGRADE, "upgrade") \
67
+ V(USER_AGENT, "user-agent") \
68
+ V(VARY, "vary") \
69
+ V(X_CONTENT_TYPE_OPTIONS, "x-content-type-options") \
70
+ V(X_FRAME_OPTIONS, "x-frame-options") \
71
+ V(KEEP_ALIVE, "keep-alive") \
72
+ V(PROXY_CONNECTION, "proxy-connection") \
73
+ V(X_XSS_PROTECTION, "x-xss-protection") \
74
+ V(ALT_SVC, "alt-svc") \
75
+ V(CONTENT_SECURITY_POLICY, "content-security-policy") \
76
+ V(EARLY_DATA, "early-data") \
77
+ V(EXPECT_CT, "expect-ct") \
78
+ V(ORIGIN, "origin") \
79
+ V(PURPOSE, "purpose") \
80
+ V(TIMING_ALLOW_ORIGIN, "timing-allow-origin") \
81
+ V(X_FORWARDED_FOR, "x-forwarded-for") \
82
+ V(PRIORITY, "priority")
83
+
84
+ #define HTTP_ADDITIONAL_HEADERS(V) \
85
+ V(ACCEPT_CHARSET, "accept-charset") \
86
+ V(ACCESS_CONTROL_MAX_AGE, "access-control-max-age") \
87
+ V(ALLOW, "allow") \
88
+ V(CONTENT_LANGUAGE, "content-language") \
89
+ V(CONTENT_LOCATION, "content-location") \
90
+ V(CONTENT_MD5, "content-md5") \
91
+ V(CONTENT_RANGE, "content-range") \
92
+ V(DNT, "dnt") \
93
+ V(EXPECT, "expect") \
94
+ V(EXPIRES, "expires") \
95
+ V(FROM, "from") \
96
+ V(IF_MATCH, "if-match") \
97
+ V(IF_UNMODIFIED_SINCE, "if-unmodified-since") \
98
+ V(MAX_FORWARDS, "max-forwards") \
99
+ V(PREFER, "prefer") \
100
+ V(PROXY_AUTHENTICATE, "proxy-authenticate") \
101
+ V(PROXY_AUTHORIZATION, "proxy-authorization") \
102
+ V(REFRESH, "refresh") \
103
+ V(RETRY_AFTER, "retry-after") \
104
+ V(TRAILER, "trailer") \
105
+ V(TK, "tk") \
106
+ V(VIA, "via") \
107
+ V(WARNING, "warning") \
108
+ V(WWW_AUTHENTICATE, "www-authenticate") \
109
+ V(HTTP2_SETTINGS, "http2-settings")
110
+
111
+ // Special and regular headers are handled specifically by the HTTP/2 (and
112
+ // later HTTP/3) implementation.
113
+ #define HTTP_KNOWN_HEADERS(V) \
114
+ HTTP_SPECIAL_HEADERS(V) \
115
+ HTTP_REGULAR_HEADERS(V) \
116
+ HTTP_ADDITIONAL_HEADERS(V)
117
+
118
+ enum http_known_headers {
119
+ HTTP_KNOWN_HEADER_MIN,
120
+ #define V(name, value) HTTP_HEADER_##name,
121
+ HTTP_KNOWN_HEADERS(V)
122
+ #undef V
123
+ HTTP_KNOWN_HEADER_MAX
124
+ };
125
+
126
+ #define HTTP_STATUS_CODES(V) \
127
+ V(CONTINUE, 100) \
128
+ V(SWITCHING_PROTOCOLS, 101) \
129
+ V(PROCESSING, 102) \
130
+ V(EARLY_HINTS, 103) \
131
+ V(OK, 200) \
132
+ V(CREATED, 201) \
133
+ V(ACCEPTED, 202) \
134
+ V(NON_AUTHORITATIVE_INFORMATION, 203) \
135
+ V(NO_CONTENT, 204) \
136
+ V(RESET_CONTENT, 205) \
137
+ V(PARTIAL_CONTENT, 206) \
138
+ V(MULTI_STATUS, 207) \
139
+ V(ALREADY_REPORTED, 208) \
140
+ V(IM_USED, 226) \
141
+ V(MULTIPLE_CHOICES, 300) \
142
+ V(MOVED_PERMANENTLY, 301) \
143
+ V(FOUND, 302) \
144
+ V(SEE_OTHER, 303) \
145
+ V(NOT_MODIFIED, 304) \
146
+ V(USE_PROXY, 305) \
147
+ V(TEMPORARY_REDIRECT, 307) \
148
+ V(PERMANENT_REDIRECT, 308) \
149
+ V(BAD_REQUEST, 400) \
150
+ V(UNAUTHORIZED, 401) \
151
+ V(PAYMENT_REQUIRED, 402) \
152
+ V(FORBIDDEN, 403) \
153
+ V(NOT_FOUND, 404) \
154
+ V(METHOD_NOT_ALLOWED, 405) \
155
+ V(NOT_ACCEPTABLE, 406) \
156
+ V(PROXY_AUTHENTICATION_REQUIRED, 407) \
157
+ V(REQUEST_TIMEOUT, 408) \
158
+ V(CONFLICT, 409) \
159
+ V(GONE, 410) \
160
+ V(LENGTH_REQUIRED, 411) \
161
+ V(PRECONDITION_FAILED, 412) \
162
+ V(PAYLOAD_TOO_LARGE, 413) \
163
+ V(URI_TOO_LONG, 414) \
164
+ V(UNSUPPORTED_MEDIA_TYPE, 415) \
165
+ V(RANGE_NOT_SATISFIABLE, 416) \
166
+ V(EXPECTATION_FAILED, 417) \
167
+ V(TEAPOT, 418) \
168
+ V(MISDIRECTED_REQUEST, 421) \
169
+ V(UNPROCESSABLE_ENTITY, 422) \
170
+ V(LOCKED, 423) \
171
+ V(FAILED_DEPENDENCY, 424) \
172
+ V(TOO_EARLY, 425) \
173
+ V(UPGRADE_REQUIRED, 426) \
174
+ V(PRECONDITION_REQUIRED, 428) \
175
+ V(TOO_MANY_REQUESTS, 429) \
176
+ V(REQUEST_HEADER_FIELDS_TOO_LARGE, 431) \
177
+ V(UNAVAILABLE_FOR_LEGAL_REASONS, 451) \
178
+ V(INTERNAL_SERVER_ERROR, 500) \
179
+ V(NOT_IMPLEMENTED, 501) \
180
+ V(BAD_GATEWAY, 502) \
181
+ V(SERVICE_UNAVAILABLE, 503) \
182
+ V(GATEWAY_TIMEOUT, 504) \
183
+ V(HTTP_VERSION_NOT_SUPPORTED, 505) \
184
+ V(VARIANT_ALSO_NEGOTIATES, 506) \
185
+ V(INSUFFICIENT_STORAGE, 507) \
186
+ V(LOOP_DETECTED, 508) \
187
+ V(BANDWIDTH_LIMIT_EXCEEDED, 509) \
188
+ V(NOT_EXTENDED, 510) \
189
+ V(NETWORK_AUTHENTICATION_REQUIRED, 511)
190
+
191
+ enum http_status_codes {
192
+ #define V(name, code) HTTP_STATUS_##name = code,
193
+ HTTP_STATUS_CODES(V)
194
+ #undef V
195
+ };
196
+
197
+ // Unlike the HTTP/1 implementation, the HTTP/2 implementation is not limited
198
+ // to a fixed number of known supported HTTP methods. These constants, therefore
199
+ // are provided strictly as a convenience to users and are exposed via the
200
+ // require('node:http2').constants object.
201
+ #define HTTP_KNOWN_METHODS(V) \
202
+ V(ACL, "ACL") \
203
+ V(BASELINE_CONTROL, "BASELINE-CONTROL") \
204
+ V(BIND, "BIND") \
205
+ V(CHECKIN, "CHECKIN") \
206
+ V(CHECKOUT, "CHECKOUT") \
207
+ V(CONNECT, "CONNECT") \
208
+ V(COPY, "COPY") \
209
+ V(DELETE, "DELETE") \
210
+ V(GET, "GET") \
211
+ V(HEAD, "HEAD") \
212
+ V(LABEL, "LABEL") \
213
+ V(LINK, "LINK") \
214
+ V(LOCK, "LOCK") \
215
+ V(MERGE, "MERGE") \
216
+ V(MKACTIVITY, "MKACTIVITY") \
217
+ V(MKCALENDAR, "MKCALENDAR") \
218
+ V(MKCOL, "MKCOL") \
219
+ V(MKREDIRECTREF, "MKREDIRECTREF") \
220
+ V(MKWORKSPACE, "MKWORKSPACE") \
221
+ V(MOVE, "MOVE") \
222
+ V(OPTIONS, "OPTIONS") \
223
+ V(ORDERPATCH, "ORDERPATCH") \
224
+ V(PATCH, "PATCH") \
225
+ V(POST, "POST") \
226
+ V(PRI, "PRI") \
227
+ V(PROPFIND, "PROPFIND") \
228
+ V(PROPPATCH, "PROPPATCH") \
229
+ V(PUT, "PUT") \
230
+ V(REBIND, "REBIND") \
231
+ V(REPORT, "REPORT") \
232
+ V(SEARCH, "SEARCH") \
233
+ V(TRACE, "TRACE") \
234
+ V(UNBIND, "UNBIND") \
235
+ V(UNCHECKOUT, "UNCHECKOUT") \
236
+ V(UNLINK, "UNLINK") \
237
+ V(UNLOCK, "UNLOCK") \
238
+ V(UPDATE, "UPDATE") \
239
+ V(UPDATEREDIRECTREF, "UPDATEREDIRECTREF") \
240
+ V(VERSION_CONTROL, "VERSION-CONTROL")
241
+
242
+ // NgHeaders takes as input a block of headers provided by the
243
+ // JavaScript side (see http2's buildNgHeaderString function) and
244
+ // converts it into a array of ng header structs. This is done
245
+ // generically to handle both http/2 and (in the future) http/3,
246
+ // which use nearly identical structs. The template parameter
247
+ // takes a Traits type that defines the ng header struct and
248
+ // the kNoneFlag value. See Http2HeaderTraits in node_http2.h
249
+ // for an example.
250
+ template <typename T>
251
+ class NgHeaders {
252
+ public:
253
+ typedef typename T::nv_t nv_t;
254
+ inline NgHeaders(Environment* env, v8::Local<v8::Array> headers);
255
+ ~NgHeaders() = default;
256
+
257
+ const nv_t* operator*() const {
258
+ return reinterpret_cast<const nv_t*>(*buf_);
259
+ }
260
+
261
+ const nv_t* data() const {
262
+ return reinterpret_cast<const nv_t*>(*buf_);
263
+ }
264
+
265
+ size_t length() const {
266
+ return count_;
267
+ }
268
+
269
+ private:
270
+ size_t count_;
271
+ MaybeStackBuffer<char, 3000> buf_;
272
+ };
273
+
274
+ // The ng libraries use nearly identical
275
+ // reference counted structures for retaining header name and value
276
+ // information in memory until the application is done with it.
277
+ // The NgRcBufPointer is an intelligent pointer capable of working
278
+ // with either type, handling the ref counting increment and
279
+ // decrement as appropriate. The Template takes a single Traits
280
+ // type that provides the rc buffer and vec type, as well as
281
+ // implementations for multiple static functions.
282
+ // See Http2RcBufferPointerTraits in node_http2.h for an example.
283
+ template <typename T>
284
+ class NgRcBufPointer : public MemoryRetainer {
285
+ public:
286
+ typedef typename T::rcbuf_t rcbuf_t;
287
+ typedef typename T::vector_t vector_t;
288
+
289
+ NgRcBufPointer() = default;
290
+
291
+ explicit NgRcBufPointer(rcbuf_t* buf) {
292
+ reset(buf);
293
+ }
294
+
295
+ template <typename B>
296
+ NgRcBufPointer(const NgRcBufPointer<B>& other) {
297
+ reset(other.get());
298
+ }
299
+
300
+ NgRcBufPointer(const NgRcBufPointer& other) {
301
+ reset(other.get());
302
+ }
303
+
304
+ template <typename B>
305
+ NgRcBufPointer& operator=(const NgRcBufPointer<B>& other) {
306
+ if (other.get() == get()) return *this;
307
+ this->~NgRcBufPointer();
308
+ return *new (this) NgRcBufPointer(other);
309
+ }
310
+
311
+ NgRcBufPointer& operator=(const NgRcBufPointer& other) {
312
+ if (other.get() == get()) return *this;
313
+ this->~NgRcBufPointer();
314
+ return *new (this) NgRcBufPointer(other);
315
+ }
316
+
317
+ NgRcBufPointer(NgRcBufPointer&& other) {
318
+ this->~NgRcBufPointer();
319
+ buf_ = other.buf_;
320
+ other.buf_ = nullptr;
321
+ }
322
+
323
+ NgRcBufPointer& operator=(NgRcBufPointer&& other) {
324
+ this->~NgRcBufPointer();
325
+ return *new (this) NgRcBufPointer(std::move(other));
326
+ }
327
+
328
+ ~NgRcBufPointer() {
329
+ reset();
330
+ }
331
+
332
+ // Returns the underlying ngvec for this rcbuf
333
+ uint8_t* data() const {
334
+ vector_t v = T::get_vec(buf_);
335
+ return v.base;
336
+ }
337
+
338
+ size_t len() const {
339
+ vector_t v = T::get_vec(buf_);
340
+ return v.len;
341
+ }
342
+
343
+ std::string str() const {
344
+ return std::string(reinterpret_cast<const char*>(data()), len());
345
+ }
346
+
347
+ void reset(rcbuf_t* ptr = nullptr, bool internalizable = false) {
348
+ if (buf_ == ptr)
349
+ return;
350
+
351
+ if (buf_ != nullptr)
352
+ T::dec(buf_);
353
+
354
+ buf_ = ptr;
355
+
356
+ if (ptr != nullptr) {
357
+ T::inc(ptr);
358
+ internalizable_ = internalizable;
359
+ }
360
+ }
361
+
362
+ rcbuf_t* get() const { return buf_; }
363
+ rcbuf_t& operator*() const { return *get(); }
364
+ rcbuf_t* operator->() const { return buf_; }
365
+ operator bool() const { return buf_ != nullptr; }
366
+ bool IsStatic() const { return T::is_static(buf_) != 0; }
367
+ void SetInternalizable() { internalizable_ = true; }
368
+ bool IsInternalizable() const { return internalizable_; }
369
+
370
+ static inline bool IsZeroLength(rcbuf_t* buf) {
371
+ if (buf == nullptr)
372
+ return true;
373
+ vector_t b = T::get_vec(buf);
374
+ return b.len == 0;
375
+ }
376
+
377
+ void MemoryInfo(MemoryTracker* tracker) const override {
378
+ tracker->TrackFieldWithSize("buf", len(), "buf");
379
+ }
380
+
381
+ SET_MEMORY_INFO_NAME(NgRcBufPointer)
382
+ SET_SELF_SIZE(NgRcBufPointer)
383
+
384
+ class External : public v8::String::ExternalOneByteStringResource {
385
+ public:
386
+ explicit External(const NgRcBufPointer<T>& ptr) : ptr_(ptr) {}
387
+
388
+ const char* data() const override {
389
+ return const_cast<const char*>(reinterpret_cast<char*>(ptr_.data()));
390
+ }
391
+
392
+ size_t length() const override {
393
+ return ptr_.len();
394
+ }
395
+
396
+ static inline
397
+ v8::MaybeLocal<v8::String> GetInternalizedString(
398
+ Environment* env,
399
+ const NgRcBufPointer<T>& ptr) {
400
+ return v8::String::NewFromOneByte(
401
+ env->isolate(),
402
+ ptr.data(),
403
+ v8::NewStringType::kInternalized,
404
+ ptr.len());
405
+ }
406
+
407
+ template <typename Allocator>
408
+ static v8::MaybeLocal<v8::String> New(
409
+ Allocator* allocator,
410
+ NgRcBufPointer<T> ptr) {
411
+ Environment* env = allocator->env();
412
+ if (ptr.IsStatic()) {
413
+ auto& static_str_map = env->isolate_data()->static_str_map;
414
+ const char* header_name = reinterpret_cast<const char*>(ptr.data());
415
+ v8::Eternal<v8::String>& eternal = static_str_map[header_name];
416
+ if (eternal.IsEmpty()) {
417
+ v8::Local<v8::String> str;
418
+ if (!GetInternalizedString(env, ptr).ToLocal(&str)) {
419
+ ptr.reset();
420
+ return {};
421
+ }
422
+ eternal.Set(env->isolate(), str);
423
+ return str;
424
+ }
425
+ return eternal.Get(env->isolate());
426
+ }
427
+
428
+ size_t len = ptr.len();
429
+
430
+ if (len == 0) {
431
+ ptr.reset();
432
+ return v8::String::Empty(env->isolate());
433
+ }
434
+
435
+ if (ptr.IsInternalizable() && len < 64) {
436
+ v8::MaybeLocal<v8::String> ret = GetInternalizedString(env, ptr);
437
+ ptr.reset();
438
+ return ret;
439
+ }
440
+
441
+ allocator->StopTrackingMemory(ptr.get());
442
+ External* h_str = new External(std::move(ptr));
443
+ v8::MaybeLocal<v8::String> str =
444
+ v8::String::NewExternalOneByte(env->isolate(), h_str);
445
+ if (str.IsEmpty())
446
+ delete h_str;
447
+
448
+ return str;
449
+ }
450
+
451
+ private:
452
+ NgRcBufPointer<T> ptr_;
453
+ };
454
+
455
+ private:
456
+ rcbuf_t* buf_ = nullptr;
457
+ bool internalizable_ = false;
458
+ };
459
+
460
+ template <typename allocator_t>
461
+ struct NgHeaderBase : public MemoryRetainer {
462
+ virtual v8::MaybeLocal<v8::String> GetName(allocator_t* allocator) const = 0;
463
+ virtual v8::MaybeLocal<v8::String> GetValue(allocator_t* allocator) const = 0;
464
+ virtual std::string name() const = 0;
465
+ virtual std::string value() const = 0;
466
+ virtual size_t length() const = 0;
467
+ virtual uint8_t flags() const = 0;
468
+ virtual std::string ToString() const;
469
+ };
470
+
471
+ // The ng libraries use nearly identical structs to represent
472
+ // received http headers. The NgHeader class wraps those in a
473
+ // consistent way and allows converting the name and value to
474
+ // v8 strings. The template is given a Traits type that provides
475
+ // the NgRcBufPointer type, the NgLibMemoryManager to use for
476
+ // memory tracking, and implementation of static utility functions.
477
+ // See Http2HeaderTraits in node_http2.h for an example.
478
+ template <typename T>
479
+ class NgHeader final : public NgHeaderBase<typename T::allocator_t> {
480
+ public:
481
+ typedef typename T::rcbufferpointer_t rcbufferpointer_t;
482
+ typedef typename T::rcbufferpointer_t::rcbuf_t rcbuf_t;
483
+ typedef typename T::allocator_t allocator_t;
484
+
485
+ inline static bool IsZeroLength(rcbuf_t* name, rcbuf_t* value);
486
+ inline static bool IsZeroLength(int32_t token, rcbuf_t* name, rcbuf_t* value);
487
+ inline NgHeader(
488
+ Environment* env,
489
+ rcbuf_t* name,
490
+ rcbuf_t* value,
491
+ uint8_t flags);
492
+ inline NgHeader(
493
+ Environment* env,
494
+ int32_t token,
495
+ rcbuf_t* name,
496
+ rcbuf_t* value,
497
+ uint8_t flags);
498
+ inline NgHeader(NgHeader<T>&& other) noexcept;
499
+
500
+ // Calling GetName and GetValue will have the effect of releasing
501
+ // control over the reference counted buffer from this NgHeader
502
+ // object to the v8 string. Once the v8 string is garbage collected,
503
+ // the reference counter will be decremented.
504
+
505
+ inline v8::MaybeLocal<v8::String> GetName(
506
+ allocator_t* allocator) const override;
507
+ inline v8::MaybeLocal<v8::String> GetValue(
508
+ allocator_t* allocator) const override;
509
+
510
+ inline std::string name() const override;
511
+ inline std::string value() const override;
512
+ inline size_t length() const override;
513
+ inline uint8_t flags() const override;
514
+
515
+ void MemoryInfo(MemoryTracker* tracker) const override;
516
+
517
+ SET_MEMORY_INFO_NAME(NgHeader)
518
+ SET_SELF_SIZE(NgHeader)
519
+
520
+ private:
521
+ Environment* env_;
522
+ rcbufferpointer_t name_;
523
+ rcbufferpointer_t value_;
524
+ int32_t token_ = -1;
525
+ uint8_t flags_ = 0;
526
+ };
527
+
528
+ inline size_t GetServerMaxHeaderPairs(size_t max_header_pairs);
529
+ inline size_t GetClientMaxHeaderPairs(size_t max_header_pairs);
530
+
531
+ } // namespace node
532
+
533
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
534
+
535
+ #endif // SRC_NODE_HTTP_COMMON_H_
@@ -0,0 +1,132 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_NODE_I18N_H_
23
+ #define SRC_NODE_I18N_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #if defined(NODE_HAVE_I18N_SUPPORT)
28
+
29
+ #include "base_object.h"
30
+ #include "env.h"
31
+ #include "util.h"
32
+ #include "v8.h"
33
+
34
+ #include <unicode/ucnv.h>
35
+
36
+ #include <string>
37
+
38
+ namespace node {
39
+ namespace i18n {
40
+
41
+ bool InitializeICUDirectory(const std::string& path, std::string* error);
42
+
43
+ void SetDefaultTimeZone(const char* tzid);
44
+
45
+ enum class idna_mode {
46
+ // Default mode for maximum compatibility.
47
+ kDefault,
48
+ // Ignore all errors in IDNA conversion, if possible.
49
+ kLenient,
50
+ // Enforce STD3 rules (UseSTD3ASCIIRules) and DNS length restrictions
51
+ // (VerifyDnsLength). Corresponds to `beStrict` flag in the "domain to ASCII"
52
+ // algorithm.
53
+ kStrict
54
+ };
55
+
56
+ struct ConverterDeleter {
57
+ void operator()(UConverter* pointer) const { ucnv_close(pointer); }
58
+ };
59
+ using ConverterPointer = std::unique_ptr<UConverter, ConverterDeleter>;
60
+
61
+ class Converter {
62
+ public:
63
+ explicit Converter(const char* name, const char* sub = nullptr);
64
+ explicit Converter(UConverter* converter, const char* sub = nullptr);
65
+
66
+ UConverter* conv() const { return conv_.get(); }
67
+
68
+ size_t max_char_size() const;
69
+ size_t min_char_size() const;
70
+ void reset();
71
+ void set_subst_chars(const char* sub = nullptr);
72
+
73
+ private:
74
+ ConverterPointer conv_;
75
+ };
76
+
77
+ class ConverterObject : public BaseObject, Converter {
78
+ public:
79
+ enum ConverterFlags {
80
+ CONVERTER_FLAGS_FLUSH = 0x1,
81
+ CONVERTER_FLAGS_FATAL = 0x2,
82
+ CONVERTER_FLAGS_IGNORE_BOM = 0x4,
83
+ CONVERTER_FLAGS_UNICODE = 0x8,
84
+ CONVERTER_FLAGS_BOM_SEEN = 0x10,
85
+ };
86
+
87
+ static void Create(const v8::FunctionCallbackInfo<v8::Value>& args);
88
+ static void Decode(const v8::FunctionCallbackInfo<v8::Value>& args);
89
+ static void Has(const v8::FunctionCallbackInfo<v8::Value>& args);
90
+
91
+ SET_NO_MEMORY_INFO()
92
+ SET_MEMORY_INFO_NAME(ConverterObject)
93
+ SET_SELF_SIZE(ConverterObject)
94
+
95
+ protected:
96
+ ConverterObject(Environment* env,
97
+ v8::Local<v8::Object> wrap,
98
+ UConverter* converter,
99
+ int flags,
100
+ const char* sub = nullptr);
101
+
102
+ void set_bom_seen(bool seen) {
103
+ if (seen)
104
+ flags_ |= CONVERTER_FLAGS_BOM_SEEN;
105
+ else
106
+ flags_ &= ~CONVERTER_FLAGS_BOM_SEEN;
107
+ }
108
+
109
+ bool bom_seen() const {
110
+ return (flags_ & CONVERTER_FLAGS_BOM_SEEN) == CONVERTER_FLAGS_BOM_SEEN;
111
+ }
112
+
113
+ bool unicode() const {
114
+ return (flags_ & CONVERTER_FLAGS_UNICODE) == CONVERTER_FLAGS_UNICODE;
115
+ }
116
+
117
+ bool ignore_bom() const {
118
+ return (flags_ & CONVERTER_FLAGS_IGNORE_BOM) == CONVERTER_FLAGS_IGNORE_BOM;
119
+ }
120
+
121
+ private:
122
+ int flags_ = 0;
123
+ };
124
+
125
+ } // namespace i18n
126
+ } // namespace node
127
+
128
+ #endif // NODE_HAVE_I18N_SUPPORT
129
+
130
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
131
+
132
+ #endif // SRC_NODE_I18N_H_