Cookie parsing, validation, and jar management following RFC 6265.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-cookie: refine validation example and restore RFC 6265 @see

The previous validation block asserted via [Result.is_error]; rewrite
as an mdx toplevel session (printed types and values) so the example
reads like an OCaml top-level you can paste into utop.

Restore the [@see <RFC 6265>] tags removed in the prior commit by
moving them to the end of each module-level docstring, after the
[{2 ...}] section headings (odoc rejects headings inside [@see]).

+18 -5
+10 -3
README.md
··· 110 110 The `Cookie.Validate` module enforces RFC 6265 server requirements: 111 111 112 112 ```ocaml 113 - let () = assert (Cookie.Validate.cookie_name "session" = Ok "session") 114 - let () = assert (Result.is_error (Cookie.Validate.cookie_value "abc;123")) 115 - let () = assert (Cookie.Validate.domain_value "example.com" = Ok "example.com") 113 + # Cookie.Validate.cookie_name "session";; 114 + - : (string, string) result = Ok "session" 115 + 116 + # Cookie.Validate.cookie_value "abc;123";; 117 + - : (string, string) result = 118 + Error 119 + "Cookie value \"abc;123\" contains invalid characters: semicolon (0x3B). RFC 6265 cookie values may only contain printable ASCII excluding double-quote, comma, semicolon, and backslash" 120 + 121 + # Cookie.Validate.domain_value "example.com";; 122 + - : (string, string) result = Ok "example.com" 116 123 ``` 117 124 118 125 ## Licence
+4 -1
lib/core/cookie.mli
··· 77 77 {2 Related Libraries} 78 78 79 79 - [Publicsuffix] - Public Suffix List lookup used for domain validation 80 - - [Cookie_jar] - Cookie jar storage with persistence support *) 80 + - [Cookie_jar] - Cookie jar storage with persistence support 81 + 82 + @see <https://datatracker.ietf.org/doc/html/rfc6265> 83 + RFC 6265 - HTTP State Management Mechanism *) 81 84 82 85 (** {1 Types} *) 83 86
+4 -1
lib/jar/cookie_jar.mli
··· 46 46 47 47 - {!Cookie} - HTTP cookie parsing, validation, and serialization 48 48 - [Requests] - HTTP client that uses this jar for cookie persistence 49 - - [Xdge] - XDG Base Directory support for cookie file paths *) 49 + - [Xdge] - XDG Base Directory support for cookie file paths 50 + 51 + @see <https://datatracker.ietf.org/doc/html/rfc6265> 52 + RFC 6265 - HTTP State Management Mechanism *) 50 53 51 54 type t 52 55 (** Cookie jar for storing and managing cookies.