From f5a7d7cfa13a3a8f0b64cb2fa57cc20ad02e3673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ci=C4=99=C5=BCarkiewicz?= Date: Sun, 30 Nov 2014 18:35:21 -0800 Subject: [PATCH] Tests for "Fix handling long Reason Phrase" Issue #163 --- src/http.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/http.rs b/src/http.rs index 57029f4c..be4ab35a 100644 --- a/src/http.rs +++ b/src/http.rs @@ -742,9 +742,22 @@ mod tests { assert_eq!(read_status(&mut mem(s)), result); } + fn read_ignore_string(s: &str, result: HttpResult) { + match (read_status(&mut mem(s)), result) { + (Ok(RawStatus(ref c1, _)), Ok(RawStatus(ref c2, _))) => { + assert_eq!(c1, c2); + }, + (r1, r2) => assert_eq!(r1, r2) + } + } + read("200 OK\r\n", Ok(RawStatus(200, Borrowed("OK")))); read("404 Not Found\r\n", Ok(RawStatus(404, Borrowed("Not Found")))); read("200 crazy pants\r\n", Ok(RawStatus(200, Owned("crazy pants".to_string())))); + read("301 Moved Permanently\r\n", Ok(RawStatus(301, Owned("Moved Permanently".to_string())))); + read_ignore_string("301 Unreasonably long header that should not happen, \ + but some men just want to watch the world burn\r\n", + Ok(RawStatus(301, Owned("Ignored".to_string())))); } #[test]