-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders.zig
More file actions
34 lines (25 loc) · 729 Bytes
/
headers.zig
File metadata and controls
34 lines (25 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const std = @import("std");
const http = std.http;
pub const ExtraHeaders = struct {
extra_headers: [16]http.Header,
len: usize,
pub fn init() ExtraHeaders {
return ExtraHeaders{
.extra_headers = undefined,
.len = 0,
};
}
pub fn append(self: *ExtraHeaders, name: []const u8, value: []const u8)!void {
if (self.len >= self.extra_headers.len) {
return error.ExtraHeadersFull;
}
self.extra_headers[self.len] = .{
.name = name,
.value = value,
};
self.len += 1;
}
pub fn toSlices(self: *ExtraHeaders) []const http.Header {
return self.extra_headers[0..self.len];
}
};