Re: cookies redirect fix

2009-03-21 Thread Tomas Hlavaty
Hi Alex,

 I'm a bit late with my reply, as I'm travelling through the south of
 Japan since almost two weeks, and have only infrequent (and
 unreliable) access to the internet.

enjoy your trip then;-)

( (loc *Cookies http))

I see.

 To just redefine 'httpStat' in the way you suggested, there is an even
 more dirty way ;-)

: (setq httpStat (insert 6 httpStat (assoc 'for httpHead)))

That's both beautiful and ugly at the same time:-o

Thanks for your ideas,

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


Re: cookies redirect fix

2009-03-20 Thread Alexander Burger
Hi Tomas,

thanks for your ideas and extensions! I'm a bit late with my reply, as
I'm travelling through the south of Japan since almost two weeks, and
have only infrequent (and unreliable) access to the internet.


You can easily circumvent the access problems of a transient symbol, if
you make use of 'loc' to get the transient symbol via some internal
symbol that refers to it, and then import it into your extensions with
'':

   ( (loc *Cookies http))

This clears the transient symbol table, and inserts the *Cookies
symbol from the 'http' function. Then *Cookies can be used in the rest
of the source file as if it were a local symbol.


To just redefine 'httpStat' in the way you suggested, there is an even
more dirty way ;-)

   : (setq httpStat (insert 6 httpStat (assoc 'for httpHead)))

This takes the expression (for L *Cookies ...)  from 'httpHead',
and builds it into 'httpStat', giving:

   : (pp 'httpStat)  
   (de 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)
  (for L *Cookies
 (prinl
Set-Cookie: 
(ht:Fmt (car L))
=
(ht:Fmt (cdr L))
; path=/ ) )
  (prinl
 Content-Length: 
 (+ 68 (length N) (* 2 (length Str)))
 ^M )
  (prinl ^M)
  (prinl HTML)
  (prinl HEADTITLE N   Str /TITLE/HEAD)
  (prinl BODYH1 Str /H1/BODY)
  (prinl /HTML) )
   - httpStat

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