Skip to content

Commit

Permalink
perf(http): replace httpbin with postman-echo
Browse files Browse the repository at this point in the history
  • Loading branch information
xz-dev committed Nov 23, 2024
1 parent cd81c2b commit 76f372b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ mod tests {

#[tokio::test]
async fn test_https_get_header() {
let url = "https://httpbin.org/headers".parse().unwrap();
let url = "https://postman-echo.com/get".parse().unwrap();
let header_map = {
let mut map = HashMap::new();
map.insert("X-Test".to_string(), "test000".to_string());
Expand All @@ -276,6 +276,9 @@ mod tests {
let body = result.unwrap().body.expect("Response body was empty");
let json: serde_json::Value = serde_json::from_slice(&body).expect("Failed to parse JSON");
for (key, value) in header_map {
// key to lowercase, for fix podman-echo
// Due https://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive
let key = key.to_lowercase();
assert_eq!(json["headers"][key], value);
}
}
Expand All @@ -298,7 +301,7 @@ mod tests {

#[tokio::test]
async fn test_http_get_header() {
let url = "http://httpbin.org/headers".parse().unwrap();
let url = "http://postman-echo.com/get".parse().unwrap();
let header_map = {
let mut map = HashMap::new();
map.insert("X-Test".to_string(), "test000".to_string());
Expand All @@ -310,6 +313,7 @@ mod tests {
let body = result.unwrap().body.expect("Response body was empty");
let json: serde_json::Value = serde_json::from_slice(&body).expect("Failed to parse JSON");
for (key, value) in header_map {
let key = key.to_lowercase();
assert_eq!(json["headers"][key], value);
}
}
Expand Down

0 comments on commit 76f372b

Please sign in to comment.