newLISP -http mode cgi bug

For the Compleat Fan
Locked
itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

newLISP -http mode cgi bug

Post by 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.

Code: Select all

void sendHTTPpage(char * content, size_t size, char * media, int closeFlag, int headerFlag)
{
if ( headerFlag ) varPrintf(OUT_CONSOLE, "HTTP/1.0 200 OK\r\nServer: newLISP v.%d (%s)\r\n", 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
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

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

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Post by itistoday »

cormullion wrote: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
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post by m i c h a e l »

itistoday,

Did you make the video we see at taoeffect?

m i c h a e l

itistoday
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Post by itistoday »

m i c h a e l wrote:itistoday,

Did you make the video we see at 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
Posts: 394
Joined: Wed Apr 26, 2006 3:37 am
Location: Oregon, USA
Contact:

Post by m i c h a e l »

itistoday wrote: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
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Post by itistoday »

m i c h a e l wrote: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.

Locked