Struct http_muncher::Parser [] [src]

pub struct Parser { /* fields omitted */ }

The main parser interface.

Example

use http_muncher::{Parser, ParserHandler};
use std::str;

struct MyHandler;
impl ParserHandler for MyHandler {
   fn on_header_field(&mut self, parser: &mut Parser, header: &[u8]) -> bool {
       println!("{}: ", str::from_utf8(header).unwrap());
       true
   }
   fn on_header_value(&mut self, parser: &mut Parser, value: &[u8]) -> bool {
       println!("\t {:?}", str::from_utf8(value).unwrap());
       true
   }
}

let http_request = b"GET / HTTP/1.0\r\n\
                     Content-Length: 0\r\n\r\n";

let mut parser = Parser::request();
parser.parse(&mut MyHandler {}, http_request);

Methods

impl Parser
[src]

[src]

Creates a new parser instance for an HTTP response.

[src]

Creates a new parser instance for an HTTP request.

[src]

Creates a new parser instance to handle both HTTP requests and responses.

[src]

Parses the provided data and returns a number of bytes read.

[src]

Returns an HTTP request or response version.

[src]

Returns an HTTP response status code (think 404).

[src]

Returns an HTTP method static string (GET, POST, and so on).

[src]

Checks if the last parse call was finished successfully. Returns true if it wasn't.

[src]

In case of a parsing error returns its mnemonic name.

[src]

In case of a parsing error returns its description.

[src]

Checks if an upgrade protocol (e.g. WebSocket) was requested.

[src]

Checks if it was the final body chunk.

[src]

If should_keep_alive() in the on_headers_complete or on_message_complete callback returns 0, then this should be the last message on the connection. If you are the server, respond with the "Connection: close" header. If you are the client, close the connection.

[src]

[src]

Trait Implementations

impl Send for Parser
[src]

impl Debug for Parser
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !Sync for Parser