Packages / rupm

rs-net-header 0.1.0

Parse HTTP headers: Accept q-values and negotiation, Content-Type parameters, Link, and Basic or Bearer Authorization

Install

cargo add rs-net-header --registry rupm

In Ruststudio: Packages, search for rs-net-header, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-23.

Versions

README

# rs-net-header

Parse HTTP headers: Accept q-values and negotiation, Content-Type parameters, Link, and Basic or Bearer Authorization

Add it with `rupm add rs-net-header` (or `cargo add rs-net-header --registry rupm`).

```rust
use rs_net_header::*;

let accept = parse_accept("text/html, application/json;q=0.9, */*;q=0.1");
assert_eq!(accept[1].q, 0.9);
assert_eq!(negotiate("application/json;q=0.5, text/html;q=0.9", &["application/json", "text/html"]), Some("text/html"));

let ct = parse_content_type("Text/HTML; charset=\"UTF-8\"").unwrap();
assert_eq!(ct.media_type, "text/html");
assert_eq!(ct.charset(), Some("UTF-8"));

assert_eq!(
    parse_authorization("Bearer abc.def"),
    Some(Authorization::Bearer("abc.def".to_string()))
);
let links = parse_link("<https://x/?page=2>; rel=\"next\"");
assert_eq!(links[0].rel.as_deref(), Some("next"));
```