/*
Null httpd -- simple http server
Copyright (C) 2001-2002 Dan Cahill
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "nullhttpd.h"
/****************************************************************************
* dorequest()
*
* Purpose : Authenticate and direct the request to the correct function
* Args : None
* Returns : void
* Notes : None
***************************************************************************/
void dorequest(int sid)
{
char file[255];
if (read_header(sid)<0) {
closeconnect(sid, 1);
return;
}
logaccess(2, "%s - HTTP Request: %s %s", conn[sid].dat->in_RemoteAddr, conn[sid].dat->in_RequestMethod, conn[sid].dat->in_RequestURI);
snprintf(file, sizeof(file)-1, "%s%s", config.server_htdocs_dir, conn[sid].dat->in_RequestURI);
snprintf(conn[sid].dat->out_ContentType, sizeof(conn[sid].dat->out_ContentType)-1, "text/html");
if (strncmp(conn[sid].dat->in_RequestURI, "/cgi-bin/", 9)==0) {
cgi_main();
} else if (sendfile(sid, file)==0) {
return;
} else if (dirlist(sid)==0) {
return;
} else {
send_header(sid, 0, 200, "OK", "1", "text/html", -1, -1);
prints("