Skip to content

Commit

Permalink
apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
zuisong committed Jun 22, 2024
1 parent 3f24597 commit 2d899c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use reqwest::header::{
use reqwest::Version;
use url::Url;

use crate::utils::HeaderValueExt;
use crate::{
buffer::Buffer,
cli::FormatOptions,
Expand Down Expand Up @@ -337,7 +336,7 @@ impl Printer {
header_string.push_str(key.as_str());
}
header_string.push_str(": ");
match value.to_utf8_str() {
match value.to_str() {
Ok(value) => header_string.push_str(value),
#[allow(clippy::format_push_string)]
Err(_) => header_string.push_str(&format!("{:?}", value)),
Expand Down
4 changes: 4 additions & 0 deletions src/to_curl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ mod tests {
(
"xh http://example.com/[1-100].png?q={80,90}",
"curl -g 'http://example.com/[1-100].png?q={80,90}'",
),
(
"xh https://exmaple.com/ hello:你好",
"curl https://exmaple.com/ -H 'hello: 你好'"
)
];
for (input, output) in expected {
Expand Down
18 changes: 1 addition & 17 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,6 @@ fn support_utf8_header_value() {
let server = server::http(|req| async move {
assert_eq!(req.headers()["hello"].as_bytes(), "你好".as_bytes());
hyper::Response::builder()
// Valid JSON, but not declared as text
.header("hello", "你好呀")
.body("".into())
.unwrap()
Expand Down Expand Up @@ -1747,21 +1746,6 @@ fn redirect_support_utf8_location() {
"#});
}

#[test]
fn to_curl_support_utf8_header_value() {
get_command()
.args(["https://exmaple.com/", "hello:你好", "--curl"])
.assert()
.stdout(contains("curl https://exmaple.com/ -H 'hello: 你好'"))
.success();

get_command()
.args(["https://exmaple.com/", "hello:你好", "--curl-long"])
.assert()
.stdout(contains("curl https://exmaple.com/ --header 'hello: 你好'"))
.success();
}

#[test]
fn mixed_stdin_request_items() {
redirecting_command()
Expand Down Expand Up @@ -3699,7 +3683,7 @@ fn multiple_format_options_are_merged() {
get_command()
.arg("--format-options=json.indent:2,json.indent:8")
.arg("--format-options=headers.sort:false")
.arg(&server.base_url())
.arg(server.base_url())
.assert()
.stdout(indoc! {r#"
HTTP/1.1 200 OK
Expand Down

0 comments on commit 2d899c2

Please sign in to comment.