Re: Customizing http access
I'll just use ht:Pack instead, thanks for the pointers though :-) On Mon, Jan 11, 2010 at 7:36 AM, Alexander Burger wrote: > On Sat, Jan 09, 2010 at 08:28:15PM +0100, Henrik Sarvell wrote: > > snag I had to solve. I couldn't find a global function so I made my own: > > > > (dm urlDecode> (Str) > >(pack > > (make > > (in (list 'echo Str) > > (while (char) > >(let Char @ > > (ifn (= Char "%") > > (unless (= "^J" Char) (link Char)) > > (link (char (hex (pack (char) (char > > Well, if I see this right, then there is indeed a function, 'ht:Pack': > > (dm urlDecode> (Str) > (ht:Pack (chop Str)) ) > > I would be rather reluctant to start such a heavy machinery like a pipe > to the external 'echo' program above, just to parse a string. You could > instead do > > (dm urlDecode> (Str) > (setq Str (chop Str)) > (pack > (make >(while (pop 'Str) > (let Char @ > (link > (if (= Char "%") >(char (hex (pack (cut 2 'Str >Char ) ) ) ) ) ) ) > > > > (in (list 'echo Str)) is a trick I got from Armadillo (originally as a > way > > to use (xml) with strings), however it seems like it's attaching a > newline > > before end of input so maybe not the best solution here (when using (xml) > > it's a non issue). > > The newline could be suppressed with the '-n' option to echo. > > > > Are there any suggestions on how the above could have been done in a > better > > way? Apart from that final newline I like the idea of being able to > stream a > > string internally to be able to utilize the input channel functions, in > this > > case (char). > > Yeah, this is really a deficit in PicoLisp, not being able to use the > standard 'in' function directly on symbols (strings) :-( > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe >
Re: Customizing http access
On Sat, Jan 09, 2010 at 08:28:15PM +0100, Henrik Sarvell wrote: > snag I had to solve. I couldn't find a global function so I made my own: > > (dm urlDecode> (Str) >(pack > (make > (in (list 'echo Str) > (while (char) >(let Char @ > (ifn (= Char "%") > (unless (= "^J" Char) (link Char)) > (link (char (hex (pack (char) (char Well, if I see this right, then there is indeed a function, 'ht:Pack': (dm urlDecode> (Str) (ht:Pack (chop Str)) ) I would be rather reluctant to start such a heavy machinery like a pipe to the external 'echo' program above, just to parse a string. You could instead do (dm urlDecode> (Str) (setq Str (chop Str)) (pack (make (while (pop 'Str) (let Char @ (link (if (= Char "%") (char (hex (pack (cut 2 'Str Char ) ) ) ) ) ) ) > (in (list 'echo Str)) is a trick I got from Armadillo (originally as a way > to use (xml) with strings), however it seems like it's attaching a newline > before end of input so maybe not the best solution here (when using (xml) > it's a non issue). The newline could be suppressed with the '-n' option to echo. > Are there any suggestions on how the above could have been done in a better > way? Apart from that final newline I like the idea of being able to stream a > string internally to be able to utilize the input channel functions, in this > case (char). Yeah, this is really a deficit in PicoLisp, not being able to use the standard 'in' function directly on symbols (strings) :-( Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
I finally had the time to walk through a complete test using the production code I will utilize to actually consume the real time pusub updates and it works flawlessly. It will enable me to get content updates in real time, and only the updates, hence no need to repeatedly download whole feeds in order to look for updates. Currently AFAIK only Google's FeedBurner has implemented the service but that makes up for more than 70% of the content I subscribe to so it's far from trivial despite the novelty. Not all content providers will ping FB when they publish something though, hence breaking the real time process. But it's still better than having to parse the feeds myself, instead I let FB do the heavy lifting and just send me the new stuff. Thanks for the help on this one! The feed url (see hub.topic below) comes url encoded which was the final snag I had to solve. I couldn't find a global function so I made my own: (dm urlDecode> (Str) (pack (make (in (list 'echo Str) (while (char) (let Char @ (ifn (= Char "%") (unless (= "^J" Char) (link Char)) (link (char (hex (pack (char) (char (in (list 'echo Str)) is a trick I got from Armadillo (originally as a way to use (xml) with strings), however it seems like it's attaching a newline before end of input so maybe not the best solution here (when using (xml) it's a non issue). Are there any suggestions on how the above could have been done in a better way? Apart from that final newline I like the idea of being able to stream a string internally to be able to utilize the input channel functions, in this case (char). My current (go): (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 "?")) (for KeyVal (split (cadr L) "&") (let Res (split KeyVal "=") (push '*Get (cons (pack (car Res)) (pack (cadr Res) (out Sock (cond (*Get (httpHead "text/plain; charset=utf-8") (and (= "hoobaloo" (cdr (assoc "hub.verify_token" *Get))) (= "subscribe" (cdr (assoc "hub.mode" *Get))) (db 'xmlUrl '+Feed (urlDecode> '+Gh (cdr (assoc "hub.topic" *Get (prin (cdr (assoc "hub.challenge" *Get) (*Xml (hubSubImport> '+Rss *Xml) (httpStat 204 "No Content")) (T (http404) (bye)) (close Sock))) (server *UsePort "@start")) The above is respecting the current version of the protocol: http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.2.html On Sun, Dec 20, 2009 at 4:06 PM, Alexander Burger wrote: > On Sun, Dec 20, 2009 at 01:59:59PM +0100, Henrik Sarvell wrote: > > Apparently it was a GET request but I managed to parse it. > > ... > > (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) > > ... > > I wouldn't match for the GET in the header loop. GET must be the very > first line, otherwise I would abort the transaction (like I wrote in my > previous example in case of POST). Also, no need for the global '*Get' > then. > > So this looks like an if/else condition. If GET is the first line, you > accept the variables from the URL, else if it is POST and "atom" is > matched, you read the XML. > > > > > 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. > > What's missing here is a call to 'out'. Currently, the socket 'Sock' is > only used in 'in'. > > (out Sock > (httpHead "text/plain; charset=3Dutf-8") > ... >
Re: Customizing http access
On Sun, Dec 20, 2009 at 01:59:59PM +0100, Henrik Sarvell wrote: > Apparently it was a GET request but I managed to parse it. > ... > (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) > ... I wouldn't match for the GET in the header loop. GET must be the very first line, otherwise I would abort the transaction (like I wrote in my previous example in case of POST). Also, no need for the global '*Get' then. So this looks like an if/else condition. If GET is the first line, you accept the variables from the URL, else if it is POST and "atom" is matched, you read the XML. > 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. What's missing here is a call to 'out'. Currently, the socket 'Sock' is only used in 'in'. (out Sock (httpHead "text/plain; charset=3Dutf-8") ... If the output channel is not set to 'Sock', it will write to whatever channel is currently open (initially standard output). BTW: I would not call '_htSet' here: >(ifn (cdr (setq L (split L "=3D"))) > (cons (htArg (car L))) > (_htSet (car L) (htArg (cadr L))) As you see from the naming conventions, the underscore in the name indicates a "local" function. And indeed, '_htSet' may call (throw "http") which will crash your system if called in the wrong context. And it does some permission checks on the variables which may not be suitable here. '_htSet' does basically only a simple assignment, and follows some rules of the application server which are not needed here, so I would recommend to use something simpler, and more to the point. Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
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 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 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
Re: Customizing http access
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 wro= te: > 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
Re: Customizing http access
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 =3D> 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: > (in Sock >(off *Xml *ContLen) >(use (L @X @Y) (use (L @U @H @X @Y) (when (and (line) (match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H) @) ) > (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=unsubscribe
Re: Customizing http access
So I've come up with the below: (de go () (rollback) (task (port 4000) # Background task listening on port 4000 (let? Sock (accept @) # Accept a connection (unless (fork) # Child process (in Sock (off *Xml *ContLen) (use (L @X @Y) # copy paste from _htHead start (while (setq L (line)) (cond ((match '(@Y "a" "t" "o" "m" @X) L) (setq *Xml T)) ((match '(~(chop "conte...@ength: ") . @X) L) (setq *ContLen (format (pack @X)) # = end (cond (*Xml (hubSubImport> '+Rss (ht:Read *ContLen)) (httpStat 204 "No Content")) ((if *ContLen (ht:Read @) (line)) # copy paste from http start (for L (split @ '&) (when (cdr (setq L (split L "=3D"))) (_htSet (car L) (ht:Pack (cadr L) #end (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 (T (http404) (bye)) # Exit child process (close Sock))) # Close socket in parent process (server *UsePort "@start")) Observe the copy paste areas from (_htHead) and (http), the one I wonder about is the part where a "normal" request would be split and its keys =3D> values would parsed. Is that part enough or is there something else happening in the big/original flow? If there is then the (req 'key) stuff further down will probably not work properly, where (req) is: (de req (Key) (get Key 'http)) /Henrik On Sat, Dec 19, 2009 at 2:17 PM, Alexander Burger wro= te: > On Sat, Dec 19, 2009 at 10:05:24AM +0100, Alexander Burger wrote: >> 1. Fork for each transaction: >> >> =A0 =A0 =A0 (task (port 4000) =A0# Background task listening on port 400= 0 >> =A0 =A0 =A0 =A0 =A0(when (setq Sock (accept @)) =A0# Accept a connection >> =A0 =A0 =A0 =A0 =A0 =A0 (unless (fork) =A0# Child process >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(task P) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(close P) =A0# Close port in child proces= s >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(in Sock >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (match ...) =A0# Read payload data >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (ht:Read ...) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (dosomething) ) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(bye) ) =A0# Exit child process >> =A0 =A0 =A0 =A0 =A0 =A0 (close Sock) ) ) =A0# Close socket in parent pro= cess > > Henrik just pointed out in IRC that 'P' is not bound. > > In fact, the two lines > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(task P) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(close P) =A0# Close port in child proces= s > > are not really needed here. They are necessary only when the child > process would last longer, and do some event handling on its own. > > So I would use the corrected version: > > =A0 =A0 =A0(task (port 4000) =A0# Background task listening on port 4000 > =A0 =A0 =A0 =A0 (let? Sock (accept @) =A0# Accept a connection > =A0 =A0 =A0 =A0 =A0 =A0(unless (fork) =A0# Child process > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (in Sock > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(match ...) =A0# Read payload data > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(ht:Read ...) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(dosomething) ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (bye) ) =A0# Exit child process > =A0 =A0 =A0 =A0 =A0 =A0(close Sock) ) ) =A0# Close socket in parent proce= ss > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
On Sat, Dec 19, 2009 at 10:05:24AM +0100, Alexander Burger wrote: > 1. Fork for each transaction: > > (task (port 4000) # Background task listening on port 4000 > (when (setq Sock (accept @)) # Accept a connection > (unless (fork) # Child process >(task P) >(close P) # Close port in child process >(in Sock > (match ...) # Read payload data > (ht:Read ...) > (dosomething) ) >(bye) ) # Exit child process > (close Sock) ) ) # Close socket in parent process Henrik just pointed out in IRC that 'P' is not bound. In fact, the two lines >(task P) >(close P) # Close port in child process are not really needed here. They are necessary only when the child process would last longer, and do some event handling on its own. So I would use the corrected version: (task (port 4000) # Background task listening on port 4000 (let? Sock (accept @) # Accept a connection (unless (fork) # Child process (in Sock (match ...) # Read payload data (ht:Read ...) (dosomething) ) (bye) ) # Exit child process (close Sock) ) ) # Close socket in parent process Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
Hi Henrik, > So I made a change that would prevent (throw "http) to be called and > everything worked. Great! > ... > (if *Xml > (setq *Xml > (ht:Read *ContLen)) > (cond > (*MPartLim (_htMultipart)) > ((if *ContLen (ht:Read @) (line)) >(for L (split @ '&) >... Just a side note: The 'if' and 'cond' might better be merged to a single 'cond': ... (cond (*Xml (setq *Xml (ht:Read *ContLen))) (*MPartLim (_htMultipart)) ((if *ContLen (ht:Read @) (line)) (for L (split @ '&) ... > Could it be as simple as: (task (port 4000) (load "hubimport.l")) and > then do whatever it is I want to do in the hubimport.l file? Like Yes, but - as you know - if that code accesses the database, it should run as a sister process to other DB processes. So it should either do a (fork) on each transaction, or do a (fork) on startup and handle requests in a permanent child process. 1. Fork for each transaction: (task (port 4000) # Background task listening on port 4000 (when (setq Sock (accept @)) # Accept a connection (unless (fork) # Child process (task P) (close P) # Close port in child process (in Sock (match ...) # Read payload data (ht:Read ...) (dosomething) ) (bye) ) # Exit child process (close Sock) ) ) # Close socket in parent process 2. Handle requests in a permanent child: (unless (fork) # Start a permanent child process (task (port 4000) (let? Sock (accept @) (in Sock (match ...) # Read payload data (ht:Read ...) (dosomething) ) (close Sock) ) ) (wait) ) # Wait in the background event loop I would probably go with 1), as this is more stable and modular. If a child crashes or hangs, it does not disturb the rest of the system. Also, more than one request can be handled at a time. Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
After I sent the prior mail to the list Alex and I had a discussion on IRC and we realized that there were two problems: 1.) In the interaction in this thread Alex assumed I was running a simple dedicated process with its own simple http function, I wasn't though, I was testing with the full monty, editing the real http function. 2.) I realized that due to my changes the routing would never take place and that that has been the problem all the time. So I made a change that would prevent (throw "http) to be called and everything worked. Except the Hub was still reporting failure. This prompted me to instead try ht:Read content length since I had noticed that the line routine was lagging, and it worked!! The pertinent section now works like this: ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H) L) (on *Post) (off *MPartLim *MPartEnd) (_htHead) (if *Xml (setq *Xml (ht:Read *ContLen)) (cond (*MPartLim (_htMultipart)) ((if *ContLen (ht:Read @) (line)) (for L (split @ '&) (when (cdr (setq L (split L "=3D"))) (_htSet (car L) (ht:Pack (cadr L))) ) ) ) (T (throw "http") Now I've gathered that the best way of handling this is through listening on a dedicated port through (task). Could it be as simple as: (task (port 4000) (load "hubimport.l")) and then do whatever it is I want to do in the hubimport.l file? Like defining a dedicated simple version of (http) and using it to read the payload for instance? /Henrik On Thu, Dec 17, 2009 at 11:25 PM, Henrik Sarvell wrote= : > I've changed the whole http function to: > > (de http (S) > =A0 (setq *Xml > =A0 =A0 =A0(make > =A0 =A0 =A0 =A0 (in S > =A0 =A0 =A0 =A0 =A0 =A0(until (eof) (link (line T)) > =A0 (and S (close S) (task S))) > > I'm not even trying to do anything with the headers. However with an > http function looking like this I'm not even able to access the server > directly on http://localhost:3000/@pubsub it just hangs and refuses to > return anything. > > As expected I'm of course getting things where they are supposed to be > now, the four last lines of the output: > > =A0line =3D "" > =A0link : "" > =A0link =3D "" > =A0task : 40 NIL > =A0task =3D NIL > > I also tried simply replacing with > > (when *Xml > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq *Xml > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(make > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (until (eof) (link (l= ine T)) > > in the real http but as we expected the problem of not finishing with > executing @pubsub is still there. > > > On Thu, Dec 17, 2009 at 10:50 AM, Alexander Burger = wrote: >> On Wed, Dec 16, 2009 at 10:15:22PM +0100, Henrik Sarvell wrote: >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (make >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(until (eof) (li= ne T) (link @) >> >> Here might be the problem: The (link @) has no definite value in '@', as >> there is no preceding flow function returning non-NIL (as described >> under "Flow functions" in "doc/ref.html#atres"). >> >> So better would be >> >> =A0 (make >> =A0 =A0 =A0(until (eof) >> =A0 =A0 =A0 =A0 (link (line T)) ) ) >> >> >> Note that in the previous case of >> >> =A0 (make >> =A0 =A0 =A0(while (line T) >> =A0 =A0 =A0 =A0 (link @) ) ) >> >> the situation was different, as 'while' always set the (non-NIL) value >> of '@' appropriately. >> >> Cheers, >> - Alex >> -- >> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe >> > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
I've changed the whole http function to: (de http (S) (setq *Xml (make (in S (until (eof) (link (line T)) (and S (close S) (task S))) I'm not even trying to do anything with the headers. However with an http function looking like this I'm not even able to access the server directly on http://localhost:3000/@pubsub it just hangs and refuses to return anything. As expected I'm of course getting things where they are supposed to be now, the four last lines of the output: line =3D "" link : "" link =3D "" task : 40 NIL task =3D NIL I also tried simply replacing with (when *Xml (setq *Xml (make (until (eof) (link (line T)) in the real http but as we expected the problem of not finishing with executing @pubsub is still there. On Thu, Dec 17, 2009 at 10:50 AM, Alexander Burger wr= ote: > On Wed, Dec 16, 2009 at 10:15:22PM +0100, Henrik Sarvell wrote: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (make >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(until (eof) (lin= e T) (link @) > > Here might be the problem: The (link @) has no definite value in '@', as > there is no preceding flow function returning non-NIL (as described > under "Flow functions" in "doc/ref.html#atres"). > > So better would be > > =A0 (make > =A0 =A0 =A0(until (eof) > =A0 =A0 =A0 =A0 (link (line T)) ) ) > > > Note that in the previous case of > > =A0 (make > =A0 =A0 =A0(while (line T) > =A0 =A0 =A0 =A0 (link @) ) ) > > the situation was different, as 'while' always set the (non-NIL) value > of '@' appropriately. > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
On Wed, Dec 16, 2009 at 10:15:22PM +0100, Henrik Sarvell wrote: > (make >(until (eof) (line T) (link @) Here might be the problem: The (link @) has no definite value in '@', as there is no preceding flow function returning non-NIL (as described under "Flow functions" in "doc/ref.html#atres"). So better would be (make (until (eof) (link (line T)) ) ) Note that in the previous case of (make (while (line T) (link @) ) ) the situation was different, as 'while' always set the (non-NIL) value of '@' appropriately. Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
I should really be more patient with myself before posting, I promise this will be the last one for today, anyway I tried the following: (when *Xml (setq *Xml (make (until (eof) (line T) (link @) And I now get this at the end instead, the full body finally but the script still stalls, my @pubsub function still isn't getting executed and the hub still reports failure: line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "T" "y" "p" "e" ":" " " "a" "p" "p" "l" "i" "c" "a" "t" "i" "o" "n" "/" "a" "t" "o" "m" "+" "x" "m" "l") line : line =3D NIL _htHead =3D T line : T line =3D "" link : T link =3D T line : T line =3D "http://www.w3.org/2005/Atom\";>henrik's streamhttp://localhost:8081//atom/stream/henrikhenrik" link : T link =3D T line : T line =3D NIL link : T link =3D T line : T line =3D "jpoihouhhttp://localhost:8081/notice= /cefae94a-5ace-494d-beaf-212722f9f8b1http://localhost:8081/notice/cefae94a-5ace-494d-beaf-212722f9f8b1\= "/>oihoihoih2009-12-16T22:01:42+01:0<= /entry>" link : T link =3D T line : T line =3D "" link : T link =3D T http =3D NIL On Wed, Dec 16, 2009 at 9:47 PM, Henrik Sarvell wrote: > I think I was a bit quick in stating earlier that I got the whole > body, the PHP dump again: > > > http://www.w3.org/2005/Atom";>henrik's > streamhttp://localhost:8081//atom/stream/henrik<= name>henrik > > 8h98h98http://localhost:8081/notice/13caea6a-50= 16-4504-8b55-d995d37d78bc href=3D"http://localhost:8081/notice/13caea6a-5016-4504-8b55-d995d37d78bc= "/>89gh97gh92009-12-14T22:25:02+01:0<= /entry> > > > Note the gap there, between the author tag and the beginning of the > entry tag, looks like an empty line to me, could that have anything to > do with it? > > > > On Wed, Dec 16, 2009 at 9:12 PM, Henrik Sarvell wrot= e: >> Good idea, the explicit linking, it shows me I'm actually getting the >> body, however somewhere later on I'm stalling. I keep forgetting that >> traceAll doesn't in fact trace everything ;-) >> >> My @pubsub function is not executing (and the hub reports failure), >> which it is when I access it through the browser without the atom/xml >> content type, so something with my approach is wrong. >> >> The pertinent section in (http) now looks like this: >> >> (when *Xml >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq *Xml >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(make >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (while (line T) (lin= k @ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (close S) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (task S) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (off S) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (throw "http")) >> >> I thought the solution might lie in cleaning up after reading >> everything but it didn't help, oh well it's there now anyway. >> >> Below is what I get when i both traceAll, link and line, maybe it will >> get us closer to the solution: >> >> =A0mime : "swf" "application/x-shockwave-flash" 3600 >> =A0mime =3D (("s" "w" "f") "application/x-shockwave-flash" 3600) >> =A0redef : (ht:Pack (Lst) (ht:Pack (replace Lst "+" " "))) >> =A0redef =3D "ht:Pack" >> =A0server : 3000 "@start" >> =A0task : 38 ((http @)) >> =A0 link : 38 >> =A0 link =3D 38 >> =A0task =3D (38 (http @)) >> =A0http : 38 >> =A0 line : >> =A0 line =3D ("P" "O" "S" "T" " " "/" "@" "p" "u" "b" "s" "u" "b" " " "H= " >> "T" "T" "P" "/" "1" "." "1") >> =A0 _htHead : >> =A0 =A0line : >> =A0 =A0line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "L" "e" "n" "g" "t" "h" >> ":" " " "4" "7" "0") >> =A0 =A0line : >> =A0 =A0line =3D ("A" "c" "c" "e" "p" "t" "-" "E" "n" "c" "o" "d" "i" "n" >> "g" ":" " " "g" "z" "i" "p") >> =A0 =A0line : >> =A0 =A0line =3D ("X" "-" "H" "u" "b" "-" "S" "i" "g" "n" "a" "t" "u" "r" >> "e" ":" " " "s" "h" "a" "1" "=3D" "2" "0" "9" "1" "c" "9" "4" "b" "2" >> "1" "d" "5" "4" "a" "9" "f" "9" "2" "6" "5" "4" "5" "4" "2" "2" "1" >> "f" "f" "5" "9" "a" "1" "5" "b" "0" "c" "4" "d" "8" "f") >> =A0 =A0line : >> =A0 =A0line =3D ("U" "s" "e" "r" "-" "A" "g" "e" "n" "t" ":" " " "A" "p" >> "p" "E" "n" "g" "i" "n" "e" "-" "G" "o" "o" "g" "l" "e" ";" " " "(" >> "+" "h" "t" "t" "p" ":" "/" "/" "c" "o" "d" "e" "." "g" "o" "o" "g" >> "l" "e" "." "c" "o" "m" "/" "a" "p" "p" "e" "n" "g" "i" "n" "e" ")") >> =A0 =A0line : >> =A0 =A0line =3D ("H" "o" "s" "t" ":" " " "l" "o" "c" "a" "l" "h" "o" "s" >> "t" ":" "3" "0" "0" "0") >> =A0 =A0line : >> =A0 =A0line =3D ("R" "e" "f" "e" "r" "e" "r" ":" " " "h" "t" "t" "p" ":" >> "/" "/" "l" "o" "c" "a" "l" "h" "o" "s" "t" "/") >> =A0 =A0line : >> =A0 =A0line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "T" "y" "p" "e" ":" " " >> "a" "p" "p" "l" "i" "c" "a" "t" "i" "o" "n" "/" "a" "t" "o" "m" "+" >> "x" "m" "l") >> =A0 =A0line : >> =A0 =A0line =3D NIL >> =A0 _htHead =3D T >> =A0 line : T >> =A0 line =3D "" >> =A0 link : "" >> =A0 link =3D "" >> =A0 line : T >> =A0 line =3D "http://www.w3.org/
Re: Customizing http access
I think I was a bit quick in stating earlier that I got the whole body, the PHP dump again: http://www.w3.org/2005/Atom";>henrik's streamhttp://localhost:8081//atom/stream/henrikhenrik 8h98h98http://localhost:8081/notice/13caea6a-5016= -4504-8b55-d995d37d78bchttp://localhost:8081/notice/13caea6a-5016-4504-8b55-d995d37d78bc"/= >89gh97gh92009-12-14T22:25:02+01:0 Note the gap there, between the author tag and the beginning of the entry tag, looks like an empty line to me, could that have anything to do with it? On Wed, Dec 16, 2009 at 9:12 PM, Henrik Sarvell wrote: > Good idea, the explicit linking, it shows me I'm actually getting the > body, however somewhere later on I'm stalling. I keep forgetting that > traceAll doesn't in fact trace everything ;-) > > My @pubsub function is not executing (and the hub reports failure), > which it is when I access it through the browser without the atom/xml > content type, so something with my approach is wrong. > > The pertinent section in (http) now looks like this: > > (when *Xml > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq *Xml > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(make > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (while (line T) (link= @ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (close S) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (task S) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (off S) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (throw "http")) > > I thought the solution might lie in cleaning up after reading > everything but it didn't help, oh well it's there now anyway. > > Below is what I get when i both traceAll, link and line, maybe it will > get us closer to the solution: > > =A0mime : "swf" "application/x-shockwave-flash" 3600 > =A0mime =3D (("s" "w" "f") "application/x-shockwave-flash" 3600) > =A0redef : (ht:Pack (Lst) (ht:Pack (replace Lst "+" " "))) > =A0redef =3D "ht:Pack" > =A0server : 3000 "@start" > =A0task : 38 ((http @)) > =A0 link : 38 > =A0 link =3D 38 > =A0task =3D (38 (http @)) > =A0http : 38 > =A0 line : > =A0 line =3D ("P" "O" "S" "T" " " "/" "@" "p" "u" "b" "s" "u" "b" " " "H" > "T" "T" "P" "/" "1" "." "1") > =A0 _htHead : > =A0 =A0line : > =A0 =A0line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "L" "e" "n" "g" "t" "h" > ":" " " "4" "7" "0") > =A0 =A0line : > =A0 =A0line =3D ("A" "c" "c" "e" "p" "t" "-" "E" "n" "c" "o" "d" "i" "n" > "g" ":" " " "g" "z" "i" "p") > =A0 =A0line : > =A0 =A0line =3D ("X" "-" "H" "u" "b" "-" "S" "i" "g" "n" "a" "t" "u" "r" > "e" ":" " " "s" "h" "a" "1" "=3D" "2" "0" "9" "1" "c" "9" "4" "b" "2" > "1" "d" "5" "4" "a" "9" "f" "9" "2" "6" "5" "4" "5" "4" "2" "2" "1" > "f" "f" "5" "9" "a" "1" "5" "b" "0" "c" "4" "d" "8" "f") > =A0 =A0line : > =A0 =A0line =3D ("U" "s" "e" "r" "-" "A" "g" "e" "n" "t" ":" " " "A" "p" > "p" "E" "n" "g" "i" "n" "e" "-" "G" "o" "o" "g" "l" "e" ";" " " "(" > "+" "h" "t" "t" "p" ":" "/" "/" "c" "o" "d" "e" "." "g" "o" "o" "g" > "l" "e" "." "c" "o" "m" "/" "a" "p" "p" "e" "n" "g" "i" "n" "e" ")") > =A0 =A0line : > =A0 =A0line =3D ("H" "o" "s" "t" ":" " " "l" "o" "c" "a" "l" "h" "o" "s" > "t" ":" "3" "0" "0" "0") > =A0 =A0line : > =A0 =A0line =3D ("R" "e" "f" "e" "r" "e" "r" ":" " " "h" "t" "t" "p" ":" > "/" "/" "l" "o" "c" "a" "l" "h" "o" "s" "t" "/") > =A0 =A0line : > =A0 =A0line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "T" "y" "p" "e" ":" " " > "a" "p" "p" "l" "i" "c" "a" "t" "i" "o" "n" "/" "a" "t" "o" "m" "+" > "x" "m" "l") > =A0 =A0line : > =A0 =A0line =3D NIL > =A0 _htHead =3D T > =A0 line : T > =A0 line =3D "" > =A0 link : "" > =A0 link =3D "" > =A0 line : T > =A0 line =3D "http://www.w3.org/2005/Atom\";>henrik= 's > streamhttp://localhost:8081//atom/stream/henrik<= name>henrik" > =A0 link : "http://www.w3.org/2005/Atom\";>henrik's > streamhttp://localhost:8081//atom/stream/henrik<= name>henrik" > =A0 link =3D "http://www.w3.org/2005/Atom\";>henrik= 's > streamhttp://localhost:8081//atom/stream/henrik<= name>henrik" > =A0 line : T > =A0 line =3D NIL > =A0 task : 38 NIL > =A0 task =3D NIL > =A0http =3D NIL > > > > On Wed, Dec 16, 2009 at 6:20 PM, Alexander Burger w= rote: >> Hi Henrik, >> >>> ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H= ) L) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (on *Post) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (off *MPartLim *MPartEnd) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (_htHead) >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (and *Xml >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq *Xml >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (make >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(while (link (ht= :In T (line T)) >> >> 'ht:In' must be called only once, right on the body following the >> header. So I would expect that >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0... >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(_htHead) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(and *Xml >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq *Xml >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(ht:In T >> =A0 =A0 =A0 =A0 =
Re: Customizing http access
Good idea, the explicit linking, it shows me I'm actually getting the body, however somewhere later on I'm stalling. I keep forgetting that traceAll doesn't in fact trace everything ;-) My @pubsub function is not executing (and the hub reports failure), which it is when I access it through the browser without the atom/xml content type, so something with my approach is wrong. The pertinent section in (http) now looks like this: (when *Xml (setq *Xml (make (while (line T) (link @ (close S) (task S) (off S) (throw "http")) I thought the solution might lie in cleaning up after reading everything but it didn't help, oh well it's there now anyway. Below is what I get when i both traceAll, link and line, maybe it will get us closer to the solution: mime : "swf" "application/x-shockwave-flash" 3600 mime =3D (("s" "w" "f") "application/x-shockwave-flash" 3600) redef : (ht:Pack (Lst) (ht:Pack (replace Lst "+" " "))) redef =3D "ht:Pack" server : 3000 "@start" task : 38 ((http @)) link : 38 link =3D 38 task =3D (38 (http @)) http : 38 line : line =3D ("P" "O" "S" "T" " " "/" "@" "p" "u" "b" "s" "u" "b" " " "H" "T" "T" "P" "/" "1" "." "1") _htHead : line : line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "L" "e" "n" "g" "t" "h" ":" " " "4" "7" "0") line : line =3D ("A" "c" "c" "e" "p" "t" "-" "E" "n" "c" "o" "d" "i" "n" "g" ":" " " "g" "z" "i" "p") line : line =3D ("X" "-" "H" "u" "b" "-" "S" "i" "g" "n" "a" "t" "u" "r" "e" ":" " " "s" "h" "a" "1" "=3D" "2" "0" "9" "1" "c" "9" "4" "b" "2" "1" "d" "5" "4" "a" "9" "f" "9" "2" "6" "5" "4" "5" "4" "2" "2" "1" "f" "f" "5" "9" "a" "1" "5" "b" "0" "c" "4" "d" "8" "f") line : line =3D ("U" "s" "e" "r" "-" "A" "g" "e" "n" "t" ":" " " "A" "p" "p" "E" "n" "g" "i" "n" "e" "-" "G" "o" "o" "g" "l" "e" ";" " " "(" "+" "h" "t" "t" "p" ":" "/" "/" "c" "o" "d" "e" "." "g" "o" "o" "g" "l" "e" "." "c" "o" "m" "/" "a" "p" "p" "e" "n" "g" "i" "n" "e" ")") line : line =3D ("H" "o" "s" "t" ":" " " "l" "o" "c" "a" "l" "h" "o" "s" "t" ":" "3" "0" "0" "0") line : line =3D ("R" "e" "f" "e" "r" "e" "r" ":" " " "h" "t" "t" "p" ":" "/" "/" "l" "o" "c" "a" "l" "h" "o" "s" "t" "/") line : line =3D ("C" "o" "n" "t" "e" "n" "t" "-" "T" "y" "p" "e" ":" " " "a" "p" "p" "l" "i" "c" "a" "t" "i" "o" "n" "/" "a" "t" "o" "m" "+" "x" "m" "l") line : line =3D NIL _htHead =3D T line : T line =3D "" link : "" link =3D "" line : T line =3D "http://www.w3.org/2005/Atom\";>henrik's streamhttp://localhost:8081//atom/stream/henrikhenrik" link : "http://www.w3.org/2005/Atom\";>henrik's streamhttp://localhost:8081//atom/stream/henrikhenrik" link =3D "http://www.w3.org/2005/Atom\";>henrik's streamhttp://localhost:8081//atom/stream/henrikhenrik" line : T line =3D NIL task : 38 NIL task =3D NIL http =3D NIL On Wed, Dec 16, 2009 at 6:20 PM, Alexander Burger wro= te: > Hi Henrik, > >> ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H)= L) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (on *Post) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (off *MPartLim *MPartEnd) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (_htHead) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (and *Xml >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq *Xml >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (make >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(while (link (ht:= In T (line T)) > > 'ht:In' must be called only once, right on the body following the > header. So I would expect that > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0... > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(_htHead) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(and *Xml > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq *Xml > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(ht:In T > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (make > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(while (line T= ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (link @) = ) ) ) ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ... ) > > Note that I also changed > > =A0 =A0 =A0 =A0 (while (link (line T))) > > to > > =A0 =A0 =A0 =A0 (while (line T) > =A0 =A0 =A0 =A0 =A0 =A0(link @) ) > > because the former will link also the last NIL (on EOF) into the list > returned by 'make', which might not be desired. > > > The rest in '_htHead' looks all right. > > >> Trying to run the above results in the hub reporting a failure to >> deliver its payload, and traceAll gives me this when the hub tries to >> deliver: >> >> =A0server : 3000 "@start" >> =A0 task : 38 ((http @)) >> =A0 task =3D3D (38 (http @)) >> =A0 http : 38 >> =A0 =A0_htHead : >> =A0 =A0_htHead =3D3D T >> =A0 http =3D3D NIL >> >> It seems execution is not getting very far? > > This is because 'traceAll' traces only Lisp functions,
Re: Customizing http access
Hi Henrik, > ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H) L) > (on *Post) > (off *MPartLim *MPartEnd) > (_htHead) > (and *Xml > (setq *Xml > (make >(while (link (ht:In T (line T)) 'ht:In' must be called only once, right on the body following the header. So I would expect that ... (_htHead) (and *Xml (setq *Xml (ht:In T (make (while (line T) (link @) ) ) ) ) ... ) Note that I also changed (while (link (line T))) to (while (line T) (link @) ) because the former will link also the last NIL (on EOF) into the list returned by 'make', which might not be desired. The rest in '_htHead' looks all right. > Trying to run the above results in the hub reporting a failure to > deliver its payload, and traceAll gives me this when the hub tries to > deliver: > > server : 3000 "@start" > task : 38 ((http @)) > task =3D (38 (http @)) > http : 38 >_htHead : >_htHead =3D T > http =3D NIL > > It seems execution is not getting very far? This is because 'traceAll' traces only Lisp functions, and there are perhaps only built-in functions being called. You must explicitly 'trace' other functions you are interested in, e.g (trace 'line) and (trace 'link) or (mapc trace '(line link ..)). Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
Still no luck, at this point I have no idea if I'm doing something illegal from a PicoLisp point of view or a HTTP point of view, maybe someone can shed some light on this. During testing I have modified (http) and (_htHead) directly, when I've discovered something that works I expect to be able patch instead. In (http): .. ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H) L) (on *Post) (off *MPartLim *MPartEnd) (_htHead) (and *Xml (setq *Xml (make (while (link (ht:In T (line T)) (throw "http")) (cond (*MPartLim (_htMultipart)) ... If a flag *Xml has been set to T I had hoped the above would get at the HTTP POST body, the part labeled as RAW by PHP above. (de _htHead () (use (L @X @Y) (setq *Http1 (format (car @H)) *Chunked (gt0 *Http1) *Xml NIL) (if (index "~" @U) (setq *ConId (pack (head @ @U)) @U (cdr (nth @U @))) (off *ConId) ) (while (setq L (line)) (cond ((match '(@Y "a" "t" "o" "m" @X) L) (setq *Xml T)) ... And setting the flag to T, I've been able to test this one properly, it's catching the content type header, I will make the match narrower when this works though. (de pubsub (httpHead "text/plain;") (cond ((and (=3D "vizual" (req 'hub.verify_token)) (=3D "subscribe" (req 'hub.mode))) (prin (req 'hub.challenge)) (bye)) (*Xml (out "pubsub_feed.xml" (prin (pack "the feed: " *Xml))) (ht:Out T (prin "OK")) (bye)) (T (http404 Finally the callback function which should output the contents to a file. Trying to run the above results in the hub reporting a failure to deliver its payload, and traceAll gives me this when the hub tries to deliver: server : 3000 "@start" task : 38 ((http @)) task =3D (38 (http @)) http : 38 _htHead : _htHead =3D T http =3D NIL It seems execution is not getting very far? On Tue, Dec 15, 2009 at 9:25 AM, Henrik Sarvell wrote: > Thanks Alex, I've actually tried advertising as both 1.0 and 1.1, > doesn't seem to make any difference, will try ht:Ln tonight. > > > > On Tue, Dec 15, 2009 at 7:39 AM, Alexander Burger w= rote: >> Hi Henrik, >> >>> Alex, you mentioned on IRC how to handle/read chunked content and of >>> course I forgot to save the buffer. Would you care to go through it >>> again please? >> >> This is fairly easy, when you use the functions 'ht:Out' and 'ht:In': >> >> =A0 (ht:Out T .. do printing ..) >> >> does chunked output, and >> >> =A0 (ht:In T .. do reading ..) >> >> the corresponding input. The first argument (here 'T') controls if there >> is any chunking at all. >> >> You could take the code in "lib/http.l", "lib/xhtml" and "lib/form.l" as >> an example. The global '*Chunked' is set in '_htHead' depending on the >> value of '*Http1', which in turn is zero or one, depending on the match >> of the first header line. For example, >> >> =A0 ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "."= @H) L) >> >> will set '@H' -> '*Http1' accordingly. >> >> Then further operation calls (ht:Out *Chunked ...). >> >> >> Besides this, you could also inhibit chunking simply by pretending to be >> a HTTP/1.0 server. Look in the 'http1' function in "lib/http.l". It >> outputs the response header depending on that global '*Http1', which >> could also be set by the program (independent of what the client sent) >> to zero before starting the response. >> >> Cheers, >> - Alex >> -- >> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe >> > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
Thanks Alex, I've actually tried advertising as both 1.0 and 1.1, doesn't seem to make any difference, will try ht:Ln tonight. On Tue, Dec 15, 2009 at 7:39 AM, Alexander Burger wro= te: > Hi Henrik, > >> Alex, you mentioned on IRC how to handle/read chunked content and of >> course I forgot to save the buffer. Would you care to go through it >> again please? > > This is fairly easy, when you use the functions 'ht:Out' and 'ht:In': > > =A0 (ht:Out T .. do printing ..) > > does chunked output, and > > =A0 (ht:In T .. do reading ..) > > the corresponding input. The first argument (here 'T') controls if there > is any chunking at all. > > You could take the code in "lib/http.l", "lib/xhtml" and "lib/form.l" as > an example. The global '*Chunked' is set in '_htHead' depending on the > value of '*Http1', which in turn is zero or one, depending on the match > of the first header line. For example, > > =A0 ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." = @H) L) > > will set '@H' -> '*Http1' accordingly. > > Then further operation calls (ht:Out *Chunked ...). > > > Besides this, you could also inhibit chunking simply by pretending to be > a HTTP/1.0 server. Look in the 'http1' function in "lib/http.l". It > outputs the response header depending on that global '*Http1', which > could also be set by the program (independent of what the client sent) > to zero before starting the response. > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
Hi Henrik, > Alex, you mentioned on IRC how to handle/read chunked content and of > course I forgot to save the buffer. Would you care to go through it > again please? This is fairly easy, when you use the functions 'ht:Out' and 'ht:In': (ht:Out T .. do printing ..) does chunked output, and (ht:In T .. do reading ..) the corresponding input. The first argument (here 'T') controls if there is any chunking at all. You could take the code in "lib/http.l", "lib/xhtml" and "lib/form.l" as an example. The global '*Chunked' is set in '_htHead' depending on the value of '*Http1', which in turn is zero or one, depending on the match of the first header line. For example, ((match '("P" "O" "S" "T" " " "/" @U " " "H" "T" "T" "P" "/" "1" "." @H) L) will set '@H' -> '*Http1' accordingly. Then further operation calls (ht:Out *Chunked ...). Besides this, you could also inhibit chunking simply by pretending to be a HTTP/1.0 server. Look in the 'http1' function in "lib/http.l". It outputs the response header depending on that global '*Http1', which could also be set by the program (independent of what the client sent) to zero before starting the response. Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
I've done some more examining and testing and I think the content might be chunked even though there's nothing advertised in the headers. Alex, you mentioned on IRC how to handle/read chunked content and of course I forgot to save the buffer. Would you care to go through it again please? I also had a PHP script subscribe to my test hub where I simply outputted all the magic global variables, here is the result, maybe it might shed some light (note the payload XML I'm after there in HTTP_RAW_POST_DATA): [GLOBALS] =3D> Array *RECURSION* [HTTP_RAW_POST_DATA] =3D> http://www.w3.org/2005/Atom";>henrik's streamhttp://localhost:8081//atom/stream/henrikhenrik 8h98h98http://localhost:8081/notice/13caea6a-5016= -4504-8b55-d995d37d78bchttp://localhost:8081/notice/13caea6a-5016-4504-8b55-d995d37d78bc"/= >89gh97gh92009-12-14T22:25:02+01:0 [_ENV] =3D> Array ( [APACHE_PID_FILE] =3D> /var/run/apache2.pid [PATH] =3D> /usr/local/bin:/usr/bin:/bin [LANG] =3D> C [APACHE_RUN_GROUP] =3D> www-data [APACHE_RUN_USER] =3D> www-data [PWD] =3D> / ) [HTTP_ENV_VARS] =3D> Array ( [APACHE_PID_FILE] =3D> /var/run/apache2.pid [PATH] =3D> /usr/local/bin:/usr/bin:/bin [LANG] =3D> C [APACHE_RUN_GROUP] =3D> www-data [APACHE_RUN_USER] =3D> www-data [PWD] =3D> / ) [_POST] =3D> Array ( ) [HTTP_POST_VARS] =3D> Array ( ) [_GET] =3D> Array ( ) [HTTP_GET_VARS] =3D> Array ( ) [_COOKIE] =3D> Array ( ) [HTTP_COOKIE_VARS] =3D> Array ( ) [_SERVER] =3D> Array ( [CONTENT_LENGTH] =3D> 469 [HTTP_ACCEPT_ENCODING] =3D> gzip [HTTP_X_HUB_SIGNATURE] =3D> sha1=3D3e8a0378ef256672b47a3628128949315d3e43da [HTTP_USER_AGENT] =3D> AppEngine-Google; (+http://code.google.com/appengine) [HTTP_HOST] =3D> localhost [HTTP_REFERER] =3D> http://localhost/ [CONTENT_TYPE] =3D> application/atom+xml [PATH] =3D> /usr/local/bin:/usr/bin:/bin [SERVER_SIGNATURE] =3D> Apache/2.2.12 (Ubuntu) Server at localhost Port 80 [SERVER_SOFTWARE] =3D> Apache/2.2.12 (Ubuntu) [SERVER_NAME] =3D> localhost [SERVER_ADDR] =3D> ::1 [SERVER_PORT] =3D> 80 [REMOTE_ADDR] =3D> ::1 [DOCUMENT_ROOT] =3D> /var/www [SERVER_ADMIN] =3D> webmas...@localhost [SCRIPT_FILENAME] =3D> /var/www/pubsub.php [REMOTE_PORT] =3D> 45083 [GATEWAY_INTERFACE] =3D> CGI/1.1 [SERVER_PROTOCOL] =3D> HTTP/1.1 [REQUEST_METHOD] =3D> POST [QUERY_STRING] =3D> [REQUEST_URI] =3D> /pubsub.php [SCRIPT_NAME] =3D> /pubsub.php [PHP_SELF] =3D> /pubsub.php [REQUEST_TIME] =3D> 1260825911 [argv] =3D> Array ( ) [argc] =3D> 0 ) On Mon, Dec 14, 2009 at 9:08 AM, Alexander Burger wro= te: > Hi Henrik, > >> Content-Length: 477 >> Accept-Encoding: gzipX-Hub-Signature: >> sha1=3Dc22189670d1aeb04d0333d737b3e97f74ccb380e >> User-Agent: AppEngine-Google; (+http://code.google.com/appengine) >> Host: localhost:3000 >> Referer: http://localhost/ >> Content-Type: application/atom+xml >> >> And the feed contents in the body. >> >> I'm missing something fundamental because I'm not able to get at the >> body using the following addition in the conditions in _htHead: >> >> ((match '(@Y "a" "t" "o" "m" @X) L) >> =A0 (setq *Xml (till))) > > The (till) will get the whole stream, until it hits EOF. > > For one thing, there might be no EOF, if the protocol is HTTP/1.1 which > will not necessarily close the connection. Also (in case of HTTP/1.1) > you must used be prepared to used chunked transfer to read the data. > > Then, the line "Content-Type: application/atom+xml" must not necessarily > be the last line in the HTTP header. The (till) will then read the rest > of the header as payload data which is probably not what you want. > > So you need to first read the whole header, until an empty line is > encountered, and remember in that course all flags and other data you > are interested in (as is done in '_htHead'). Then, after the empty line > was read, you can slurp in the data. > > Cheers, > - Alex > -- > UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe > -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe
Re: Customizing http access
Hi Henrik, > Content-Length: 477 > Accept-Encoding: gzipX-Hub-Signature: > sha1=c22189670d1aeb04d0333d737b3e97f74ccb380e > User-Agent: AppEngine-Google; (+http://code.google.com/appengine) > Host: localhost:3000 > Referer: http://localhost/ > Content-Type: application/atom+xml > > And the feed contents in the body. > > I'm missing something fundamental because I'm not able to get at the > body using the following addition in the conditions in _htHead: > > ((match '(@Y "a" "t" "o" "m" @X) L) > (setq *Xml (till))) The (till) will get the whole stream, until it hits EOF. For one thing, there might be no EOF, if the protocol is HTTP/1.1 which will not necessarily close the connection. Also (in case of HTTP/1.1) you must used be prepared to used chunked transfer to read the data. Then, the line "Content-Type: application/atom+xml" must not necessarily be the last line in the HTTP header. The (till) will then read the rest of the header as payload data which is probably not what you want. So you need to first read the whole header, until an empty line is encountered, and remember in that course all flags and other data you are interested in (as is done in '_htHead'). Then, after the empty line was read, you can slurp in the data. Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe