diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-02-23 17:41:38 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-23 17:41:38 -0800 |
| commit | cfce81f7d5f11ab93b2d5fd26df41edf967f333b (patch) | |
| tree | 11e52ad0a44620f4a4519683abd945146c11b312 /lib/std/http.zig | |
| parent | 7230b68b350b16c637e84f3ff224be24d23214ce (diff) | |
| parent | 653d4158cdcb20be82ff525e122277064e6acb92 (diff) | |
| download | zig-cfce81f7d5f11ab93b2d5fd26df41edf967f333b.tar.gz zig-cfce81f7d5f11ab93b2d5fd26df41edf967f333b.zip | |
Merge pull request #18955 from ziglang/std.http.Server
take std.http in a different direction
Diffstat (limited to 'lib/std/http.zig')
| -rw-r--r-- | lib/std/http.zig | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/std/http.zig b/lib/std/http.zig index 9b2bce1338..af966d89e7 100644 --- a/lib/std/http.zig +++ b/lib/std/http.zig @@ -1,12 +1,9 @@ -const std = @import("std.zig"); - pub const Client = @import("http/Client.zig"); pub const Server = @import("http/Server.zig"); pub const protocol = @import("http/protocol.zig"); -const headers = @import("http/Headers.zig"); - -pub const Headers = headers.Headers; -pub const Field = headers.Field; +pub const HeadParser = @import("http/HeadParser.zig"); +pub const ChunkParser = @import("http/ChunkParser.zig"); +pub const HeaderIterator = @import("http/HeaderIterator.zig"); pub const Version = enum { @"HTTP/1.0", @@ -18,7 +15,7 @@ pub const Version = enum { /// https://datatracker.ietf.org/doc/html/rfc7231#section-4 Initial definition /// /// https://datatracker.ietf.org/doc/html/rfc5789#section-2 PATCH -pub const Method = enum(u64) { // TODO: should be u192 or u256, but neither is supported by the C backend, and therefore cannot pass CI +pub const Method = enum(u64) { GET = parse("GET"), HEAD = parse("HEAD"), POST = parse("POST"), @@ -46,10 +43,6 @@ pub const Method = enum(u64) { // TODO: should be u192 or u256, but neither is s try w.writeAll(str); } - pub fn format(value: Method, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) @TypeOf(writer).Error!void { - return try value.write(writer); - } - /// Returns true if a request of this method is allowed to have a body /// Actual behavior from servers may vary and should still be checked pub fn requestHasBody(self: Method) bool { @@ -309,9 +302,22 @@ pub const Connection = enum { close, }; +pub const Header = struct { + name: []const u8, + value: []const u8, +}; + +const builtin = @import("builtin"); +const std = @import("std.zig"); + test { _ = Client; _ = Method; _ = Server; _ = Status; + _ = HeadParser; + _ = ChunkParser; + if (builtin.os.tag != .wasi) { + _ = @import("http/test.zig"); + } } |
