Skip to content
Open
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
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ impl HttpClient {
///
/// Automatically sets:
/// - Content-Type: application/x-www-form-urlencoded
/// - Accept: application/json
///
/// # Arguments
///
Expand All @@ -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
Expand All @@ -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();
Expand Down
Loading