Skip to content

Commit

Permalink
Handle empty headers in CurlCmd
Browse files Browse the repository at this point in the history
  • Loading branch information
theoforger authored and hurl-bot committed Jan 21, 2025
1 parent 1f14a73 commit 819085b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/hurl/src/http/curl_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ impl Header {
let value = &self.value;
vec![
"--header".to_string(),
encode_shell_string(&format!("{name}: {value}")),
if self.value.is_empty() {
encode_shell_string(&format!("{name};"))
} else {
encode_shell_string(&format!("{name}: {value}"))
},
]
}
}
Expand Down Expand Up @@ -626,6 +630,7 @@ mod tests {
headers: vec![
"Test-Header-1: content-1".to_string(),
"Test-Header-2: content-2".to_string(),
"Test-Header-Empty:".to_string(),
],
http_version: RequestedHttpVersion::Http10,
insecure: true,
Expand Down Expand Up @@ -658,6 +663,7 @@ mod tests {
"curl \
--header 'Test-Header-1: content-1' \
--header 'Test-Header-2: content-2' \
--header 'Test-Header-Empty;' \
--compressed \
--connect-timeout 20 \
--connect-to example.com:443:host-47.example.com:443 \
Expand Down

0 comments on commit 819085b

Please sign in to comment.