#parser #headers #formatted

rfc7239

Parser for rfc7239 formatted Forwarded headers

1 unstable release

0.1.0 Jan 5, 2021
Download history 21/week @ 2021-07-03 47/week @ 2021-07-10 36/week @ 2021-07-17 40/week @ 2021-07-24 42/week @ 2021-07-31 23/week @ 2021-08-07 16/week @ 2021-08-14 62/week @ 2021-08-21 51/week @ 2021-08-28 146/week @ 2021-09-04 171/week @ 2021-09-11 138/week @ 2021-09-18 71/week @ 2021-09-25 109/week @ 2021-10-02 71/week @ 2021-10-09 44/week @ 2021-10-16

171 downloads per month
Used in warp-real-ip

MIT/Apache

14KB
353 lines

rfc7239

Parser for rfc7239 formatted Forwarded headers.

Usage

use rfc7239::parse;

// get the header value from your favorite http server library
let header_value = "for=192.0.2.60;proto=http;by=203.0.113.43,for=192.168.10.10";

for node_result in parse(header_value) {
    let node = node_result?;
    if let Some(forwarded_for) = node.forwarded_for {
        println!("Forwarded by {}", forwarded_for)
    }
}

lib.rs:

Parser for rfc7239 formatted Forwarded headers.

Usage

use rfc7239::parse;
# use std::error::Error;

# fn main() -> Result<(), Box<dyn Error>> {
// get the header value from your favorite http server library
let header_value = "for=192.0.2.60;proto=http;by=203.0.113.43,for=192.168.10.10";

for node_result in parse(header_value) {
    let node = node_result?;
    if let Some(forwarded_for) = node.forwarded_for {
        println!("Forwarded by {}", forwarded_for)
    }
}
# Ok(())
# }

Dependencies

~28KB

_