I see, then we do like this instead:

(de http (S)
   (use (*Post L @U @H @X)
      (off *Port% *ContLen *Cookies "*Cookies" "*HtSet")
      (catch "http"
         (in S
            (cond
               ((not (setq L (line)))
                (task (close S))
                (off S)
                (throw "http") )
               ((match '("G" "E" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1"
"." @H) L)
                (_htHead)
                (setq *Get)
                (setq L (split @U "?"))
                (for KeyVal (split (cadr L) "&")
                   (let Res (split KeyVal "=")
                      (put '*Get (list (ht:Pack (car Res)) (ht:Pack (cadr
Res)))) ) )
                (setq *Get (getl '*Get)) )
               ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/"
"1" "." @H) L)
                (setq *Post)
                (off *MPartLim *MPartEnd)
                (_htHead)
                (cond
                   (*MPartLim (_htMultipart))
                   ((if *ContLen (ht:Read @) (line))
                    (for L (split @ '&)
                       (when (cdr (setq L (split L "=")))
                          (push '*Post (list (ht:Pack (car L)) (ht:Pack
(cadr L)))) ) ) )
                   (T (throw "http")) ) )
               (T
                  (out S
                     (if
                        (and
                           (match '(@U " " @ " " "H" "T" "T" "P" . @) L)
                           (member @U
                              (quote
                                 ("O" "P" "T" "I" "O" "N" "S")
                                 ("H" "E" "A" "D")
                                 ("P" "U" "T")
                                 ("D" "E" "L" "E" "T" "E")
                                 ("T" "R" "A" "C" "E")
                                 ("C" "O" "N" "N" "E" "C" "T") ) ) )
                        (httpStat 501 "Method Not Implemented" "Allow: GET,
POST")
                        (httpStat 400 "Bad Request") ) )
                  (task (close S))
                  (off S)
                  (throw "http") ) )
            (out S
               (cond
                  ((= '! (car @U))
                   (apply (val (intern (ht:Pack (cdr @U)))) L) )
                  ((tail '("." "l") @U)
                   (apply script L *Url) )
                  (T (httpEcho *Url "application/octet-stream" 1 T)) ) ) ) )
      (and S (=0 *Http1) (task (close S))) ) )

And then we can fetch values like this:

(de req (Key)
   (cadr (assoc Key *Post)))



On Sat, Jul 9, 2011 at 3:06 PM, Alexander Burger <a...@software-lab.de>wrote:

> Hi Henrik,
>
> >    (put '*Post "key" "value")
> > ..
> >
> > (("value" . "key") ("value" . "key")) "value"
> >
> > I don't get it, isn't the put statement before ht:Out supposed to replace
> > "value" under "key"?
>
> In principle, yes. However, the property functions use pointer equality,
> so if the key is a transient symbol, you must make sure that all
> occurrences of "key" mean the same, identical symbol. This is not the
> case if the string "key" is read during a transaction, while "key" in
> the program code was read from a source file or console session.
>
> Cheers,
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to