7 releases
Uses old Rust 2015
0.1.6 | Aug 18, 2017 |
---|---|
0.1.5 | Aug 17, 2017 |
#44 in #mini
29 downloads per month
Used in 2 crates
11KB
166 lines
minihttpse is a http response parser for rust,is simple and easy
Examples
use minihttpse::Response;
let s = "HTTP/1.1 200 OK\r\n\
Content-Length: 18\r\n\
Server: GWS/2.0\r\n\
Date: Sat, 11 Jan 2003 02:44:04 GMT\r\n\
Content-Type: text/html\r\n\
Cache-control: private\r\n\
Set-Cookie: PREF=ID=73d4aef52e57bae9:TM=1042253044:LM=1042253044:S=SMCc_HRPCQiqyX9j; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com\r\n\
Connection: keep-alive\r\n\
\r\n\
<html>hello</html>";
let res = Response::new(s.as_bytes().to_owned()).unwrap();
assert_eq!(res.reason(),"OK");
assert_eq!(res.status_code(),200);
assert_eq!(res.headers().get("Server"),Some(&"GWS/2.0".to_owned()));
println!("body {}",res.text());