diff options
author | 2022-03-01 22:19:15 -0800 | |
---|---|---|
committer | 2022-03-01 22:19:15 -0800 | |
commit | 78cae049d2c8f7fa4f7cde8ed5b8895b3e32b5fc (patch) | |
tree | 0998a2e0787b4e5dac8c0ecb0a333d91232863d5 /src/http/method.zig | |
parent | 7b4f239d33f2c9641350ce32cede2141e3075c72 (diff) | |
download | bun-78cae049d2c8f7fa4f7cde8ed5b8895b3e32b5fc.tar.gz bun-78cae049d2c8f7fa4f7cde8ed5b8895b3e32b5fc.tar.zst bun-78cae049d2c8f7fa4f7cde8ed5b8895b3e32b5fc.zip |
cleanup code that checks if it should send an HTTP body
Diffstat (limited to 'src/http/method.zig')
-rw-r--r-- | src/http/method.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/http/method.zig b/src/http/method.zig index 8c3e30c7f..91074d1b3 100644 --- a/src/http/method.zig +++ b/src/http/method.zig @@ -8,6 +8,7 @@ const MutableString = _global.MutableString; const stringZ = _global.stringZ; const default_allocator = _global.default_allocator; const C = _global.C; +const std = @import("std"); pub const Method = enum { GET, @@ -19,6 +20,17 @@ pub const Method = enum { CONNECT, TRACE, + const with_body: std.enums.EnumSet(Method) = brk: { + var values = std.enums.EnumSet(Method).initFull(); + values.remove(.HEAD); + values.remove(.TRACE); + break :brk values; + }; + + pub fn hasBody(this: Method) bool { + return with_body.contains(this); + } + pub fn which(str: []const u8) ?Method { if (str.len < 3) { return null; |