[racket] Print Cookie Path issue

From: J G Cho (gcho at fundingmatters.com)
Date: Fri Jul 1 20:00:34 EDT 2011

> Looks like "cookie-path", for one, can add the quotes (indirectly;
> ultimately in "convert-to-quoted").

I read that part after sending this email inquiry. It does seem to
have some rules RFC rules about quoting string.

;; value: token | quoted-string
(define (rfc2109:value? s)
  (or (rfc2068:token? s) (rfc2068:quoted-string? s)
      (rfc2068:quoted-string? (convert-to-quoted s))))

;; convert-to-quoted : string -> quoted-string?
;; takes the given string as a particular message, and converts the given
;; string to that representatation
(define (convert-to-quoted str)
  (string-append "\"" (regexp-replace* #rx"\"" str "\\\\\"") "\""))

;; string -> rfc2109:value?
(define (to-rfc2109:value s)
    [(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))
     => (λ (x) x)]
     (error* "could not convert the given string to an acceptable RFC
2109 value: ~s" s)]))

Not clear whose at fault per your info on how things work in the real
world as opposed to theory.

One thing that was omitted in my email:

When you do write cookie from Racket HTTP Server while at the top URL
(ie /) without #:path optional arg, FF stores path as /. And then the
server can read that cookie while at any URL. So the current work
around for me is to write the cookie while at / URL or put all cookie
needed URLs after where I write cookie. e.g. /cookied/abc or
/private/abc etc. Not ideal but not a deal breaker either.

> If you're not up to Wiresharking, I can do it this weekend, if you send me a
> standalone file of Racket code and a URL to a Web page that together
> demonstrate the problem.

Thanks for the offer but my codes are not in neat order and I can't
subject others to it. I will clean them up at some point and take up
on this offer should it remain on the table at such time.


Posted on the users mailing list.