From df3738bc914788b07835fb3570bd5affd683bd53 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 3 Feb 2009 22:32:35 +0000 Subject: [PATCH] cookies svn: r13397 original commit: 0b816d2942e593c6e4bfc9c8c0acbadff6a3b8ae --- collects/net/cookie-sig.ss | 1 + collects/net/cookie-unit.ss | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/collects/net/cookie-sig.ss b/collects/net/cookie-sig.ss index 409944a..390f5be 100644 --- a/collects/net/cookie-sig.ss +++ b/collects/net/cookie-sig.ss @@ -1,6 +1,7 @@ #lang scheme/signature cookie? +valid-domain? set-cookie cookie:add-comment cookie:add-domain diff --git a/collects/net/cookie-unit.ss b/collects/net/cookie-unit.ss index 8eb31e9..b3d3b5c 100644 --- a/collects/net/cookie-unit.ss +++ b/collects/net/cookie-unit.ss @@ -177,12 +177,12 @@ (define (get-all-results name cookies) (let loop ([c cookies]) (if (null? c) - '() - (let ([pair (car c)]) - (if (string=? name (car pair)) - ;; found an instance of cookie named `name' - (cons (cadr pair) (loop (cdr c))) - (loop (cdr c))))))) + '() + (let ([pair (car c)]) + (if (string=? name (car pair)) + ;; found an instance of cookie named `name' + (cons (cadr pair) (loop (cdr c))) + (loop (cdr c))))))) ;; which typically looks like: ;; (cookie . "test5=\"5\"; test1=\"1\"; test0=\"0\"; test1=\"20\"") @@ -274,11 +274,11 @@ (cond [(not (string? s)) (error* "expected string, given: ~e" s)] - + ;; for backwards compatibility, just use the given string if it will work [(rfc2068:token? s) s] [(rfc2068:quoted-string? s) s] - + ;; ... but if it doesn't work (i.e., it's just a normal message) then try ;; to convert it into a representation that will work [(rfc2068:quoted-string? (convert-to-quoted s)) @@ -298,9 +298,9 @@ (unless (string? s) (error* "string expected, received: ~a" s)) (if value? - (rfc2109:value? s) - ;; name: token - (rfc2068:token? s))) + (rfc2109:value? s) + ;; name: token + (rfc2068:token? s))) ;; Host names as per RFC 1123 and RFC952, more or less, anyway. :-) (define char-set:hostname @@ -311,11 +311,12 @@ #\.))) (define (valid-domain? dom) - (and ;; Domain must start with a dot (.) - (string=? (string-take dom 1) ".") - ;; The rest are tokens-like strings separated by dots - (string-every char-set:hostname dom) - (<= (string-length dom) 76))) + (and (string? dom) + ;; Domain must start with a dot (.) + (string=? (string-take dom 1) ".") + ;; The rest are tokens-like strings separated by dots + (string-every char-set:hostname dom) + (<= (string-length dom) 76))) (define (valid-path? v) (and (string? v) (rfc2109:value? v)))