Struct minihttpse::Response
[−]
[src]
pub struct Response { /* fields omitted */ }http response object
Methods
impl Response[src]
fn new(res: Vec<u8>) -> Result<Response, HttpError>
parse http response to Response object.
Examples
let s = "HTTP/1.1 200 OK\r\n\ Content-Length: 3059\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());
fn status_code(&self) -> usize
return status code(eg:200)
fn text(&self) -> String
return response body string
fn content(&self) -> Vec<u8>
return response raw body
fn headers(&self) -> HashMap<String, String>
return response headers hashmap
fn reason(&self) -> String
return response reason
Trait Implementations
impl Debug for Response[src]
impl Clone for Response[src]
fn clone(&self) -> Response
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more