aboutsummaryrefslogtreecommitdiff
path: root/misctools/fetch.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-02 18:07:05 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-02-02 18:07:05 -0800
commit1a4ccd3f5c2ef273bd5307d9c8939177bdc310cc (patch)
tree1b1634fa2d1450b87846de1d1dc572ba44d1f333 /misctools/fetch.zig
parent68cb6130d3e4bd25a53c959db9108a68f5268298 (diff)
downloadbun-1a4ccd3f5c2ef273bd5307d9c8939177bdc310cc.tar.gz
bun-1a4ccd3f5c2ef273bd5307d9c8939177bdc310cc.tar.zst
bun-1a4ccd3f5c2ef273bd5307d9c8939177bdc310cc.zip
[http] Fixes to chunked transfer encoding readerjarred/async_bio
Diffstat (limited to 'misctools/fetch.zig')
-rw-r--r--misctools/fetch.zig15
1 files changed, 10 insertions, 5 deletions
diff --git a/misctools/fetch.zig b/misctools/fetch.zig
index 53a7f9499..2167429e0 100644
--- a/misctools/fetch.zig
+++ b/misctools/fetch.zig
@@ -31,6 +31,7 @@ const params = [_]clap.Param(clap.Help){
clap.parseParam("-r, --max-redirects <STR> Maximum number of redirects to follow (default: 128)") catch unreachable,
clap.parseParam("-b, --body <STR> HTTP request body as a string") catch unreachable,
clap.parseParam("-f, --file <STR> File path to load as body") catch unreachable,
+ clap.parseParam("-q, --quiet Quiet mode") catch unreachable,
clap.parseParam("--no-gzip Disable gzip") catch unreachable,
clap.parseParam("--no-deflate Disable deflate") catch unreachable,
clap.parseParam("--no-compression Disable gzip & deflate") catch unreachable,
@@ -70,6 +71,7 @@ pub const Arguments = struct {
headers_buf: string,
body: string = "",
turbo: bool = false,
+ quiet: bool = false,
pub fn parse(allocator: std.mem.Allocator) !Arguments {
var diag = clap.Diagnostic{};
@@ -159,6 +161,7 @@ pub const Arguments = struct {
.headers_buf = "",
.body = body_string,
.turbo = args.flag("--turbo"),
+ .quiet = args.flag("--quiet"),
};
}
};
@@ -213,7 +216,7 @@ pub fn main() anyerror!void {
while (true) {
while (channel.tryReadItem() catch null) |http| {
var response = http.response orelse {
- Output.printErrorln("<r><red>error<r><d>:<r> <b>HTTP response missing<r>", .{});
+ Output.prettyErrorln("<r><red>error<r><d>:<r> <b>HTTP response missing<r>", .{});
Output.flush();
std.os.exit(1);
};
@@ -227,10 +230,12 @@ pub fn main() anyerror!void {
},
}
- Output.flush();
- Output.disableBuffering();
- try Output.writer().writeAll(response_body_string.list.items);
- Output.enableBuffering();
+ if (!args.quiet) {
+ Output.flush();
+ Output.disableBuffering();
+ try Output.writer().writeAll(response_body_string.list.items);
+ Output.enableBuffering();
+ }
return;
}
}