aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2022-02-17 16:09:32 +0000
committerGuillaume Pasquet <dev@etenil.net>2022-02-17 16:09:32 +0000
commitd2446813f9e14cfdb4e62d1034bc8a844a14131a (patch)
tree2bd1a9b547e83c0081488c91e3be8592ccaef6b0
parent47fd1e1985faa8d3251674c4ea92e11797da5866 (diff)
Fix #2: Don't print header when using `-b`.
-rw-r--r--src/executor.rs14
-rw-r--r--src/main.rs2
2 files changed, 9 insertions, 7 deletions
diff --git a/src/executor.rs b/src/executor.rs
index d330419..b5f8e96 100644
--- a/src/executor.rs
+++ b/src/executor.rs
@@ -55,7 +55,7 @@ impl Executor {
Executor { context }
}
- pub fn execute(&mut self, bfile: BarbFile) -> Result<ureq::Response, String> {
+ pub fn execute(&mut self, bfile: BarbFile, print_headers: bool) -> Result<ureq::Response, String> {
let mut req = ureq::request(
bfile.method_as_string().as_str(),
self.context.substitute(&bfile.url()).as_str(),
@@ -66,11 +66,13 @@ impl Executor {
header.name(),
self.context.substitute(header.value()).as_str(),
);
- println!(
- "{} {}",
- header.name(),
- self.context.substitute(header.value())
- );
+ if print_headers {
+ println!(
+ "{} {}",
+ header.name(),
+ self.context.substitute(header.value())
+ );
+ }
}
match bfile.method().takes_body() {
diff --git a/src/main.rs b/src/main.rs
index f5abb69..4ddc809 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -57,7 +57,7 @@ fn run_file(args: &Args, executor: &mut Executor, file_name: &String) {
.as_str(),
)
.expect("Failed to parse file");
- let response = executor.execute(bfile).unwrap();
+ let response = executor.execute(bfile, args.req_headers()).unwrap();
if args.print_headers() {
println!("{} {}", response.status(), response.status_text());