pub trait HttpParserCallback {
// Provided methods
fn on_message_begin(&mut self, parser: &mut HttpParser) -> CallbackResult { ... }
fn on_url(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult { ... }
fn on_status(
&mut self,
parser: &mut HttpParser,
data: &[u8],
) -> CallbackResult { ... }
fn on_header_field(
&mut self,
parser: &mut HttpParser,
data: &[u8],
) -> CallbackResult { ... }
fn on_header_value(
&mut self,
parser: &mut HttpParser,
data: &[u8],
) -> CallbackResult { ... }
fn on_headers_complete(&mut self, parser: &mut HttpParser) -> CallbackResult { ... }
fn on_body(
&mut self,
parser: &mut HttpParser,
data: &[u8],
) -> CallbackResult { ... }
fn on_message_complete(&mut self, parser: &mut HttpParser) -> CallbackResult { ... }
}Expand description
It defines the callback functions that would be called by parser.
§Example
struct Callback;
impl HttpParserCallback for Callback {
fn on_message_begin(&mut self, parser: &mut HttpParser) -> CallbackResult {
println!("Message begin");
Ok(ParseAction::None)
}
// Override other functions as you wish
}
let mut cb = Callback;Provided Methods§
Sourcefn on_message_begin(&mut self, parser: &mut HttpParser) -> CallbackResult
fn on_message_begin(&mut self, parser: &mut HttpParser) -> CallbackResult
Function called when starting parsing a new HTTP request or response.
Sourcefn on_url(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult
fn on_url(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult
Function called when a URL is parsed.
Sourcefn on_status(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult
fn on_status(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult
Function called when a status is parsed.
Sourcefn on_header_field(
&mut self,
parser: &mut HttpParser,
data: &[u8],
) -> CallbackResult
fn on_header_field( &mut self, parser: &mut HttpParser, data: &[u8], ) -> CallbackResult
Function called when a header field is parsed.
Sourcefn on_header_value(
&mut self,
parser: &mut HttpParser,
data: &[u8],
) -> CallbackResult
fn on_header_value( &mut self, parser: &mut HttpParser, data: &[u8], ) -> CallbackResult
Function called when a header value is parsed.
Sourcefn on_headers_complete(&mut self, parser: &mut HttpParser) -> CallbackResult
fn on_headers_complete(&mut self, parser: &mut HttpParser) -> CallbackResult
Function called when all headers are parsed.
Sourcefn on_body(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult
fn on_body(&mut self, parser: &mut HttpParser, data: &[u8]) -> CallbackResult
Function called when the body is parsed.
Sourcefn on_message_complete(&mut self, parser: &mut HttpParser) -> CallbackResult
fn on_message_complete(&mut self, parser: &mut HttpParser) -> CallbackResult
Function called when finishing parsing a HTTP request or response.