summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal_binding/http_parser.ts
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /ext/node/polyfills/internal_binding/http_parser.ts
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
Diffstat (limited to 'ext/node/polyfills/internal_binding/http_parser.ts')
-rw-r--r--ext/node/polyfills/internal_binding/http_parser.ts160
1 files changed, 160 insertions, 0 deletions
diff --git a/ext/node/polyfills/internal_binding/http_parser.ts b/ext/node/polyfills/internal_binding/http_parser.ts
new file mode 100644
index 000000000..bad10d985
--- /dev/null
+++ b/ext/node/polyfills/internal_binding/http_parser.ts
@@ -0,0 +1,160 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+import { primordials } from "ext:core/mod.js";
+import { AsyncWrap } from "ext:deno_node/internal_binding/async_wrap.ts";
+
+const {
+ ObjectDefineProperty,
+ ObjectEntries,
+ ObjectSetPrototypeOf,
+ SafeArrayIterator,
+} = primordials;
+
+export const methods = [
+ "DELETE",
+ "GET",
+ "HEAD",
+ "POST",
+ "PUT",
+ "CONNECT",
+ "OPTIONS",
+ "TRACE",
+ "COPY",
+ "LOCK",
+ "MKCOL",
+ "MOVE",
+ "PROPFIND",
+ "PROPPATCH",
+ "SEARCH",
+ "UNLOCK",
+ "BIND",
+ "REBIND",
+ "UNBIND",
+ "ACL",
+ "REPORT",
+ "MKACTIVITY",
+ "CHECKOUT",
+ "MERGE",
+ "M-SEARCH",
+ "NOTIFY",
+ "SUBSCRIBE",
+ "UNSUBSCRIBE",
+ "PATCH",
+ "PURGE",
+ "MKCALENDAR",
+ "LINK",
+ "UNLINK",
+ "SOURCE",
+ "QUERY",
+];
+
+export const allMethods = [
+ "DELETE",
+ "GET",
+ "HEAD",
+ "POST",
+ "PUT",
+ "CONNECT",
+ "OPTIONS",
+ "TRACE",
+ "COPY",
+ "LOCK",
+ "MKCOL",
+ "MOVE",
+ "PROPFIND",
+ "PROPPATCH",
+ "SEARCH",
+ "UNLOCK",
+ "BIND",
+ "REBIND",
+ "UNBIND",
+ "ACL",
+ "REPORT",
+ "MKACTIVITY",
+ "CHECKOUT",
+ "MERGE",
+ "M-SEARCH",
+ "NOTIFY",
+ "SUBSCRIBE",
+ "UNSUBSCRIBE",
+ "PATCH",
+ "PURGE",
+ "MKCALENDAR",
+ "LINK",
+ "UNLINK",
+ "SOURCE",
+ "PRI",
+ "DESCRIBE",
+ "ANNOUNCE",
+ "SETUP",
+ "PLAY",
+ "PAUSE",
+ "TEARDOWN",
+ "GET_PARAMETER",
+ "SET_PARAMETER",
+ "REDIRECT",
+ "RECORD",
+ "FLUSH",
+ "QUERY",
+];
+
+export function HTTPParser() {
+}
+
+ObjectSetPrototypeOf(HTTPParser.prototype, AsyncWrap.prototype);
+
+function defineProps(obj: object, props: Record<string, unknown>) {
+ for (const entry of new SafeArrayIterator(ObjectEntries(props))) {
+ ObjectDefineProperty(obj, entry[0], {
+ __proto__: null,
+ value: entry[1],
+ enumerable: true,
+ writable: true,
+ configurable: true,
+ });
+ }
+}
+
+defineProps(HTTPParser, {
+ REQUEST: 1,
+ RESPONSE: 2,
+ kOnMessageBegin: 0,
+ kOnHeaders: 1,
+ kOnHeadersComplete: 2,
+ kOnBody: 3,
+ kOnMessageComplete: 4,
+ kOnExecute: 5,
+ kOnTimeout: 6,
+ kLenientNone: 0,
+ kLenientHeaders: 1,
+ kLenientChunkedLength: 2,
+ kLenientKeepAlive: 4,
+ kLenientTransferEncoding: 8,
+ kLenientVersion: 16,
+ kLenientDataAfterClose: 32,
+ kLenientOptionalLFAfterCR: 64,
+ kLenientOptionalCRLFAfterChunk: 128,
+ kLenientOptionalCRBeforeLF: 256,
+ kLenientSpacesAfterChunkSize: 512,
+ kLenientAll: 1023,
+});