elidingDrain
Function parameters
Parameters
- w:*Writer
- data:[]const []const u8
- splat:usize
Type definitions in this namespace
Types
- Method
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
- Status
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
- TransferEncoding
- compression is intentionally omitted here since it is handled in `ContentEncoding`.
- BodyWriter
- Request or response body.
Source
Implementation
pub fn elidingDrain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
const bw: *BodyWriter = @alignCast(@fieldParentPtr("writer", w));
const slice = data[0 .. data.len - 1];
const pattern = data[slice.len];
var written: usize = pattern.len * splat;
for (slice) |bytes| written += bytes.len;
switch (bw.state) {
.content_length => |*len| len.* -= written + w.end,
else => {},
}
w.end = 0;
return written;
}