diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-09-12 01:52:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 00:52:08 +0000 |
commit | f794781ffba941085343b95dd5a9c1ad74a322a2 (patch) | |
tree | 395ad9feae6a3bf4078d0f03053eed8ce85b3396 /ext/node/polyfills/http.ts | |
parent | 8476bbff9af28408bc6a9b0a7b2303cb3803422e (diff) |
feat(ext/node): expose ES modules for _ modules (#25588)
Exposes following modules:
- `"node:_http_agent"`
- `"node:_http_common"`
- `"node:_http_outgoing"`
- `"node:_http_server"`
- `"node:_stream_duplex"`
- `"node:_stream_passthrough"`
- `"node:_stream_readable"`
- `"node:_stream_transform"`
- `"node:_stream_writable"`
- `"node:_tls_common"`
- `"node:_tls_wrap"`
Diffstat (limited to 'ext/node/polyfills/http.ts')
-rw-r--r-- | ext/node/polyfills/http.ts | 180 |
1 files changed, 6 insertions, 174 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index a9eee0019..f3f6f86ed 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -36,16 +36,16 @@ import { Writable as NodeWritable, } from "node:stream"; import { + kUniqueHeaders, OutgoingMessage, parseUniqueHeadersOption, validateHeaderName, validateHeaderValue, -} from "ext:deno_node/_http_outgoing.ts"; +} from "node:_http_outgoing"; import { ok as assert } from "node:assert"; import { kOutHeaders } from "ext:deno_node/internal/http.ts"; -import { _checkIsHttpToken as checkIsHttpToken } from "ext:deno_node/_http_common.ts"; -import { Agent, globalAgent } from "ext:deno_node/_http_agent.mjs"; -// import { chunkExpression as RE_TE_CHUNKED } from "ext:deno_node/_http_common.ts"; +import { _checkIsHttpToken as checkIsHttpToken } from "node:_http_common"; +import { Agent, globalAgent } from "node:_http_agent"; import { urlToHttpOptions } from "ext:deno_node/internal/url.ts"; import { kEmptyObject } from "ext:deno_node/internal/util.mjs"; import { constants, TCP } from "ext:deno_node/internal_binding/tcp_wrap.ts"; @@ -67,178 +67,12 @@ import { timerId } from "ext:deno_web/03_abort_signal.js"; import { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js"; import { resourceForReadableStream } from "ext:deno_web/06_streams.js"; import { TcpConn } from "ext:deno_net/01_net.js"; +import { STATUS_CODES } from "node:_http_server"; +import { methods as METHODS } from "node:_http_common"; const { internalRidSymbol } = core; const { ArrayIsArray } = primordials; -enum STATUS_CODES { - /** RFC 7231, 6.2.1 */ - Continue = 100, - /** RFC 7231, 6.2.2 */ - SwitchingProtocols = 101, - /** RFC 2518, 10.1 */ - Processing = 102, - /** RFC 8297 **/ - EarlyHints = 103, - - /** RFC 7231, 6.3.1 */ - OK = 200, - /** RFC 7231, 6.3.2 */ - Created = 201, - /** RFC 7231, 6.3.3 */ - Accepted = 202, - /** RFC 7231, 6.3.4 */ - NonAuthoritativeInfo = 203, - /** RFC 7231, 6.3.5 */ - NoContent = 204, - /** RFC 7231, 6.3.6 */ - ResetContent = 205, - /** RFC 7233, 4.1 */ - PartialContent = 206, - /** RFC 4918, 11.1 */ - MultiStatus = 207, - /** RFC 5842, 7.1 */ - AlreadyReported = 208, - /** RFC 3229, 10.4.1 */ - IMUsed = 226, - - /** RFC 7231, 6.4.1 */ - MultipleChoices = 300, - /** RFC 7231, 6.4.2 */ - MovedPermanently = 301, - /** RFC 7231, 6.4.3 */ - Found = 302, - /** RFC 7231, 6.4.4 */ - SeeOther = 303, - /** RFC 7232, 4.1 */ - NotModified = 304, - /** RFC 7231, 6.4.5 */ - UseProxy = 305, - /** RFC 7231, 6.4.7 */ - TemporaryRedirect = 307, - /** RFC 7538, 3 */ - PermanentRedirect = 308, - - /** RFC 7231, 6.5.1 */ - BadRequest = 400, - /** RFC 7235, 3.1 */ - Unauthorized = 401, - /** RFC 7231, 6.5.2 */ - PaymentRequired = 402, - /** RFC 7231, 6.5.3 */ - Forbidden = 403, - /** RFC 7231, 6.5.4 */ - NotFound = 404, - /** RFC 7231, 6.5.5 */ - MethodNotAllowed = 405, - /** RFC 7231, 6.5.6 */ - NotAcceptable = 406, - /** RFC 7235, 3.2 */ - ProxyAuthRequired = 407, - /** RFC 7231, 6.5.7 */ - RequestTimeout = 408, - /** RFC 7231, 6.5.8 */ - Conflict = 409, - /** RFC 7231, 6.5.9 */ - Gone = 410, - /** RFC 7231, 6.5.10 */ - LengthRequired = 411, - /** RFC 7232, 4.2 */ - PreconditionFailed = 412, - /** RFC 7231, 6.5.11 */ - RequestEntityTooLarge = 413, - /** RFC 7231, 6.5.12 */ - RequestURITooLong = 414, - /** RFC 7231, 6.5.13 */ - UnsupportedMediaType = 415, - /** RFC 7233, 4.4 */ - RequestedRangeNotSatisfiable = 416, - /** RFC 7231, 6.5.14 */ - ExpectationFailed = 417, - /** RFC 7168, 2.3.3 */ - Teapot = 418, - /** RFC 7540, 9.1.2 */ - MisdirectedRequest = 421, - /** RFC 4918, 11.2 */ - UnprocessableEntity = 422, - /** RFC 4918, 11.3 */ - Locked = 423, - /** RFC 4918, 11.4 */ - FailedDependency = 424, - /** RFC 8470, 5.2 */ - TooEarly = 425, - /** RFC 7231, 6.5.15 */ - UpgradeRequired = 426, - /** RFC 6585, 3 */ - PreconditionRequired = 428, - /** RFC 6585, 4 */ - TooManyRequests = 429, - /** RFC 6585, 5 */ - RequestHeaderFieldsTooLarge = 431, - /** RFC 7725, 3 */ - UnavailableForLegalReasons = 451, - - /** RFC 7231, 6.6.1 */ - InternalServerError = 500, - /** RFC 7231, 6.6.2 */ - NotImplemented = 501, - /** RFC 7231, 6.6.3 */ - BadGateway = 502, - /** RFC 7231, 6.6.4 */ - ServiceUnavailable = 503, - /** RFC 7231, 6.6.5 */ - GatewayTimeout = 504, - /** RFC 7231, 6.6.6 */ - HTTPVersionNotSupported = 505, - /** RFC 2295, 8.1 */ - VariantAlsoNegotiates = 506, - /** RFC 4918, 11.5 */ - InsufficientStorage = 507, - /** RFC 5842, 7.2 */ - LoopDetected = 508, - /** RFC 2774, 7 */ - NotExtended = 510, - /** RFC 6585, 6 */ - NetworkAuthenticationRequired = 511, -} - -const METHODS = [ - "ACL", - "BIND", - "CHECKOUT", - "CONNECT", - "COPY", - "DELETE", - "GET", - "HEAD", - "LINK", - "LOCK", - "M-SEARCH", - "MERGE", - "MKACTIVITY", - "MKCALENDAR", - "MKCOL", - "MOVE", - "NOTIFY", - "OPTIONS", - "PATCH", - "POST", - "PROPFIND", - "PROPPATCH", - "PURGE", - "PUT", - "REBIND", - "REPORT", - "SEARCH", - "SOURCE", - "SUBSCRIBE", - "TRACE", - "UNBIND", - "UNLINK", - "UNLOCK", - "UNSUBSCRIBE", -]; - type Chunk = string | Buffer | Uint8Array; const ENCODER = new TextEncoder(); @@ -283,8 +117,6 @@ function validateHost(host, name) { const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/; const kError = Symbol("kError"); -const kUniqueHeaders = Symbol("kUniqueHeaders"); - class FakeSocket extends EventEmitter { constructor( opts: { |