replace zig-async-io and std.http.Client with a custom HTTP client

This commit is contained in:
Karl Seguin
2025-03-14 19:40:56 +08:00
parent fd35724aa8
commit 2017d4785b
17 changed files with 1566 additions and 2145 deletions

View File

@@ -2181,21 +2181,28 @@ fn parseParams(enc: ?[:0]const u8) c.dom_hubbub_parser_params {
fn parseData(parser: *c.dom_hubbub_parser, reader: anytype) !void {
var err: c.hubbub_error = undefined;
var buffer: [1024]u8 = undefined;
var ln = buffer.len;
while (ln > 0) {
ln = try reader.read(&buffer);
err = c.dom_hubbub_parser_parse_chunk(parser, &buffer, ln);
// TODO handle encoding change error return.
// When the HTML contains a META tag with a different encoding than the
// original one, a c.DOM_HUBBUB_HUBBUB_ERR_ENCODINGCHANGE error is
// returned.
// In this case, we must restart the parsing with the new detected
// encoding. The detected encoding is stored in the document and we can
// get it with documentGetInputEncoding().
try parserErr(err);
const TI = @typeInfo(@TypeOf(reader));
if (TI == .pointer and @hasDecl(TI.pointer.child, "next")) {
while (try reader.next()) |data| {
err = c.dom_hubbub_parser_parse_chunk(parser, data.ptr, data.len);
try parserErr(err);
}
} else {
var buffer: [1024]u8 = undefined;
var ln = buffer.len;
while (ln > 0) {
ln = try reader.read(&buffer);
err = c.dom_hubbub_parser_parse_chunk(parser, &buffer, ln);
// TODO handle encoding change error return.
// When the HTML contains a META tag with a different encoding than the
// original one, a c.DOM_HUBBUB_HUBBUB_ERR_ENCODINGCHANGE error is
// returned.
// In this case, we must restart the parsing with the new detected
// encoding. The detected encoding is stored in the document and we can
// get it with documentGetInputEncoding().
try parserErr(err);
}
}
err = c.dom_hubbub_parser_completed(parser);
try parserErr(err);
}