Skip to content

Commit c745ee5

Browse files
committed
make-cookie should coerce name and value to strings
Currently, the contract for make-cookie accepts its name and value args as either strings or byte-strings, but the contracts for `cookie-name` and `cookie-value` require strings. This means that `(define c (make-cookie #"name" #"val")` succeeds, but `(cookie-name c)` raises an error. This is fixed by having make-cookie convert its arguments as needed.
1 parent 0d26815 commit c745ee5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎net/cookies/server.rkt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@
6161
#:secure? [secure? #f]
6262
#:http-only? [http-only? #f]
6363
#:extension [extension #f])
64-
(cookie name value expires max-age domain path secure? http-only? extension))
64+
(define (convert x)
65+
(if (bytes? x)
66+
(bytes->string/utf-8)
67+
x))
68+
(cookie (convert name) (convert value) expires max-age domain path secure? http-only? extension))
6569

6670
;; cookie -> String
6771
;; produce a Set-Cookie header suitable for sending to a client

0 commit comments

Comments
 (0)