@@ 433,6 433,28 @@ export fn write_header(sink: io::handle, head: *header) (size | io::error) = {
assert(result == expect);
};
@test fn roundtrip() void = {
const input =
"To: Drew DeVault <sir@cmpwn.com>\r\n"
"From: Harriet <harriet@harelang.org>\r\n"
"Content-Type: text/plain\r\n"
"DKIM-Signature: a=rsa-sha256;\r\n"
" bh=uI/rVH7mLBSWkJVvQYKz3TbpdI2BLZWTIMKcuo0KHOI=; c=simple/simple;\r\n"
" d=example.org; h=Subject:To:From; s=default; t=1577562184; v=1; b=;\r\n"
"\r\n";
const in = bufio::fixed(strings::toutf8(input), io::mode::READ);
const head = read_header(&in)!;
defer header_finish(&head);
const sink = strio::dynamic();
defer io::close(&sink)!;
write_header(&sink, &head)!;
assert(strio::string(&sink) == input);
};
// Initializes a new header field, duplicating the provided parameters.
fn new_header_field(key: str, val: str, raw: []u8) header_field = {
return header_field {