aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-07 00:38:18 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-07 00:38:18 -0700
commit7ab8d832fb847e9d2850f9b076174994e3505c0d (patch)
tree0a4e1b2ad0e38160efb62a84f358dd49a319c63f
parent0ecdbf4793f19b3244a3e099bd47e3e81e993811 (diff)
downloadbun-7ab8d832fb847e9d2850f9b076174994e3505c0d.tar.gz
bun-7ab8d832fb847e9d2850f9b076174994e3505c0d.tar.zst
bun-7ab8d832fb847e9d2850f9b076174994e3505c0d.zip
Add obscure HTTP methods (#3553)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
-rw-r--r--src/bun.js/webcore/request.zig14
-rw-r--r--src/http/method.zig88
2 files changed, 85 insertions, 17 deletions
diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig
index 231f0deed..cff2ef2f3 100644
--- a/src/bun.js/webcore/request.zig
+++ b/src/bun.js/webcore/request.zig
@@ -255,19 +255,7 @@ pub const Request = struct {
this: *Request,
globalThis: *JSC.JSGlobalObject,
) callconv(.C) JSC.JSValue {
- const string_contents: string = switch (this.method) {
- .GET => "GET",
- .HEAD => "HEAD",
- .PATCH => "PATCH",
- .PUT => "PUT",
- .POST => "POST",
- .OPTIONS => "OPTIONS",
- .CONNECT => "CONNECT",
- .TRACE => "TRACE",
- .DELETE => "DELETE",
- };
-
- return ZigString.init(string_contents).toValueGC(globalThis);
+ return bun.String.static(@tagName(this.method)).toJSConst(globalThis);
}
pub fn getMode(
diff --git a/src/http/method.zig b/src/http/method.zig
index 4a3d45133..d2668f1b7 100644
--- a/src/http/method.zig
+++ b/src/http/method.zig
@@ -11,15 +11,42 @@ const C = bun.C;
const std = @import("std");
pub const Method = enum {
+ ACL,
+ BIND,
+ CHECKOUT,
+ CONNECT,
+ COPY,
+ DELETE,
GET,
HEAD,
+ LINK,
+ LOCK,
+ @"M-SEARCH",
+ MERGE,
+ MKACTIVITY,
+ MKCALENDAR,
+ MKCOL,
+ MOVE,
+ NOTIFY,
+ OPTIONS,
PATCH,
- PUT,
POST,
- OPTIONS,
- CONNECT,
+ PROPFIND,
+ PROPPATCH,
+ PURGE,
+ PUT,
+ /// https://httpwg.org/http-extensions/draft-ietf-httpbis-safe-method-w-body.html
+ QUERY,
+ REBIND,
+ REPORT,
+ SEARCH,
+ SOURCE,
+ SUBSCRIBE,
TRACE,
- DELETE,
+ UNBIND,
+ UNLINK,
+ UNLOCK,
+ UNSUBSCRIBE,
const with_body: std.enums.EnumSet(Method) = brk: {
var values = std.enums.EnumSet(Method).initFull();
@@ -47,24 +74,77 @@ pub const Method = enum {
}
const Map = bun.ComptimeStringMap(Method, .{
+ .{ "ACL", Method.ACL },
+ .{ "BIND", Method.BIND },
+ .{ "CHECKOUT", Method.CHECKOUT },
.{ "CONNECT", Method.CONNECT },
+ .{ "COPY", Method.COPY },
.{ "DELETE", Method.DELETE },
.{ "GET", Method.GET },
.{ "HEAD", Method.HEAD },
+ .{ "LINK", Method.LINK },
+ .{ "LOCK", Method.LOCK },
+ .{ "M-SEARCH", Method.@"M-SEARCH" },
+ .{ "MERGE", Method.MERGE },
+ .{ "MKACTIVITY", Method.MKACTIVITY },
+ .{ "MKCALENDAR", Method.MKCALENDAR },
+ .{ "MKCOL", Method.MKCOL },
+ .{ "MOVE", Method.MOVE },
+ .{ "NOTIFY", Method.NOTIFY },
.{ "OPTIONS", Method.OPTIONS },
.{ "PATCH", Method.PATCH },
.{ "POST", Method.POST },
+ .{ "PROPFIND", Method.PROPFIND },
+ .{ "PROPPATCH", Method.PROPPATCH },
+ .{ "PURGE", Method.PURGE },
.{ "PUT", Method.PUT },
+ .{ "QUERY", Method.QUERY },
+ .{ "REBIND", Method.REBIND },
+ .{ "REPORT", Method.REPORT },
+ .{ "SEARCH", Method.SEARCH },
+ .{ "SOURCE", Method.SOURCE },
+ .{ "SUBSCRIBE", Method.SUBSCRIBE },
.{ "TRACE", Method.TRACE },
+ .{ "UNBIND", Method.UNBIND },
+ .{ "UNLINK", Method.UNLINK },
+ .{ "UNLOCK", Method.UNLOCK },
+ .{ "UNSUBSCRIBE", Method.UNSUBSCRIBE },
+
+ .{ "acl", Method.ACL },
+ .{ "bind", Method.BIND },
+ .{ "checkout", Method.CHECKOUT },
.{ "connect", Method.CONNECT },
+ .{ "copy", Method.COPY },
.{ "delete", Method.DELETE },
.{ "get", Method.GET },
.{ "head", Method.HEAD },
+ .{ "link", Method.LINK },
+ .{ "lock", Method.LOCK },
+ .{ "m-search", Method.@"M-SEARCH" },
+ .{ "merge", Method.MERGE },
+ .{ "mkactivity", Method.MKACTIVITY },
+ .{ "mkcalendar", Method.MKCALENDAR },
+ .{ "mkcol", Method.MKCOL },
+ .{ "move", Method.MOVE },
+ .{ "notify", Method.NOTIFY },
.{ "options", Method.OPTIONS },
.{ "patch", Method.PATCH },
.{ "post", Method.POST },
+ .{ "propfind", Method.PROPFIND },
+ .{ "proppatch", Method.PROPPATCH },
+ .{ "purge", Method.PURGE },
.{ "put", Method.PUT },
+ .{ "query", Method.QUERY },
+ .{ "rebind", Method.REBIND },
+ .{ "report", Method.REPORT },
+ .{ "search", Method.SEARCH },
+ .{ "source", Method.SOURCE },
+ .{ "subscribe", Method.SUBSCRIBE },
.{ "trace", Method.TRACE },
+ .{ "unbind", Method.UNBIND },
+ .{ "unlink", Method.UNLINK },
+ .{ "unlock", Method.UNLOCK },
+ .{ "unsubscribe", Method.UNSUBSCRIBE },
});
pub fn which(str: []const u8) ?Method {