aboutsummaryrefslogtreecommitdiff
path: root/src/http/method.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-10-13 00:27:35 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-10-13 00:27:35 -0700
commit88a5e2d34d25c3ac3d13a432bbd85daa075c4bcb (patch)
tree53e40562b7bbe006304daa341a5ce3dfbdeca81e /src/http/method.zig
parentafc346d6f125a41fb6ff823d04d3ffd85ab36dcd (diff)
downloadbun-88a5e2d34d25c3ac3d13a432bbd85daa075c4bcb.tar.gz
bun-88a5e2d34d25c3ac3d13a432bbd85daa075c4bcb.tar.zst
bun-88a5e2d34d25c3ac3d13a432bbd85daa075c4bcb.zip
Add TLS 1.3 support, improve fetch() HTTPS performance
Diffstat (limited to 'src/http/method.zig')
-rw-r--r--src/http/method.zig49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/http/method.zig b/src/http/method.zig
new file mode 100644
index 000000000..f306e522e
--- /dev/null
+++ b/src/http/method.zig
@@ -0,0 +1,49 @@
+usingnamespace @import("../global.zig");
+
+pub const Method = enum {
+ GET,
+ HEAD,
+ PATCH,
+ PUT,
+ POST,
+ OPTIONS,
+ CONNECT,
+ TRACE,
+
+ pub fn which(str: []const u8) ?Method {
+ if (str.len < 3) {
+ return null;
+ }
+ const Match = strings.ExactSizeMatcher(2);
+ // we already did the length check
+ switch (Match.match(str[0..2])) {
+ Match.case("GE"), Match.case("ge") => {
+ return .GET;
+ },
+ Match.case("HE"), Match.case("he") => {
+ return .HEAD;
+ },
+ Match.case("PA"), Match.case("pa") => {
+ return .PATCH;
+ },
+ Match.case("PO"), Match.case("po") => {
+ return .POST;
+ },
+ Match.case("PU"), Match.case("pu") => {
+ return .PUT;
+ },
+ Match.case("OP"), Match.case("op") => {
+ return .OPTIONS;
+ },
+ Match.case("CO"), Match.case("co") => {
+ return .CONNECT;
+ },
+ Match.case("TR"), Match.case("tr") => {
+ return .TRACE;
+ },
+ else => {
+ return null;
+ },
+ }
+ }
+};