httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sklar <sk...@student.net>
Subject [PATCH] apache-1.3/src/support/ab.c - sending a cookie
Date Tue, 30 Mar 1999 20:07:31 GMT
I needed to do some benchmarking with ab on some sites that expected a
certain cookie to be sent, so here's a patch against ab.c rev 1.20 to
allow a cookie to specified on the commandline to get sent with the
request, e.g.

ab -C foo=bar http://www.sklar.com/index.html

will send along a

Cookie: foo=bar

header with the request.

-dave

-------------------

--- ab.c.orig   Tue Mar 30 15:02:44 1999
+++ ab.c        Tue Mar 30 15:01:19 1999
@@ -174,6 +174,7 @@
 char *postdata;                        /* *buffer containing data from
postfile */
 int postlen = 0;               /* length of data to be POSTed */
 char content_type[1024];       /* content type to put in POST header */
+char cookie[1024];              /* name and value for Cookie: header */
 int port = 80;                 /* port number */
 
 int use_html = 0;              /* use html in the report */
@@ -733,11 +734,13 @@
        sprintf(request, "GET %s HTTP/1.0\r\n"
                "User-Agent: ApacheBench/%s\r\n"
                "%s"
+               "%s"
                "Host: %s\r\n"
                "Accept: */*\r\n"
                "\r\n",
                path,
                VERSION,
+                (cookie[0] ? cookie : ""),
                keepalive ? "Connection: Keep-Alive\r\n" : "",
                hostname);
     }
@@ -745,6 +748,7 @@
        sprintf(request, "POST %s HTTP/1.0\r\n"
                "User-Agent: ApacheBench/%s\r\n"
                "%s"
+               "%s"
                "Host: %s\r\n"
                "Accept: */*\r\n"
                "Content-length: %d\r\n"
@@ -752,6 +756,7 @@
                "\r\n",
                path,
                VERSION,
+               (cookie[0] ? cookie : ""),
                keepalive ? "Connection: Keep-Alive\r\n" : "",
                hostname, postlen,
                (content_type[0]) ? content_type : "text/plain");
@@ -846,6 +851,7 @@
     fprintf(stderr, "    -t timelimit    Seconds to max. wait for
responses\n");
     fprintf(stderr, "    -p postfile     File containg data to
POST\n");
     fprintf(stderr, "    -T content-type Content-type header for
POSTing\n");
+    fprintf(stderr, "    -C cookie       name=value data for Cookie:
header\n");
     fprintf(stderr, "    -v verbosity    How much troubleshooting info
to print\n");
     fprintf(stderr, "    -w              Print out results in HTML
tables\n");
     fprintf(stderr, "    -x attributes   String to insert as table
attributes\n");
@@ -931,7 +937,7 @@
     tdstring = "bgcolor=white";
 
     optind = 1;
-    while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwx:y:z:")) > 0) {
+    while ((c = getopt(argc, argv, "n:c:t:T:C:p:v:kVhwx:y:z:")) > 0) {
        switch (c) {
        case 'n':
            requests = atoi(optarg);
@@ -962,6 +968,9 @@
            break;
        case 'T':
            strcpy(content_type, optarg);
+           break;
+       case 'C':
+           sprintf(cookie,"Cookie: %s\r\n",optarg);
            break;
        case 'V':
            copyright();

Mime
View raw message