mirror of
https://github.com/ducaale/xh.git
synced 2025-05-05 15:32:50 +00:00
can not combine compress with multipart
This commit is contained in:
parent
53e7bbd88a
commit
d9026f1850
@ -54,7 +54,7 @@ none\:"Disable both coloring and formatting"))' \
|
||||
'--json[(default) Serialize data items from the command line as a JSON object]' \
|
||||
'-f[Serialize data items from the command line as form fields]' \
|
||||
'--form[Serialize data items from the command line as form fields]' \
|
||||
'(--raw)--multipart[Like --form, but force a multipart/form-data request even without files]' \
|
||||
'(--raw -x --compress)--multipart[Like --form, but force a multipart/form-data request even without files]' \
|
||||
'-h[Print only the response headers. Shortcut for --print=h]' \
|
||||
'--headers[Print only the response headers. Shortcut for --print=h]' \
|
||||
'-b[Print only the response body. Shortcut for --print=b]' \
|
||||
|
@ -60,7 +60,7 @@ pub struct Cli {
|
||||
/// Like --form, but force a multipart/form-data request even without files.
|
||||
///
|
||||
/// Overrides both --json and --form.
|
||||
#[clap(long, conflicts_with = "raw", overrides_with_all = &["json", "form"])]
|
||||
#[clap(long, conflicts_with_all = &["raw", "compress"], overrides_with_all = &["json", "form"])]
|
||||
pub multipart: bool,
|
||||
|
||||
/// Pass raw request data without extra processing.
|
||||
|
@ -512,7 +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
|
||||
// TODO: Compress file body (File) without buffering
|
||||
let body_bytes = body.buffer()?;
|
||||
let mut encoder = ZlibEncoder::new(Vec::new(), Default::default());
|
||||
encoder.write_all(body_bytes)?;
|
||||
|
@ -87,6 +87,7 @@ fn compress_request_body_form() {
|
||||
key={c}
|
||||
"#, c = "1".repeat(1000),});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skip_compression_when_compression_ratio_is_negative() {
|
||||
let server = server();
|
||||
@ -105,7 +106,7 @@ fn skip_compression_when_compression_ratio_is_negative() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compress_request_body_force() {
|
||||
fn test_compress_force_with_negative_ratio() {
|
||||
let server = server();
|
||||
get_command()
|
||||
.arg(format!("{}/deflate", server.base_url()))
|
||||
@ -195,3 +196,14 @@ fn compress_body_from_file_unless_compress_rate_less_1() {
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
#[test]
|
||||
fn test_cannot_combine_compress_with_multipart() {
|
||||
get_command()
|
||||
.arg(format!("{}/deflate", ""))
|
||||
.args(["--multipart", "-x", "a=1"])
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicates::str::contains(
|
||||
"the argument '--multipart' cannot be used with '--compress...'",
|
||||
));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user