newLISP -http mode cgi bug

Started by itistoday, October 24, 2008, 11:07:41 AM

Previous topic - Next topic

itistoday

I've just finished a massive endeavor.



I'm making a site that uses AJAX.  To know whether or not there was an error AJAX needs to get the right HTTP header, (e.g. "HTTP/1.0 200 OK", etc.)



The problem: newLISP does not do this properly, so testing the site via http mode in it did not work.



The solution: I spent a LONG time figuring out what was going on, and in the meantime learning about .cgi and HTTP.  I ended up compiling a custom version of newLISP to get things working because...



newLISP ignores .cgi Status: headers.  As far as I can tell from what I've read, the way things are supposed to work (and the way it works with Apache), a .cgi script does not write the first HTTP status header.  Instead it uses a custom Status: header that's pretty much identical, which the server is then supposed to translate to the corresponding HTTP status header.



newLISP does not do this.  It always responds with "HTTP/1.0 200 OK" as long as it managed to load the .cgi script and execute it.



So, what I'm doing right now for my testing purposes to get around this problem is I modified the newLISP binary to not print out the first header if it's running a .cgi script (and then my script prints it out for it, if it detects that newLISP is the server):



I modified the sendHTTPpage function in nl-web.c to take an extra parameter.


void sendHTTPpage(char * content, size_t size, char * media, int closeFlag, int headerFlag)
{
if ( headerFlag ) varPrintf(OUT_CONSOLE, "HTTP/1.0 200 OKrnServer: newLISP v.%d (%s)rn", version, ostype);


This is obviously a hack, the correct behavior should be that newLISP reads the headers that the cgi script provides and changes its response if it sees a Status header (e.g. "Status: 500 Internal Error").



(Oh, I'm going to be posting my template system for newLISP soon, as it's going to drive part of my site (see sig).)
Get your Objective newLISP groove on.

cormullion

#1
Great looking application/web site! (I can't comment on the Apache stuff...)

itistoday

#2
Quote from: "cormullion"Great looking application/web site! (I can't comment on the Apache stuff...)


Thanks!  Keep an eye on it, the release is coming up really soon... ;-)
Get your Objective newLISP groove on.

m i c h a e l

#3
itistoday,



Did you make the video we see at http://www.taoeffect.com/">taoeffect?



m i c h a e l

itistoday

#4
Quote from: "m i c h a e l"itistoday,



Did you make the video we see at http://www.taoeffect.com/">taoeffect?



m i c h a e l


I did indeed!  Hah, and I would be lying if I said it wasn't inspired by your amazing FOOP videos! :-D
Get your Objective newLISP groove on.

m i c h a e l

#5
Quote from: "itistoday"I did indeed! Hah, and I would be lying if I said it wasn't inspired by your amazing FOOP videos! :-D


Really? That's great! I really liked it. Espionage looks cool, too.



Speaking of the FOOP videos, I've been working on a new series that even Lutz doesn't know about yet! It's called "Fun with FOOP" and should be coming soon to a newLISP forum near you :-)



m i c h a e l

itistoday

#6
Quote from: "m i c h a e l"Really? That's great! I really liked it. Espionage looks cool, too.



Speaking of the FOOP videos, I've been working on a new series that even Lutz doesn't know about yet! It's called "Fun with FOOP" and should be coming soon to a newLISP forum near you :-)



m i c h a e l


Nice! Looking forward to seeing that! :-)
Get your Objective newLISP groove on.