1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

16 tests OK

This commit is contained in:
Daniel Stenberg 2002-02-22 15:40:17 +00:00
parent 85efa64c31
commit 417c8fb602
2 changed files with 22 additions and 5 deletions

View File

@ -145,11 +145,18 @@ sub runhttpserver {
if ( $data =~ /WE ROOLZ(: |)(\d*)/ ) { if ( $data =~ /WE ROOLZ(: |)(\d*)/ ) {
$pid = 0+$2; $pid = 0+$2;
if(!$pid) {
print "Test server already running with unkown pid! Use it...\n";
return;
}
if($verbose) { if($verbose) {
print "Test server already running with pid $pid, killing it...\n"; print "Test server already running with pid $pid, killing it...\n";
} }
} }
elsif($data ne "") { elsif($data ne "") {
print "GOT: $data\n";
print "An alien HTTP server is running on port $HOSTPORT\n", print "An alien HTTP server is running on port $HOSTPORT\n",
"Edit runtests.pl to use another port and rerun the test script\n"; "Edit runtests.pl to use another port and rerun the test script\n";
exit; exit;

View File

@ -29,7 +29,7 @@ char *spitout(FILE *stream, char *main, char *sub, int *size);
#define TEST_DATA_PATH "data/test%d" #define TEST_DATA_PATH "data/test%d"
static char *docfriends = "WE ROOLZ\r\n"; static char *docfriends = "HTTP/1.1 200 Mighty fine indeed\r\n\r\nWE ROOLZ\r\n";
static char *doc404 = "HTTP/1.1 404 Not Found\n" static char *doc404 = "HTTP/1.1 404 Not Found\n"
"Server: " VERSION "\n" "Server: " VERSION "\n"
"Connection: close\n" "Connection: close\n"
@ -125,7 +125,7 @@ void storerequest(char *reqbuf)
{ {
FILE *dump; FILE *dump;
dump = fopen(REQUEST_DUMP, "wb"); /* b is for windows-preparing */ dump = fopen(REQUEST_DUMP, "ab"); /* b is for windows-preparing */
if(dump) { if(dump) {
fwrite(reqbuf, 1, strlen(reqbuf), dump); fwrite(reqbuf, 1, strlen(reqbuf), dump);
@ -144,6 +144,7 @@ static int get_request(int sock, int *part)
char request[REQUEST_KEYWORD_SIZE]; char request[REQUEST_KEYWORD_SIZE];
unsigned int offset = 0; unsigned int offset = 0;
int prot_major, prot_minor; int prot_major, prot_minor;
char logbuf[256];
*part = 0; /* part zero equals none */ *part = 0; /* part zero equals none */
@ -189,7 +190,12 @@ static int get_request(int sock, int *part)
/* get the number after it */ /* get the number after it */
if(ptr) { if(ptr) {
if(!strcmp("/verifiedserver", ptr)) {
sprintf(logbuf, "Got request: %s %s HTTP/%d.%d",
request, doc, prot_major, prot_minor);
logmsg(logbuf);
if(!strncmp("/verifiedserver", ptr, 15)) {
logmsg("Are-we-friendly question received"); logmsg("Are-we-friendly question received");
return -2; return -2;
} }
@ -203,7 +209,8 @@ static int get_request(int sock, int *part)
test_no /= 10000; test_no /= 10000;
} }
logmsg("Found test number in PATH"); sprintf(logbuf, "Found test number %d in path", test_no);
logmsg(logbuf);
} }
else { else {
@ -238,6 +245,8 @@ static int send_doc(int sock, int doc, int part_no)
buffer = doc404; buffer = doc404;
ptr = NULL; ptr = NULL;
stream=NULL; stream=NULL;
count = strlen(buffer);
} }
else { else {
sprintf(filename, TEST_DATA_PATH, doc); sprintf(filename, TEST_DATA_PATH, doc);
@ -258,7 +267,8 @@ static int send_doc(int sock, int doc, int part_no)
do { do {
written = send(sock, buffer, count, 0); written = send(sock, buffer, count, 0);
if (written < 0) { if (written < 0) {
fclose(stream); if(stream)
fclose(stream);
return -1; return -1;
} }
count -= written; count -= written;