mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-12 22:10:40 -05:00
unset cookies needs the original value and cookie's key are case sensitive
This commit is contained in:
parent
8713cdb893
commit
961eb6af65
2 changed files with 7 additions and 5 deletions
|
|
@ -409,8 +409,8 @@ module Headers = struct
|
|||
|
||||
let set_cookie ?(props=[]) k v h =
|
||||
set "Set-Cookie" (SetCookie.set props k v) h
|
||||
let unset_cookie k h =
|
||||
set_cookie ~props:[MaxAge 0] k "UNSET" h
|
||||
let unset_cookie k v h =
|
||||
set_cookie ~props:[MaxAge 0] k v h
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -442,7 +442,9 @@ module Request = struct
|
|||
| Some x -> (try Some (int_of_string x) with _ -> None)
|
||||
| None -> None
|
||||
let set_header k v self = {self with headers=Headers.set k v self.headers}
|
||||
let get_cookie ?f self h = Headers.get ?f h self.cookies
|
||||
let get_cookie ?(f=fun x -> x) self h =
|
||||
try Some (f (List.assoc h self.cookies))
|
||||
with Not_found -> None
|
||||
let get_cookie_int self h = match get_cookie self h with
|
||||
| Some x -> (try Some (int_of_string x) with _ -> None)
|
||||
| None -> None
|
||||
|
|
|
|||
|
|
@ -232,8 +232,8 @@ module Headers : sig
|
|||
(** Set a cookie in the header
|
||||
@since 0.12 *)
|
||||
|
||||
val unset_cookie : string -> t -> t
|
||||
(** Unset a cookie in the header
|
||||
val unset_cookie : string -> string -> t -> t
|
||||
(** Unset a cookie in the header (needs key and values)
|
||||
@since 0.12 *)
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue