From 44548ee5b2ca3d98c8dc401da0d48b033776bf56 Mon Sep 17 00:00:00 2001 From: izarma Date: Fri, 29 May 2026 18:48:53 +0530 Subject: [PATCH] update default headers --- src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 57c316a..6206011 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -540,7 +540,6 @@ impl HttpClient { /// /// Automatically sets: /// - Content-Type: application/x-www-form-urlencoded - /// - Accept: application/json /// /// # Arguments /// @@ -558,12 +557,14 @@ impl HttpClient { /// // Simple form submission /// let client = HttpClient::new() /// .post("https://api.example.com/login") - /// .form_encoded("username=john&password=secret"); + /// .form_encoded("username=john&password=secret") + /// .headers(&[("Accept", "application/json")]); /// /// // With URL-encoded special characters /// let client = HttpClient::new() /// .post("https://api.example.com/submit") - /// .form_encoded("email=user%40example.com&message=Hello%20World"); + /// .form_encoded("email=user%40example.com&message=Hello%20World") + /// .headers(&[("Accept", "application/json")]); /// ``` /// /// # Note @@ -576,12 +577,11 @@ impl HttpClient { "Content-Type".to_string(), "application/x-www-form-urlencoded".to_string(), ); - headers.insert("Accept".to_string(), "application/json".to_string()); } else { - self.headers = Some(ehttp::Headers::new(&[ - ("Content-Type", "application/x-www-form-urlencoded"), - ("Accept", "application/json"), - ])); + self.headers = Some(ehttp::Headers::new(&[( + "Content-Type", + "application/x-www-form-urlencoded", + )])); } self.body = body.as_bytes().to_vec();