Loading tests/server/sws.c +106 −94 Original line number Diff line number Diff line Loading @@ -314,91 +314,12 @@ static void restore_signal_handlers(void) #endif } static int ProcessRequest(struct httprequest *req) /* based on the testno, parse the correct server commands */ static int parse_servercmd(struct httprequest *req) { char *line=&req->reqbuf[req->checkindex]; bool chunked = FALSE; static char request[REQUEST_KEYWORD_SIZE]; static char doc[MAXDOCNAMELEN]; char logbuf[456]; int prot_major, prot_minor; char *end; int error; end = strstr(line, end_of_headers); req->callcount++; logmsg("Process %d bytes request%s", req->offset, req->callcount > 1?" [CONTINUED]":""); /* try to figure out the request characteristics as soon as possible, but only once! */ if(use_gopher && (req->testno == DOCNUMBER_NOTHING) && !strncmp("/verifiedserver", line, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } else if((req->testno == DOCNUMBER_NOTHING) && sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", request, doc, &prot_major, &prot_minor) == 4) { char *ptr; req->prot_version = prot_major*10 + prot_minor; /* find the last slash */ ptr = strrchr(doc, '/'); /* get the number after it */ if(ptr) { FILE *stream; char *filename; if((strlen(doc) + strlen(request)) < 400) sprintf(logbuf, "Got request: %s %s HTTP/%d.%d", request, doc, prot_major, prot_minor); else sprintf(logbuf, "Got a *HUGE* request HTTP/%d.%d", prot_major, prot_minor); logmsg("%s", logbuf); if(!strncmp("/verifiedserver", ptr, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } if(!strncmp("/quit", ptr, 5)) { logmsg("Request-to-quit received"); req->testno = DOCNUMBER_QUIT; return 1; /* done */ } ptr++; /* skip the slash */ /* skip all non-numericals following the slash */ while(*ptr && !ISDIGIT(*ptr)) ptr++; req->testno = strtol(ptr, &ptr, 10); if(req->testno > 10000) { req->partno = req->testno % 10000; req->testno /= 10000; } else req->partno = 0; sprintf(logbuf, "Requested test number %ld part %ld", req->testno, req->partno); logmsg("%s", logbuf); int error; filename = test2file(req->testno); Loading Loading @@ -465,7 +386,7 @@ static int ProcessRequest(struct httprequest *req) req->writedelay = num; } else { logmsg("funny instruction found: %s", cmd); logmsg("Unknown <servercmd> instruction found: %s", cmd); } /* try to deal with CRLF or just LF */ check = strchr(cmd, '\r'); Loading @@ -488,6 +409,94 @@ static int ProcessRequest(struct httprequest *req) if(orgcmd) free(orgcmd); } return 0; /* OK! */ } static int ProcessRequest(struct httprequest *req) { char *line=&req->reqbuf[req->checkindex]; bool chunked = FALSE; static char request[REQUEST_KEYWORD_SIZE]; static char doc[MAXDOCNAMELEN]; char logbuf[456]; int prot_major, prot_minor; char *end = strstr(line, end_of_headers); req->callcount++; logmsg("Process %d bytes request%s", req->offset, req->callcount > 1?" [CONTINUED]":""); /* try to figure out the request characteristics as soon as possible, but only once! */ if(use_gopher && (req->testno == DOCNUMBER_NOTHING) && !strncmp("/verifiedserver", line, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } else if((req->testno == DOCNUMBER_NOTHING) && sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", request, doc, &prot_major, &prot_minor) == 4) { char *ptr; req->prot_version = prot_major*10 + prot_minor; /* find the last slash */ ptr = strrchr(doc, '/'); /* get the number after it */ if(ptr) { if((strlen(doc) + strlen(request)) < 400) sprintf(logbuf, "Got request: %s %s HTTP/%d.%d", request, doc, prot_major, prot_minor); else sprintf(logbuf, "Got a *HUGE* request HTTP/%d.%d", prot_major, prot_minor); logmsg("%s", logbuf); if(!strncmp("/verifiedserver", ptr, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } if(!strncmp("/quit", ptr, 5)) { logmsg("Request-to-quit received"); req->testno = DOCNUMBER_QUIT; return 1; /* done */ } ptr++; /* skip the slash */ /* skip all non-numericals following the slash */ while(*ptr && !ISDIGIT(*ptr)) ptr++; req->testno = strtol(ptr, &ptr, 10); if(req->testno > 10000) { req->partno = req->testno % 10000; req->testno /= 10000; } else req->partno = 0; sprintf(logbuf, "Requested test number %ld part %ld", req->testno, req->partno); logmsg("%s", logbuf); /* find and parse <servercmd> for this test */ parse_servercmd(req); } else { if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", Loading Loading @@ -532,6 +541,9 @@ static int ProcessRequest(struct httprequest *req) req->testno = req->connect_port?req->connect_port:DOCNUMBER_CONNECT; else req->testno = req->connect_port?DOCNUMBER_CONNECT:DOCNUMBER_BADCONNECT; /* find and parse <servercmd> for this test */ parse_servercmd(req); } else { logmsg("Did not find test number in PATH"); Loading Loading @@ -1979,7 +1991,7 @@ int main(int argc, char *argv[]) if(got_exit_signal) break; logmsg("====> Client disconnect"); logmsg("====> Client disconnect %d", req.connmon); if(req.connmon) { const char *keepopen="[DISCONNECT]\n"; Loading Loading
tests/server/sws.c +106 −94 Original line number Diff line number Diff line Loading @@ -314,91 +314,12 @@ static void restore_signal_handlers(void) #endif } static int ProcessRequest(struct httprequest *req) /* based on the testno, parse the correct server commands */ static int parse_servercmd(struct httprequest *req) { char *line=&req->reqbuf[req->checkindex]; bool chunked = FALSE; static char request[REQUEST_KEYWORD_SIZE]; static char doc[MAXDOCNAMELEN]; char logbuf[456]; int prot_major, prot_minor; char *end; int error; end = strstr(line, end_of_headers); req->callcount++; logmsg("Process %d bytes request%s", req->offset, req->callcount > 1?" [CONTINUED]":""); /* try to figure out the request characteristics as soon as possible, but only once! */ if(use_gopher && (req->testno == DOCNUMBER_NOTHING) && !strncmp("/verifiedserver", line, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } else if((req->testno == DOCNUMBER_NOTHING) && sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", request, doc, &prot_major, &prot_minor) == 4) { char *ptr; req->prot_version = prot_major*10 + prot_minor; /* find the last slash */ ptr = strrchr(doc, '/'); /* get the number after it */ if(ptr) { FILE *stream; char *filename; if((strlen(doc) + strlen(request)) < 400) sprintf(logbuf, "Got request: %s %s HTTP/%d.%d", request, doc, prot_major, prot_minor); else sprintf(logbuf, "Got a *HUGE* request HTTP/%d.%d", prot_major, prot_minor); logmsg("%s", logbuf); if(!strncmp("/verifiedserver", ptr, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } if(!strncmp("/quit", ptr, 5)) { logmsg("Request-to-quit received"); req->testno = DOCNUMBER_QUIT; return 1; /* done */ } ptr++; /* skip the slash */ /* skip all non-numericals following the slash */ while(*ptr && !ISDIGIT(*ptr)) ptr++; req->testno = strtol(ptr, &ptr, 10); if(req->testno > 10000) { req->partno = req->testno % 10000; req->testno /= 10000; } else req->partno = 0; sprintf(logbuf, "Requested test number %ld part %ld", req->testno, req->partno); logmsg("%s", logbuf); int error; filename = test2file(req->testno); Loading Loading @@ -465,7 +386,7 @@ static int ProcessRequest(struct httprequest *req) req->writedelay = num; } else { logmsg("funny instruction found: %s", cmd); logmsg("Unknown <servercmd> instruction found: %s", cmd); } /* try to deal with CRLF or just LF */ check = strchr(cmd, '\r'); Loading @@ -488,6 +409,94 @@ static int ProcessRequest(struct httprequest *req) if(orgcmd) free(orgcmd); } return 0; /* OK! */ } static int ProcessRequest(struct httprequest *req) { char *line=&req->reqbuf[req->checkindex]; bool chunked = FALSE; static char request[REQUEST_KEYWORD_SIZE]; static char doc[MAXDOCNAMELEN]; char logbuf[456]; int prot_major, prot_minor; char *end = strstr(line, end_of_headers); req->callcount++; logmsg("Process %d bytes request%s", req->offset, req->callcount > 1?" [CONTINUED]":""); /* try to figure out the request characteristics as soon as possible, but only once! */ if(use_gopher && (req->testno == DOCNUMBER_NOTHING) && !strncmp("/verifiedserver", line, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } else if((req->testno == DOCNUMBER_NOTHING) && sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT"s %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", request, doc, &prot_major, &prot_minor) == 4) { char *ptr; req->prot_version = prot_major*10 + prot_minor; /* find the last slash */ ptr = strrchr(doc, '/'); /* get the number after it */ if(ptr) { if((strlen(doc) + strlen(request)) < 400) sprintf(logbuf, "Got request: %s %s HTTP/%d.%d", request, doc, prot_major, prot_minor); else sprintf(logbuf, "Got a *HUGE* request HTTP/%d.%d", prot_major, prot_minor); logmsg("%s", logbuf); if(!strncmp("/verifiedserver", ptr, 15)) { logmsg("Are-we-friendly question received"); req->testno = DOCNUMBER_WERULEZ; return 1; /* done */ } if(!strncmp("/quit", ptr, 5)) { logmsg("Request-to-quit received"); req->testno = DOCNUMBER_QUIT; return 1; /* done */ } ptr++; /* skip the slash */ /* skip all non-numericals following the slash */ while(*ptr && !ISDIGIT(*ptr)) ptr++; req->testno = strtol(ptr, &ptr, 10); if(req->testno > 10000) { req->partno = req->testno % 10000; req->testno /= 10000; } else req->partno = 0; sprintf(logbuf, "Requested test number %ld part %ld", req->testno, req->partno); logmsg("%s", logbuf); /* find and parse <servercmd> for this test */ parse_servercmd(req); } else { if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", Loading Loading @@ -532,6 +541,9 @@ static int ProcessRequest(struct httprequest *req) req->testno = req->connect_port?req->connect_port:DOCNUMBER_CONNECT; else req->testno = req->connect_port?DOCNUMBER_CONNECT:DOCNUMBER_BADCONNECT; /* find and parse <servercmd> for this test */ parse_servercmd(req); } else { logmsg("Did not find test number in PATH"); Loading Loading @@ -1979,7 +1991,7 @@ int main(int argc, char *argv[]) if(got_exit_signal) break; logmsg("====> Client disconnect"); logmsg("====> Client disconnect %d", req.connmon); if(req.connmon) { const char *keepopen="[DISCONNECT]\n"; Loading