dirkx 99/09/27 13:27:37
Modified: src/support ab.c ab.8 Log: Adding a fifth, sixth or seventh wheel to this croaking cart... HEAD support. Revision Changes Path 1.31 +20 -9 apache-1.3/src/support/ab.c Index: ab.c =================================================================== RCS file: /x3/home/cvs/apache-1.3/src/support/ab.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- ab.c 1999/08/25 13:02:04 1.30 +++ ab.c 1999/09/27 20:27:24 1.31 @@ -254,7 +254,7 @@ out[0].iov_base = request; out[0].iov_len = reqlen; - if (posting) { + if (posting>0) { out[1].iov_base = postdata; out[1].iov_len = postlen; outcnt = 2; @@ -263,7 +263,7 @@ writev(c->fd,out, outcnt); #else write(c->fd,request,reqlen); - if (posting) { + if (posting>0) { write(c->fd,postdata,postlen); totalposted += (reqlen + postlen); } @@ -331,7 +331,7 @@ if (keepalive) printf("Keep-Alive requests: %d\n", doneka); printf("Total transferred: %d bytes\n", totalread); - if (posting) + if (posting>0) printf("Total POSTed: %d\n", totalposted); printf("HTML transferred: %d bytes\n", totalbread); @@ -340,7 +340,7 @@ printf("Requests per second: %.2f\n", 1000 * (float) (done) / timetaken); printf("Transfer rate: %.2f kb/s received\n", (float) (totalread) / timetaken); - if (posting) { + if (posting>0) { printf(" %.2f kb/s sent\n", (float) (totalposted) / timetaken); printf(" %.2f kb/s total\n", @@ -429,7 +429,7 @@ printf("<tr %s><th colspan=2 %s>Total transferred:</th>" "<td colspan=2 %s>%d bytes</td></tr>\n", trstring, tdstring, tdstring, totalread); - if (posting) + if (posting>0) printf("<tr %s><th colspan=2 %s>Total POSTed:</th>" "<td colspan=2 %s>%d</td></tr>\n", trstring, tdstring, tdstring, totalposted); @@ -445,7 +445,7 @@ printf("<tr %s><th colspan=2 %s>Transfer rate:</th>" "<td colspan=2 %s>%.2f kb/s received</td></tr>\n", trstring, tdstring, tdstring, (float) (totalread) / timetaken); - if (posting) { + if (posting>0) { printf("<tr %s><td colspan=2 %s> </td>" "<td colspan=2 %s>%.2f kb/s sent</td></tr>\n", trstring, tdstring, tdstring, @@ -769,13 +769,14 @@ FD_ZERO(&writebits); /* setup request */ - if (!posting) { - sprintf(request, "GET %s HTTP/1.0\r\n" + if (posting <= 0) { + sprintf(request, "%s %s HTTP/1.0\r\n" "User-Agent: ApacheBench/%s\r\n" "%s" "%s" "%s" "Host: %s\r\n" "Accept: */*\r\n" "%s" "\r\n", + (posting == 0) ? "GET" : "HEAD", path, VERSION, keepalive ? "Connection: Keep-Alive\r\n" : "", @@ -890,6 +891,7 @@ fprintf(stderr, " -T content-type Content-type header for POSTing\n"); fprintf(stderr, " -v verbosity How much troubleshooting info to print\n"); fprintf(stderr, " -w Print out results in HTML tables\n"); + fprintf(stderr, " -i Use HEAD instead of GET\n"); fprintf(stderr, " -x attributes String to insert as table attributes\n"); fprintf(stderr, " -y attributes String to insert as tr attributes\n"); fprintf(stderr, " -z attributes String to insert as td or th attributes\n"); @@ -983,7 +985,7 @@ auth[0] = '\0'; hdrs[0] = '\0'; optind = 1; - while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwx:y:z:C:H:P:A:")) > 0) { + while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwix:y:z:C:H:P:A:")) > 0) { switch (c) { case 'n': requests = atoi(optarg); @@ -997,7 +999,16 @@ case 'c': concurrency = atoi(optarg); break; + case 'i': + if (posting==1) + err("Cannot mix POST and HEAD"); + + posting = -1; + break; case 'p': + if (posting!=0) + err("Cannot mix POST and HEAD"); + if (0 == (r = open_postfile(optarg))) { posting = 1; } 1.7 +6 -1 apache-1.3/src/support/ab.8 Index: ab.8 =================================================================== RCS file: /x3/home/cvs/apache-1.3/src/support/ab.8,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ab.8 1999/04/07 14:51:43 1.6 +++ ab.8 1999/09/27 20:27:27 1.7 @@ -1,5 +1,5 @@ .TH ab 1 "March 1998" -.\" $Id: ab.8,v 1.6 1999/04/07 14:51:43 martin Exp $ +.\" $Id: ab.8,v 1.7 1999/09/27 20:27:27 dirkx Exp $ .\" Copyright (c) 1998-1999 The Apache Group. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -59,6 +59,8 @@ [ .B \-k ] [ +.B \-i +] [ .BI \-n " requests" ] [ .BI \-t " timelimit" @@ -112,6 +114,9 @@ .B \-k Enable the HTTP KeepAlive feature, i.e. perform multiple requests within one HTTP session instead. Default is no KeepAlive. +.TP 12 +.B \-i +Use an HTTP 'HEAD' instead of the GET method. Cannot be mixed with POST. .TP 12 .BI \-n " requests" Number of requests to perform for the benchmarking session. The default is to