update help doc

This commit is contained in:
zuisong 2025-02-04 22:10:12 +08:00
parent abc8c03b10
commit 53e7bbd88a
No known key found for this signature in database
GPG Key ID: A617F31AFE6F5E8D
3 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,4 @@
.TH XH 1 2025-01-23 0.23.1 "User Commands"
.TH XH 1 2025-02-04 0.23.1 "User Commands"
.SH NAME
xh \- Friendly and fast tool for sending HTTP requests
@ -191,7 +191,7 @@ Always stream the response body.
\fB\-x\fR, \fB\-\-compress\fR
Content compressed (encoded) with Deflate algorithm. The Content\-Encoding header is set to deflate.
Compression is skipped if it appears that compression ratio is negative. Compression can be forced by repeating this option.
Compression is skipped if it appears that compression ratio is negative. Compression can be forced by repeating this option. Note: Compression cannot be forced if the Content\-Encoding request header is present.
.TP 4
\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
Save output to FILE instead of stdout.

View File

@ -187,6 +187,7 @@ Example: --print=Hb"
///
/// Compression is skipped if it appears that compression ratio is negative.
/// Compression can be forced by repeating this option.
/// Note: Compression cannot be forced if the Content-Encoding request header is present.
#[clap(short = 'x', long = "compress", name = "compress", action = ArgAction::Count)]
pub compress: u8,

View File

@ -512,6 +512,7 @@ fn run(args: Cli) -> Result<i32> {
if args.compress >= 1 && request.headers().get(CONTENT_ENCODING).is_none() {
if let Some(body) = request.body_mut() {
// TODO: Compress file body (Multipart and File) without buffering
let body_bytes = body.buffer()?;
let mut encoder = ZlibEncoder::new(Vec::new(), Default::default());
encoder.write_all(body_bytes)?;