diff --git a/CHANGES.md b/CHANGES.md index adbd144..5ba8586 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## v4.3.1 2025-06-15 +- remove check for duplicate cookies, navigator may send duplicate cookies and break the server +- allow max-age of 0L and -1L as it is a standard way to expire a cookie +- expiring a cookie should not remove domain and path + ## v4.3 2023-01-17 - add `expire` functionality (#8 @craff) - make http-cookie more lean by removing `fmt` dependency. diff --git a/docs/http-cookie/Http_cookie/index.html b/docs/http-cookie/Http_cookie/index.html index 56b662e..d32d977 100644 --- a/docs/http-cookie/Http_cookie/index.html +++ b/docs/http-cookie/Http_cookie/index.html @@ -1,5 +1,5 @@ -
Http_cookieA comprehensive and standards compliant HTTP cookies library for ocaml.
HTTP cookie is serialized as follows:
Cookie header in a HTTP requestSet-Cookie header in a HTTP response.The library supports consuming and creating HTTP cookie in both requests and responses.
The standards implemented by the library is
'Same-site' cookie attribute. Same-site
val pp : Stdlib.Format.formatter -> t -> unitval pp_same_site : Stdlib.Format.formatter -> same_site -> unitval pp_date_time : Stdlib.Format.formatter -> date_time -> unitpp_date_time fmt date_time pretty prints date_time in RFC 1123 format.
Example:
Sun, 06 Nov 1994 08:49:37 GMTval pp_rfc1123 : Stdlib.Format.formatter -> date_time -> unitAlias of pp_date_time.
val date_time :
+Http_cookie (http-cookie.Http_cookie) Module Http_cookie
A comprehensive and standards compliant HTTP cookies library for ocaml.
HTTP cookie is serialized as follows:
- In a
Cookie header in a HTTP request - In a
Set-Cookie header in a HTTP response.
The library supports consuming and creating HTTP cookie in both requests and responses.
The standards implemented by the library is
'Same-site' cookie attribute. Same-site
Pretty Printers
val pp : Stdlib.Format.formatter -> t -> unitval pp_same_site : Stdlib.Format.formatter -> same_site -> unitval pp_date_time : Stdlib.Format.formatter -> date_time -> unitpp_date_time fmt date_time pretty prints date_time in RFC 1123 format.
Example:
Sun, 06 Nov 1994 08:49:37 GMT
val pp_rfc1123 : Stdlib.Format.formatter -> date_time -> unitAlias of pp_date_time.
Create/Decode/Encode
val date_time :
year:int ->
month:
[ `Jan
@@ -30,5 +30,4 @@
?extension:string ->
name:string ->
string ->
- (t, string) Stdlib.resultcreate ~path ~domain ~expires ~max_age ~secure ~http_only ~same_site ~extension ~name
- value is Ok cookie if all of the given parameters are valid cookie attribute values. Otherwise it is Error error where error is the description of the error.
val of_cookie : string -> (t list, string) Stdlib.resultof_cookie header parses header - a string value which represents HTTP Cookie header value as defined in https://tools.ietf.org/html/rfc6265#section-4.2. It returns a list of Cookies if it is able to successfully parse s, otherwise it returns Error err.
It is an error to include duplicate cookie names.
Examples
This returns two cookies with cookie names SID and lang.
Http_cookie.of_cookie "SID=31d4d96e407aad42; lang=en-US"
val to_cookie : t -> stringto_cookie c serializes c into a string which can be encoded as value for HTTP Cookie header.
Example of a string returned by the function.
SID=31d4d96e407aad42
val to_set_cookie : t -> stringto_set_cookie c serializes cookie c into a string which can be encoded as value for HTTP Set-Cookie header.
The datetime format for expires attribute is specified in RFC 2616
Example of a string returned by the function,
SID=31d4d96e407aad42; Path=/; Secure; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT
val of_set_cookie : string -> (t, string) Stdlib.resultof_set_cookie s is Ok cookie if s can be parsed successfully to create t.
s is the HTTP 'Set-Cookie' header value. The syntax for the value is defined as set-cookie-string in RFC 6265, 4.1
Cookie Attributes
Cookie attributes are defined precisely at RFC 6262
val name : t -> stringname t returns a cookie name.
See cookie-name
val value : t -> stringvalue t returns a cookie value.
See cookie-value
val path : t -> string optionpath t returns cookie path attribute.
See cookie-path
val domain : t -> string optiondomain t returns cookie domain attribute.
See cookie-domain
expires t returns a coookie expires attribute.
See cookie-expires
val max_age : t -> int64 optionmax_age t returns a cookie max_age attribute.
See max-age and max-age-av
val secure : t -> boolsecure t returns a secure attribute.
See cookie-secure
val extension : t -> string optionextension t returns a cookie extension value.
See cookie-extension
Compare
compare c1 c2 returns 0 if c1 and c2 are equal, a positive integer if c1 is greater than c2 and a negative integer if c1 is less than c2
Updates
+ (t, string) Stdlib.resultcreate ~path ~domain ~expires ~max_age ~secure ~http_only ~same_site ~extension ~name value is Ok cookie if all of the given parameters are valid cookie attribute values. Otherwise it is Error error where error is the description of the error.
val of_cookie : string -> (t list, string) Stdlib.resultof_cookie header parses header - a string value which represents HTTP Cookie header value as defined in https://tools.ietf.org/html/rfc6265#section-4.2. It returns a list of Cookies if it is able to successfully parse s, otherwise it returns Error err.
It is an error to include duplicate cookie names.
Examples
This returns two cookies with cookie names SID and lang.
Http_cookie.of_cookie "SID=31d4d96e407aad42; lang=en-US"val to_cookie : t -> stringto_cookie c serializes c into a string which can be encoded as value for HTTP Cookie header.
Example of a string returned by the function.
SID=31d4d96e407aad42
val to_set_cookie : t -> stringto_set_cookie c serializes cookie c into a string which can be encoded as value for HTTP Set-Cookie header.
The datetime format for expires attribute is specified in RFC 2616
Example of a string returned by the function,
SID=31d4d96e407aad42; Path=/; Secure; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT
val of_set_cookie : string -> (t, string) Stdlib.resultof_set_cookie s is Ok cookie if s can be parsed successfully to create t.
s is the HTTP 'Set-Cookie' header value. The syntax for the value is defined as set-cookie-string in RFC 6265, 4.1
Cookie attributes are defined precisely at RFC 6262
val name : t -> stringname t returns a cookie name.
See cookie-name
val value : t -> stringvalue t returns a cookie value.
See cookie-value
val path : t -> string optionpath t returns cookie path attribute.
See cookie-path
val domain : t -> string optiondomain t returns cookie domain attribute.
See cookie-domain
expires t returns a coookie expires attribute.
See cookie-expires
val max_age : t -> int64 optionmax_age t returns a cookie max_age attribute.
See max-age and max-age-av
val secure : t -> boolsecure t returns a secure attribute.
See cookie-secure
val extension : t -> string optionextension t returns a cookie extension value.
See cookie-extension
compare c1 c2 returns 0 if c1 and c2 are equal, a positive integer if c1 is greater than c2 and a negative integer if c1 is less than c2
The entry point of this library is the module: Http_cookie.
The entry point of this library is the module: Http_cookie.