-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Header Json when post Json content
- Loading branch information
Showing
4 changed files
with
89 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use rust_extensions::StrOrString; | ||
|
||
pub struct FlUrlHeader { | ||
pub name: StrOrString<'static>, | ||
pub value: String, | ||
} | ||
|
||
pub struct FlUrlHeaders { | ||
headers: Vec<FlUrlHeader>, | ||
} | ||
|
||
impl FlUrlHeaders { | ||
pub fn new() -> Self { | ||
Self { | ||
headers: Vec::new(), | ||
} | ||
} | ||
|
||
fn find_index(&self, name: &str) -> Option<usize> { | ||
self.headers.iter().position(|header| { | ||
rust_extensions::str_utils::compare_strings_case_insensitive(header.name.as_str(), name) | ||
}) | ||
} | ||
|
||
pub fn add(&mut self, name: StrOrString<'static>, value: String) { | ||
match self.find_index(name.as_str()) { | ||
Some(index) => self.headers[index].value = value, | ||
None => { | ||
self.headers.push(FlUrlHeader { name, value }); | ||
} | ||
} | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
self.headers.len() | ||
} | ||
|
||
pub fn iter(&self) -> std::slice::Iter<FlUrlHeader> { | ||
self.headers.iter() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ mod errors; | |
pub use errors::*; | ||
|
||
pub extern crate my_tls; | ||
mod fl_url_headers; | ||
pub use fl_url_headers::*; |