Thanks Tomas, yes I'm aware of that thread and will try it out.

I could've sworn though that I had it working somehow but I can't
remember anymore, could be that I've lost the working version because
I can't tell the difference anymore.

/Henrik


On Thu, Apr 2, 2009 at 10:01 AM, Tomas Hlavaty <kviet...@seznam.cz> wrote:
> 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'
> function).
>
>> 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;-). =A0Maybe now
> is the right time to go ahead with the fix?
>
> I would suggest putting this in @lib/http.l:
>
> (de cookie @
> =A0 (let At (rest)
> =A0 =A0 =A0(if (assoc (car At) "*Cookies")
> =A0 =A0 =A0 =A0 (con @ (cdr At))
> =A0 =A0 =A0 =A0 (push '"*Cookies" At) ) ) )
>
> (de httpCookie (K V P E D S H)
> =A0 (prin "Set-Cookie: " (ht:Fmt K) "=3D" (ht:Fmt V) "; path=3D" (or P "/=
"))
> =A0 (when E (prin "; expires=3D" @))
> =A0 (when D (prin "; domain=3D" @))
> =A0 (when S (prin "; secure"))
> =A0 (when H (prin "; HttpOnly"))
> =A0 (prinl) )
>
> (de httpCookies ()
> =A0 (mapc httpCookie "*Cookies") )
>
> (redef httpHead (Typ Upd File Att)
> =A0 (http1 Typ Upd File Att)
> =A0 (and *Chunked (prinl "Transfer-Encoding: chunked^M"))
> =A0 (httpCookies)
> =A0 (prinl "^M") )
>
> (redef httpStat (N Str . @)
> =A0 (prinl "HTTP/1.0 " N " " Str "^M")
> =A0 (prinl "Server: PicoLisp^M")
> =A0 (while (args)
> =A0 =A0 =A0(prinl (next) "^M") )
> =A0 (prinl "Content-Type: text/html^M")
> =A0 (httpCookies)
> =A0 (prinl "Content-Length: " (+ 68 (length N) (* 2 (length Str))) "^M")
> =A0 (prinl "^M")
> =A0 (prinl "<HTML>")
> =A0 (prinl "<HEAD><TITLE>" N " " Str "</TITLE></HEAD>")
> =A0 (prinl "<BODY><H1>" Str "</H1></BODY>")
> =A0 (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.
>
> Cheers,
>
> Tomas
> --
> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe
>
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to