| 1047 | false, |
| 1048 | &response(304, "content-length", "11") |
| 1049 | )); |
| 1050 | assert!(should_poison_connection( |
| 1051 | &Method::POST, |
| 1052 | true, |
| 1053 | &response(304, "content-length", "11") |
| 1054 | )); |
| 1055 | assert!(!should_poison_connection( |
| 1056 | &Method::HEAD, |
| 1057 | false, |
| 1058 | &response(200, "content-length", "11") |
| 1059 | )); |
| 1060 | assert!(!should_poison_connection( |
| 1061 | &Method::GET, |
| 1062 | false, |
| 1063 | &h2_response(204, "content-length", "11") |
| 1064 | )); |
| 1065 | } |
| 1066 | |
| 1067 | #[test] |
| 1068 | fn test_should_change_method() { |
| 1069 | // Test cases for prev_status being 301 or 302 |
| 1070 | assert!(should_change_method(301, &Method::POST)); |
| 1071 | assert!(should_change_method(302, &Method::POST)); |
| 1072 | |
| 1073 | assert!(!should_change_method(301, &Method::GET)); |
| 1074 | assert!(!should_change_method(302, &Method::GET)); |
| 1075 | assert!(!should_change_method(301, &Method::HEAD)); |
| 1076 | assert!(!should_change_method(302, &Method::HEAD)); |
| 1077 | |
| 1078 | // Test cases for prev_status being 303 |
| 1079 | assert!(should_change_method(303, &Method::POST)); |
| 1080 | |
| 1081 | assert!(!should_change_method(303, &Method::GET)); |
| 1082 | assert!(!should_change_method(303, &Method::HEAD)); |
| 1083 | |
| 1084 | // Test case for other prev_status values |
| 1085 | assert!(!should_change_method(200, &Method::POST)); |
| 1086 | assert!(!should_change_method(404, &Method::GET)); |
| 1087 | } |
| 1088 | |
| 1089 | #[test] |
| 1090 | fn test_is_request_body_header_name() { |
| 1091 | assert!(is_request_body_header_name("content-encoding")); |
| 1092 | assert!(is_request_body_header_name("content-language")); |
| 1093 | assert!(is_request_body_header_name("content-location")); |
| 1094 | assert!(is_request_body_header_name("content-type")); |
| 1095 | |
| 1096 | assert!(!is_request_body_header_name("content-length")); |
| 1097 | assert!(!is_request_body_header_name("accept")); |
| 1098 | } |
| 1099 | |
| 1100 | #[test] |
| 1101 | fn test_is_same_origin() { |
| 1102 | let uri1 = Uri::from_static("https://example.com:8080/path"); |
| 1103 | let uri2 = Uri::from_static("https://example.com:8080/path"); |
| 1104 | |
| 1105 | assert!(is_same_origin(&uri1, &uri2)); |
| 1106 | |