Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ mod cli_integration_tests {

assert_success!(
assert,
Some("GET https://httpbin.org/status/200 HTTP/1.1\n\n"),
Some("GET https://httpbin.org/status/200 HTTP/1.1\r\n\n"),
None::<String>
);
}
Expand Down
4 changes: 2 additions & 2 deletions reqlang/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ mod test {
format_to_http_get_request,
HttpRequest::get("/", "1.1", vec![]),
RequestFormat::HttpMessage,
"GET / HTTP/1.1\n"
"GET / HTTP/1.1\r\n"
);

export_test!(
format_to_http_post_request,
HttpRequest::post("/", "1.1", vec![], Some("[1, 2, 3]\n")),
RequestFormat::HttpMessage,
"POST / HTTP/1.1\n\n[1, 2, 3]\n"
"POST / HTTP/1.1\r\n\r\n[1, 2, 3]\n"
);

export_response_test!(
Expand Down
10 changes: 5 additions & 5 deletions reqlang/src/types/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ impl Display for HttpRequest {
None
} else {
Some(format!(
"{}\n",
"{}\r\n",
self.headers
.clone()
.into_iter()
.map(|x| format!("{}: {}", x.0, x.1))
.collect::<Vec<String>>()
.join("\n")
.join("\r\n")
.trim_end()
))
};
Expand All @@ -161,15 +161,15 @@ impl Display for HttpRequest {
.and_then(|x| if x.is_empty() { None } else { Some(x) });

let the_rest = match (&headers, &body) {
(Some(headers), Some(body)) => format!("{headers}\n{body}"),
(Some(headers), Some(body)) => format!("{headers}\r\n{body}"),
(Some(headers), None) => headers.to_string(),
(None, Some(body)) => format!("\n{body}"),
(None, Some(body)) => format!("\r\n{body}"),
(None, None) => String::new(),
};

write!(
f,
"{} {} HTTP/{}\n{}",
"{} {} HTTP/{}\r\n{}",
self.verb, self.target, self.http_version, the_rest
)
}
Expand Down
8 changes: 4 additions & 4 deletions reqlang/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ mod tests {

assert_eq!(
concat!(
"POST / HTTP/1.1\n",
"host: https://example.com\n\n",
"POST / HTTP/1.1\r\n",
"host: https://example.com\r\n\r\n",
"[1, 2, 3]\n"
),
format!("{req}"),
Expand All @@ -797,7 +797,7 @@ mod tests {
);

assert_eq!(
concat!("GET / HTTP/1.1\n", "host: https://example.com\n"),
concat!("GET / HTTP/1.1\r\n", "host: https://example.com\r\n"),
format!("{req}"),
);
}
Expand All @@ -806,7 +806,7 @@ mod tests {
fn get_request_no_headers() {
let req = HttpRequest::get("/", "1.1", Vec::default());

assert_eq!("GET / HTTP/1.1\n", format!("{req}"));
assert_eq!("GET / HTTP/1.1\r\n", format!("{req}"));
}
}
}
Loading