Packages / rupm

cookie-tools 0.1.0

Parse Cookie and Set-Cookie headers and build them, with attribute handling and percent-encoding

Install

cargo add cookie-tools --registry rupm

In Ruststudio: Packages, search for cookie-tools, Install.

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

Versions

README

# cookie-tools

Parse Cookie and Set-Cookie headers and build them, with attribute handling and percent-encoding

Add it with `rupm add cookie-tools` (or `cargo add cookie-tools --registry rupm`).

```rust
use cookie_tools::{parse_cookie_header, parse_set_cookie, SameSite, SetCookie};

let pairs = parse_cookie_header("a=1; theme=dark");
assert_eq!(pairs[1], ("theme".to_string(), "dark".to_string()));

let mut c = SetCookie::new("sid", "abc123").unwrap();
c.path = Some("/".into());
c.http_only = true;
c.same_site = Some(SameSite::Lax);
assert_eq!(c.to_string(), "sid=abc123; Path=/; HttpOnly; SameSite=Lax");
assert_eq!(parse_set_cookie(&c.to_string()).unwrap(), c);
```