fediglam/src/http/request.zig

26 lines
641 B
Zig
Raw Normal View History

const std = @import("std");
const http = @import("./lib.zig");
const parser = @import("./request/parser.zig");
2022-11-07 07:38:21 +00:00
pub fn Request(comptime Reader: type) type {
2022-11-05 10:09:59 +00:00
return struct {
protocol: http.Protocol,
2022-11-05 07:26:53 +00:00
2022-11-05 10:09:59 +00:00
method: http.Method,
uri: []const u8,
headers: http.Fields,
2022-11-07 07:38:21 +00:00
body: ?parser.TransferStream(Reader),
2022-10-13 09:23:57 +00:00
2022-11-05 10:09:59 +00:00
pub fn parseFree(self: *@This(), allocator: std.mem.Allocator) void {
allocator.free(self.uri);
self.headers.deinit();
}
};
}
2022-11-05 10:09:59 +00:00
pub fn parse(alloc: std.mem.Allocator, reader: anytype) !Request(@TypeOf(reader)) {
return parser.parse(alloc, reader);
}