Expand description
Parser for Netscape/curl cookie jar files.
Netscape cookie files are line-oriented. Each cookie line contains seven tab-separated fields: domain, tail-match flag, path, secure flag, expires, name, and value. This crate keeps cookie data as raw bytes so non-UTF-8 cookie names, values, paths, and domains can round-trip through the parser.
Empty lines and ordinary # comments are skipped. curl’s #HttpOnly_
extension is treated as metadata on the cookie rather than as a comment.
use netscape_cookie_file_parser::{parse_line, CookiePrefix};
let cookie = parse_line("#HttpOnly_.example.com\tTRUE\t/\tTRUE\t0\t__Secure-SID\tabc")
.unwrap()
.unwrap();
assert_eq!(cookie.domain, b"example.com");
assert!(cookie.http_only);
assert_eq!(cookie.prefix, CookiePrefix::Secure);Structs§
- Cookie
- One parsed cookie record from a Netscape cookie file.
- Netscape
Cookie Parser - Streaming parser over a Netscape cookie file.
- Parse
Error - Error returned when parsing a cookie stream.
Enums§
- Cookie
Prefix - Case-sensitive cookie name prefixes recognized by the parser.
- Parse
Error Kind - Detailed reason a cookie line or stream could not be parsed.
Functions§
- parse
- Parses all valid cookie lines from a buffered reader.
- parse_
line - Parses one Netscape cookie file line.
- parse_
lossy - Parses all valid cookie lines and skips malformed cookie records.