@@ -409,8 +409,8 @@ impl<'a> TryParse for httparse::Response<'a, 'a> {
409409 httparse:: Status :: Complete ( len) => {
410410 let code = res. code . unwrap ( ) ;
411411 let reason = match StatusCode :: from_u16 ( code) . canonical_reason ( ) {
412- Some ( reason) => Cow :: Borrowed ( reason) ,
413- None => Cow :: Owned ( res. reason . unwrap ( ) . to_owned ( ) )
412+ Some ( reason) if reason == res . reason . unwrap ( ) => Cow :: Borrowed ( reason) ,
413+ _ => Cow :: Owned ( res. reason . unwrap ( ) . to_owned ( ) )
414414 } ;
415415 httparse:: Status :: Complete ( ( Incoming {
416416 version : if res. version . unwrap ( ) == 1 { Http11 } else { Http10 } ,
@@ -460,7 +460,7 @@ mod tests {
460460 use buffer:: BufReader ;
461461 use mock:: MockStream ;
462462
463- use super :: { read_chunk_size, parse_request} ;
463+ use super :: { read_chunk_size, parse_request, parse_response } ;
464464
465465 #[ test]
466466 fn test_write_chunked ( ) {
@@ -533,6 +533,22 @@ mod tests {
533533 parse_request ( & mut buf) . unwrap ( ) ;
534534 }
535535
536+ #[ test]
537+ fn test_parse_raw_status ( ) {
538+ let mut raw = MockStream :: with_input ( b"HTTP/1.1 200 OK\r \n \r \n " ) ;
539+ let mut buf = BufReader :: new ( & mut raw) ;
540+ let res = parse_response ( & mut buf) . unwrap ( ) ;
541+
542+ assert_eq ! ( res. subject. 1 , "OK" ) ;
543+
544+ let mut raw = MockStream :: with_input ( b"HTTP/1.1 200 Howdy\r \n \r \n " ) ;
545+ let mut buf = BufReader :: new ( & mut raw) ;
546+ let res = parse_response ( & mut buf) . unwrap ( ) ;
547+
548+ assert_eq ! ( res. subject. 1 , "Howdy" ) ;
549+ }
550+
551+
536552 #[ test]
537553 fn test_parse_tcp_closed ( ) {
538554 use std:: io:: ErrorKind ;
0 commit comments