]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
* Do not warn about size mismatch on responses without a Content-Length:
authorwessels <>
Fri, 17 Jul 1998 06:00:51 +0000 (06:00 +0000)
committerwessels <>
Fri, 17 Jul 1998 06:00:51 +0000 (06:00 +0000)
header
* Documented all the options in usage().
* Added -t to build a tracefile suitable for later input

A tracefile has the format

METHOD URL BODY-FILE SIZE CHECKSUM
Where:
METHOD          Is the HTTP method to use, usually GET
URL             The URL
BODY-FILE       Is a file to send as request body (- for none)
SIZE            The object size of the returned object (- to ignore)
CHECKSUM        A simple checksum of the object (- to ignore)

tcp-banger already accepts this format as input (was in one of my
previous tcp-banger patches).

/Henrik

test-suite/tcp-banger2.c

index 06f3e06a2643df9f8bde00d9dd001885ddb25bfd..d01fe5b71a7d590b562817140a9b0a501708e532 100644 (file)
@@ -101,6 +101,7 @@ static struct timeval now;
 static long total_bytes_written = 0;
 static long total_bytes_read = 0;
 static int opt_checksum = 0;
+FILE *trace_file = NULL;
 
 typedef void (CB) (int, void *);
 
@@ -113,6 +114,8 @@ struct _f {
 struct _request {
     int fd;
     char url[8192];
+    char method[16];
+    char requestbodyfile[256];
     char buf[READ_BUF_SZ * 2 + 1];
     int headfound;
     long validsize;
@@ -256,9 +259,10 @@ reply_done(int fd, void *data)
        else if (opt_checksum && r->validsum != r->sum)
            fprintf(stderr,"WARNING: %s invalid checksum wanted %d got %d\n",
                    r->url, r->validsum, r->sum);
-    } else if (opt_checksum) {
-       fprintf(stderr,"DONE: %s checksum %d size %d\n",
-               r->url, r->sum, r->bodysize);
+    }
+    if (trace_file) {
+       fprintf(trace_file,"%s %s %s %d %d\n",
+               r->method, r->url, r->requestbodyfile, r->bodysize, r->sum);
     }
     free(r);
 }
@@ -299,9 +303,17 @@ request(char *urlin)
        url=method;
        method="GET";
     }
+    if (!file)
+       file="-";
+    if (!size)
+       size="-";
+    if (!checksum)
+       checksum="-";
     r=calloc(1,sizeof *r);
     assert(r!=NULL);
     strcpy(r->url, url);
+    strcpy(r->method, method);
+    strcpy(r->requestbodyfile, file);
     r->fd = s;
     if (size && strcmp(size,"-")!=0)
        r->validsize=atoi(size);
@@ -309,6 +321,7 @@ request(char *urlin)
        r->validsize=-1; /* Unknown */
     if (checksum && strcmp(checksum,"-")!=0)
        r->validsum=atoi(checksum);
+    r->content_length=-1; /* Unknown */
     msg[0] = '\0';
     sprintf(buf,"%s %s HTTP/1.0\r\n", method, url);
     strcat(msg, buf);
@@ -409,7 +422,11 @@ read_url(int fd, void *junk)
 void
 usage(void)
 {
-    fprintf(stderr, "usage: %s: [-cir] -p port -h host -n max\n", progname);
+    fprintf(stderr, "usage: %s: -p port -h host -n max\n", progname);
+    fprintf(stderr, " -t <tracefile>  Save request trace\n");
+    fprintf(stderr, " -c              Check checksum agains trace\n");
+    fprintf(stderr, " -i              Send random If-Modified-Since times\n");
+    fprintf(stderr, " -l <seconds>    Connection lifetime timeout (default 60)\n");
 }
 
 int
@@ -430,7 +447,7 @@ main(argc, argv)
     progname = strdup(argv[0]);
     gettimeofday(&now, NULL);
     start = last = now;
-    while ((c = getopt(argc, argv, "p:h:n:icrl:")) != -1) {
+    while ((c = getopt(argc, argv, "p:h:n:icrl:t:")) != -1) {
        switch (c) {
        case 'p':
            proxy_port = atoi(optarg);
@@ -450,6 +467,11 @@ main(argc, argv)
        case 'c':
            opt_checksum = 1;
            break;
+       case 't':
+           opt_checksum = 1; /* Tracing requires checksums */
+           trace_file = fopen(optarg,"w");
+           assert(trace_file);
+           break;
        case 'r':
            opt_range = 1;
            break;