Apparently it was a GET request but I managed to parse it.

The problem now is that it seems like the prints are on the wrong
channel, before when I was using the normal http etc in the @pubsub
function I didn't get headers printed to my terminal for instance
which I'm getting now. If I only can get the output to the right place
I think I'm done.

Here is what I have at the moment:

(de go ()
   (rollback)
   (task (port 4000)
      (let? Sock (accept @)
         (unless (fork)
            (in Sock
               (off *Xml *ContLen *Get)
               (use (L @X @Y @U)
                  (while (setq L (line))
                     (cond
                        ((match '("G" "E" "T" " " @U " " "H" "T" "T"
"P" "/" "1" "." @Y) L)
                           (setq *Get T))
                        ((match '(@Y "a" "t" "o" "m" @X) L)
                           (setq *Xml T))
                        ((match '(~(chop "conte...@ength: ") . @X) L)
                           (setq *ContLen (format (pack @X))))))
                  (cond
                     ((and *Xml *ContLen)
                        (setq *Xml (ht:Read *ContLen)))
                     (*Get
                        (setq
                           L (split @U "?")
                           L (mapcan
                                   '((L)
                                       (ifn (cdr (setq L (split L "=3D")))
                                          (cons (htArg (car L)))
                                          (_htSet (car L) (htArg (cadr L)))
                                          NIL ))
                                   (split (cadr L) "&")))))
                  (cond
                     (*Get
                        (httpHead "text/plain; charset=3Dutf-8")
                        (and
                           (=3D "vizual" (req 'hub.verify_token))
                           (=3D "subscribe" (req 'hub.mode))
                           #(db 'xmlUrl '+Feed (req 'hub.topic))
                           (prin (req 'hub.challenge))))
                     (*Xml
                        (hubSubImport> '+Rss *Xml)
                        (httpStat 204 "No Content"))
                     (T (http404)))))
            (bye))
         (close Sock)))
   (server *UsePort "@start"))

On Sun, Dec 20, 2009 at 10:56 AM, Henrik Sarvell <hsarv...@gmail.com> wrote=
:
> In this special case I don't need to extract url parameters just the
> POST contents in the case of verification.
>
> So I'll incorporate the POST match and give it a try.
>
>
> On Sun, Dec 20, 2009 at 8:52 AM, Alexander Burger <a...@software-lab.de> w=
rote:
>> On Sat, Dec 19, 2009 at 05:31:24PM +0100, Henrik Sarvell wrote:
>>> wonder about is the part where a "normal" request would be split and
>>> its keys =3D3D> values would parsed. Is that part enough or is there
>>> something else happening in the big/original flow?
>>
>> I would check for the initial POST, so that erroneous connections are
>> discarded:
>>
>>> =A0 =A0 =A0 =A0 =A0 =A0 (in Sock
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(off *Xml *ContLen)
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(use (L @X @Y)
>>
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (use (L @U @H @X @Y)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(when
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(and
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (line)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match '("P" "O" "S"=
 "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H) @) )
>>
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (while (setq L (line))
>>
>> Also, you might perhaps need '@U' later to extract URL parameters.
>>
>> I cannot see other things at the moment that might be needed here.
>> Further parsing of arguments, or permissions checks are not necessary,
>> right?
>>
>> Cheers,
>> - Alex
>> --
>> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe
>>
>
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to