add a basic test for the all flag
@@ -9,7 +9,7 @@ use std::{
use assert_cmd::prelude::*;
use httpmock::{Method::*, MockServer};
-use indoc::indoc;
+use indoc::{formatdoc, indoc};
use predicate::str::contains;
use predicates::prelude::*;
use serde_json::json;
@@ -1627,3 +1627,53 @@ fn cookies_override_each_other_in_the_correct_order() {
})
);
}
+
+#[test]
+fn print_intermediate_requests_and_responses() {
+ let server1 = MockServer::start();
+ server1.mock(|_, then| {
+ then.header("date", "N/A").body("final destination");
+ });
+ let server2 = MockServer::start();
+ server2.mock(|_, then| {
+ then.header("location", &server1.base_url())
+ .status(302)
+ .header("date", "N/A")
+ .body("redirecting...");
+ });
+
+ get_command()
+ .arg(server2.base_url())
+ .arg("--follow")
+ .arg("--verbose")
+ .arg("--all")
+ .assert()
+ .stdout(formatdoc! {r#"
+ GET / HTTP/1.1
+ accept: */*
+ accept-encoding: gzip, br
+ connection: keep-alive
+ host: http.mock
+ user-agent: xh/0.0.0 (test mode)
+
+ HTTP/1.1 302 Found
+ content-length: 14
+ date: N/A
+ location: {url}
+
+ redirecting...
+
+ GET / HTTP/1.1
+ accept: */*
+ accept-encoding: gzip, br
+ connection: keep-alive
+ host: http.mock
+ user-agent: xh/0.0.0 (test mode)
+
+ HTTP/1.1 200 OK
+ content-length: 17
+ date: N/A
+
+ final destination
+ "#, url = server1.base_url() });
+}
