Skip to content
Snippets Groups Projects
Commit e2008a68 authored by rswindell's avatar rswindell
Browse files

Fixed index_file_name bug in check_request.

parent b6d408a2
Branches
Tags
No related merge requests found
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
static const char* server_name="Synchronet Web Server"; static const char* server_name="Synchronet Web Server";
static const char* newline="\r\n"; static const char* newline="\r\n";
static const char* unknown_mime_type="application/octet-stream";
extern const uchar* nular; extern const uchar* nular;
...@@ -497,6 +496,8 @@ static char *get_header(int id) ...@@ -497,6 +496,8 @@ static char *get_header(int id)
return(NULL); return(NULL);
} }
static const char* unknown_mime_type="application/octet-stream";
static const char* get_mime_type(char *ext) static const char* get_mime_type(char *ext)
{ {
uint i; uint i;
...@@ -561,9 +562,13 @@ BOOL send_headers(http_session_t *session, const char *status) ...@@ -561,9 +562,13 @@ BOOL send_headers(http_session_t *session, const char *status)
if(!ret) { if(!ret) {
sockprintf(session->socket,"%s: %d",get_header(HEAD_LENGTH),stats.st_size); sockprintf(session->socket,"%s: %d",get_header(HEAD_LENGTH),stats.st_size);
sockprintf(session->socket,"%s: %s",get_header(HEAD_TYPE),get_mime_type(strrchr(session->req.request,'.'))); sockprintf(session->socket,"%s: %s",get_header(HEAD_TYPE)
,get_mime_type(strrchr(session->req.request,'.')));
t=gmtime(&stats.st_mtime); t=gmtime(&stats.st_mtime);
sockprintf(session->socket,"%s: %s, %02d %s %04d %02d:%02d:%02d GMT",get_header(HEAD_LASTMODIFIED),days[t->tm_wday],t->tm_mday,months[t->tm_mon],t->tm_year+1900,t->tm_hour,t->tm_min,t->tm_sec); sockprintf(session->socket,"%s: %s, %02d %s %04d %02d:%02d:%02d GMT"
,get_header(HEAD_LASTMODIFIED)
,days[t->tm_wday],t->tm_mday,months[t->tm_mon]
,t->tm_year+1900,t->tm_hour,t->tm_min,t->tm_sec);
} }
sendsocket(session->socket,newline,2); sendsocket(session->socket,newline,2);
return(send_file); return(send_file);
...@@ -949,15 +954,12 @@ static BOOL check_request(http_session_t * session) ...@@ -949,15 +954,12 @@ static BOOL check_request(http_session_t * session)
send_error("404 Not Found",session); send_error("404 Not Found",session);
return(FALSE); return(FALSE);
} }
if(!strcmp(path,session->req.request))
session->req.send_location=TRUE;
if(!fexist(path)) { if(!fexist(path)) {
backslash(path); backslash(path);
strcat(path,startup->index_file_name); strcat(path,startup->index_file_name);
session->req.send_location=TRUE;
} }
if(strnicmp(session->req.request,root_dir,strlen(root_dir))) { if(strnicmp(path,root_dir,strlen(root_dir))) {
lprintf("%04d request = '%s'",session->socket,session->req.request); lprintf("%04d path = '%s'",session->socket,path);
lprintf("%04d root_dir = '%s'",session->socket,root_dir); lprintf("%04d root_dir = '%s'",session->socket,root_dir);
send_error("400 Bad Request",session); send_error("400 Bad Request",session);
session->req.keep_alive=FALSE; session->req.keep_alive=FALSE;
...@@ -967,7 +969,10 @@ static BOOL check_request(http_session_t * session) ...@@ -967,7 +969,10 @@ static BOOL check_request(http_session_t * session)
send_error("404 Not Found",session); send_error("404 Not Found",session);
return(FALSE); return(FALSE);
} }
if(!strcmp(path,session->req.request)) {
session->req.send_location=TRUE;
SAFECOPY(session->req.request,path); SAFECOPY(session->req.request,path);
}
/* Set default ARS to a 0-length string */ /* Set default ARS to a 0-length string */
session->req.ars[0]=0; session->req.ars[0]=0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment