Hi Henrik,

> (cookie 'uid Uid)
> (setq *Cookies (cons 'uid Uid))
> (redirect (pack *Domain "@desktop")))

The problem is that 'redirect' does not set the cookies (see the
previous discussion and @lib/http.l code for 'redirect', 'httpStat'
and 'httpHead').

Also, you do not need (setq *Cookies (cons 'uid Uid)) because *Cookies
is only for cookies received, not the ones being sent ("*Cookies"
internal to @lib/http.l is used for that which is set by 'cookies'

> I don't know if something new has been introduced but I've been
> following the discussions and I don't think so, but I'm not 100% sure,
> hence this post.

nothing has been changed in this area as far as I am aware.

We discussed this issue recently (see "cookies & redirect fix" thread)
but there did not seem much demand for fixing this in the official
distribution (I seemed to be the only one using cookies;-).  Maybe now
is the right time to go ahead with the fix?

I would suggest putting this in @lib/http.l:

(de cookie @
   (let At (rest)
      (if (assoc (car At) "*Cookies")
         (con @ (cdr At))
         (push '"*Cookies" At) ) ) )

(de httpCookie (K V P E D S H)
   (prin "Set-Cookie: " (ht:Fmt K) "=" (ht:Fmt V) "; path=" (or P "/"))
   (when E (prin "; expires=" @))
   (when D (prin "; domain=" @))
   (when S (prin "; secure"))
   (when H (prin "; HttpOnly"))
   (prinl) )

(de httpCookies ()
   (mapc httpCookie "*Cookies") )

(redef httpHead (Typ Upd File Att)
   (http1 Typ Upd File Att)
   (and *Chunked (prinl "Transfer-Encoding: chunked^M"))
   (prinl "^M") )

(redef httpStat (N Str . @)
   (prinl "HTTP/1.0 " N " " Str "^M")
   (prinl "Server: PicoLisp^M")
   (while (args)
      (prinl (next) "^M") )
   (prinl "Content-Type: text/html^M")
   (prinl "Content-Length: " (+ 68 (length N) (* 2 (length Str))) "^M")
   (prinl "^M")
   (prinl "<HTML>")
   (prinl "<HEAD><TITLE>" N " " Str "</TITLE></HEAD>")
   (prinl "<BODY><H1>" Str "</H1></BODY>")
   (prinl "</HTML>") )

If Alex agrees, I can send the fix to be included in the official
distribution, otherwise you can use the patching code from the
"cookies & redirect fix" thread.


UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to