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);
(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).)