Skip to content

Commit f5a7d7c

Browse files
committed
Tests for "Fix handling long Reason Phrase"
Issue #163
1 parent f3a5c01 commit f5a7d7c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/http.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,22 @@ mod tests {
742742
assert_eq!(read_status(&mut mem(s)), result);
743743
}
744744

745+
fn read_ignore_string(s: &str, result: HttpResult<RawStatus>) {
746+
match (read_status(&mut mem(s)), result) {
747+
(Ok(RawStatus(ref c1, _)), Ok(RawStatus(ref c2, _))) => {
748+
assert_eq!(c1, c2);
749+
},
750+
(r1, r2) => assert_eq!(r1, r2)
751+
}
752+
}
753+
745754
read("200 OK\r\n", Ok(RawStatus(200, Borrowed("OK"))));
746755
read("404 Not Found\r\n", Ok(RawStatus(404, Borrowed("Not Found"))));
747756
read("200 crazy pants\r\n", Ok(RawStatus(200, Owned("crazy pants".to_string()))));
757+
read("301 Moved Permanently\r\n", Ok(RawStatus(301, Owned("Moved Permanently".to_string()))));
758+
read_ignore_string("301 Unreasonably long header that should not happen, \
759+
but some men just want to watch the world burn\r\n",
760+
Ok(RawStatus(301, Owned("Ignored".to_string()))));
748761
}
749762

750763
#[test]

0 commit comments

Comments
 (0)