Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

next

Public Function
std.http.HeaderIterator.next
pub fn next(it: *HeaderIterator) ?std.http.Header

Params

File

http/HeaderIterator.zig:13
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
pub fn next(it: *HeaderIterator) ?std.http.Header {
    const end = std.mem.findPosLinear(u8, it.bytes, it.index, "\r\n").?;
    if (it.index == end) { // found the trailer boundary (\r\n\r\n)
        if (it.is_trailer) return null;

        const next_end = std.mem.findPosLinear(u8, it.bytes, end + 2, "\r\n") orelse
            return null;

        var kv_it = std.mem.splitScalar(u8, it.bytes[end + 2 .. next_end], ':');
        const name = kv_it.first();
        const value = kv_it.rest();

        it.is_trailer = true;
        it.index = next_end + 2;
        if (name.len == 0)
            return null;

        return .{
            .name = name,
            .value = std.mem.trim(u8, value, " \t"),
        };
    } else { // normal header
        var kv_it = std.mem.splitScalar(u8, it.bytes[it.index..end], ':');
        const name = kv_it.first();
        const value = kv_it.rest();

        it.index = end + 2;
        if (name.len == 0)
            return null;

        return .{
            .name = name,
            .value = std.mem.trim(u8, value, " \t"),
        };
    }
}