set-cookie-parser 0.1.0

Parse Set-Cookie response headers into structured cookies, and split a comma-joined Set-Cookie header without choking on commas in Expires dates. A faithful port of the set-cookie-parser npm package. Zero dependencies, no_std.
Documentation
# set-cookie-parser

[![Crates.io](https://img.shields.io/crates/v/set-cookie-parser.svg)](https://crates.io/crates/set-cookie-parser)
[![Documentation](https://docs.rs/set-cookie-parser/badge.svg)](https://docs.rs/set-cookie-parser)
[![CI](https://github.com/trananhtung/set-cookie-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/trananhtung/set-cookie-parser/actions/workflows/ci.yml)
[![License](https://img.shields.io/crates/l/set-cookie-parser.svg)](#license)

**Parse `Set-Cookie` response headers** into structured cookies, and split a
comma-joined `Set-Cookie` string into individual cookies *without* choking on the
commas inside an `Expires` date. A faithful Rust port of the
[`set-cookie-parser`](https://www.npmjs.com/package/set-cookie-parser) npm package.
Zero dependencies and `#![no_std]`.

```rust
use set_cookie_parser::{parse, parse_all, split_cookies_string};

let c = parse("sid=abc123; Path=/; HttpOnly; SameSite=Lax").unwrap();
assert_eq!(c.name, "sid");
assert_eq!(c.value, "abc123");
assert_eq!(c.path.as_deref(), Some("/"));
assert!(c.http_only);

// One combined header with two cookies (note the comma inside Expires):
let header = "a=1; Expires=Wed, 09 Jun 2021 10:18:14 GMT, b=2";
assert_eq!(parse_all(header).len(), 2);
```

## Why set-cookie-parser?

Servers and proxies sometimes combine multiple `Set-Cookie` field values into one
comma-joined string — which is awkward to split because `Expires` dates contain
commas too (`Wed, 09 Jun 2021 …`). This ports the canonical JS algorithm that splits
correctly, and parses each cookie's name, value, and attributes.

```toml
[dependencies]
set-cookie-parser = "0.1"
```

## API

| Item | Purpose |
| --- | --- |
| `parse(set_cookie)` | Parse one `Set-Cookie` value into a `Cookie` |
| `parse_with(set_cookie, decode_values)` | …controlling URI-decoding of the value |
| `split_cookies_string(combined)` | Split a comma-joined header into individual strings |
| `parse_all(combined)` | Split then parse each cookie |
| `Cookie` | name, value, expires, max_age, domain, path, secure, http_only, same_site, partitioned, other |

## Notes

- Cookie values are URI-decoded by default (`decodeURIComponent`); a malformed escape
  keeps the raw value. Pass `decode_values = false` to disable.
- `expires` is kept as the raw header string — parse it with a date crate (e.g.
  `httpdate`, `time`, `chrono`) if you need a timestamp.
- Attributes beyond the well-known ones are collected into `Cookie::other` as
  `(lower-cased key, value)` pairs. Keys are lower-cased with Rust's Unicode
  lowercasing; for non-ASCII custom keys this can differ from JavaScript on
  context-sensitive cases (e.g. Greek final sigma). Standard ASCII attributes
  (`Path`, `Secure`, …) are unaffected.

## License

Licensed under either of [Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) at
your option.