From ad1195e81efe656f9b27912546f5bbba185b3f7e Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Mon, 29 Apr 2024 18:27:51 -0400 Subject: [PATCH] fix: body enters twice into options --- src/app.rs | 1 + src/request/curl.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/app.rs b/src/app.rs index d51443b..e61d5cd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -73,6 +73,7 @@ impl<'a> Default for App<'a> { } impl<'a> App<'a> { + #[allow(dead_code)] fn new_test_db() -> Self { Self { db: Box::new(DB::new_test().expect("Failed to create database")), diff --git a/src/request/curl.rs b/src/request/curl.rs index 67d89d1..99f15f6 100644 --- a/src/request/curl.rs +++ b/src/request/curl.rs @@ -568,6 +568,9 @@ impl Curl { if self.ser { self.opts.push(AppOptions::RequestBody(body.to_string())); } + if self.opts.iter().any(|x| std::mem::discriminant(x) == std::mem::discriminant(&AppOptions::RequestBody(body.to_string()))) { + self.opts.retain(|x| std::mem::discriminant(x) != std::mem::discriminant(&AppOptions::RequestBody(body.to_string()))); + } self.opts.push(AppOptions::RequestBody(body.to_string())); self.curl .post_fields_copy(body.as_bytes())