soegaard2
2019-9-14 18:56:20

soegaard2
2019-9-14 19:53:28

Running this: #lang racket (require racket/runtime-path web-server/http/id-cookie) (define-runtime-path cookie-salt.bin "cookie-salt.bin") (define cookie-salt (make-secret-salt/file cookie-salt.bin)) (make-id-cookie #"aname" #"avalue" #:key cookie-salt) gives me the error: ; expected: string? ; given: #"aname" ; in: an and/c case of ; the name argument of ; (->i ; ((name (and/c string? cookie-name?)) ; (data-or-key ; (maybe-key) ; (if (unsupplied-arg? maybe-key) ; bytes? ; (and/c string? cookie-value?)))) Since the documentation of cookie-name? says: > Returns #t if v is a valid cookie name (represented as a string or a byte string), #f otherwise. I expected using a byte-string to be ok.


soegaard2
2019-9-14 19:54:10

The contract says (and/c string? cookie-name?)) so I see why, I get the error. But is it intentional?


soegaard2
2019-9-14 19:54:47

Same goes for the value argument.


philip.mcgrath
2019-9-14 22:04:33

@soegaard2 Thanks for this report! When I updated web-server/http/id-cookie to use the new net/cookies with RFC 6265 support instead of the deprecated net/cookie, there were some inconsistencies with what contracts allowed byte-strings (e.g. https://github.com/RenaissanceBug/racket-cookies/commit/c745ee51e9a4914d232380abe65332d91d88f7f8)—I expect I just missed this one when fixing them. I will open a GitHub issue and try to patch this soon, or you can if you want.


soegaard2
2019-9-14 22:06:23

Go ahead!


soegaard2
2019-9-14 22:08:05

The id-cookies are great btw.


philip.mcgrath
2019-9-14 22:08:36

Yes, I am a big fan.


philip.mcgrath
2019-9-14 22:21:13

Though FYI, @soegaard2, byte-strings are just immediately passed to bytes->string/utf-8.


soegaard2
2019-9-14 22:23:17

Oh? I thought, I could save a few conversion if I used byte-strings. The binding value is byte string, so I just passed it along unchanged.


philip.mcgrath
2019-9-14 22:40:51

cookie-name and cookie-value are guaranteed to produce strings, and net/cookies manipulates them as strings internally: https://github.com/RenaissanceBug/racket-cookies/blob/master/net-cookies-lib/net/cookies/server.rkt


soegaard2
2019-9-14 22:50:51

The headers must be byte strings?