request-http-parser 0.1.1

A simple library for parsing http request string to a model.
Documentation
  • Coverage
  • 15.38%
    2 out of 13 items documented1 out of 3 items with examples
  • Size
  • Source code size: 6.16 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 496.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • crisandolindesmanrumahorbo

How to use

let mut buffer = [0; 1024];
let size =  stream.read(&mut buffer).expect("");
let req_str = String::from_utf8_lossy(&buffer[..size]);
let req = Request::new(&req_str);

Examples

    use request_http_parser::parser::{Method,Request};
    let req_str = format!(
                "POST /login HTTP/1.1\r\n\
                Content-Type: application/json\r\n\
                User-Agent: Test\r\n\
                Content-Length: {}\r\n\\r\n\
                {{\"username\": \"{}\",\"password\": \"{}\"}}",
                44, "crisandolin", "rumahorbo");
                let req = Request::new(&req_str);

    assert_eq!(Method::POST, req.method);
    assert_eq!("/login", req.path);