httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r534057 - in /httpd/httpd/branches/2.2.x: CHANGES support/ab.c
Date Tue, 01 May 2007 13:13:00 GMT
Author: jim
Date: Tue May  1 06:12:59 2007
New Revision: 534057

URL: http://svn.apache.org/viewvc?view=rev&rev=534057
Log:
Backports:

Correct behavior of HTTP request headers sent by ab in presence of -H command-
line overrides.  Previously, ab would concatenate a supplied -H User-Agent: 
header to the existing one, and send duplicate headers if either -H Host: or
-H Accept: were specified on the command line. 

Now, the default headers are not sent if they are overridden using the -H 
command-line flag. 

Submitted by:  Arvind Srinivasan arvind.srinivasan  sun.com
Reviewed by: sctemme
PR: 31268, 26554

The apr_port_t type is unsigned, but ab was using a signed format code in
its reports. PR 42070. Submitted by Takashi Sato serai  lans-tv.com, 
reviewed by sctemme.


Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/support/ab.c

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?view=diff&rev=534057&r1=534056&r2=534057
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Tue May  1 06:12:59 2007
@@ -1,7 +1,15 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.5
 
-   * mod_ldap: Remove the hardcoded size limit parameter for
+  *) ab.c: Correct behavior of HTTP request headers sent by ab
+     in presence of -H command-line overrides. PR 31268, 26554.
+     [Arvind Srinivasan <arvind.srinivasan  sun.com>]
+
+  *) ab.c: The apr_port_t type is unsigned, but ab was using a
+     signed format code in its reports. PR 42070.
+     [Takashi Sato <serai  lans-tv.com>]
+
+  *) mod_ldap: Remove the hardcoded size limit parameter for
      ldap_search_ext_s and replace it with an APR_ defined
      value that is set according to the LDAP SDK being used.
      [David Jones <oscaremma gmail com>]

Modified: httpd/httpd/branches/2.2.x/support/ab.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/support/ab.c?view=diff&rev=534057&r1=534056&r2=534057
==============================================================================
--- httpd/httpd/branches/2.2.x/support/ab.c (original)
+++ httpd/httpd/branches/2.2.x/support/ab.c Tue May  1 06:12:59 2007
@@ -284,6 +284,11 @@
 char * fullurl, * colonhost;
 int isproxy = 0;
 apr_interval_time_t aprtimeout = apr_time_from_sec(30); /* timeout value */
+
+/* overrides for ab-generated common headers */
+int opt_host = 0;       /* was an optional "Host:" header specified? */
+int opt_useragent = 0;  /* was an optional "User-Agent:" header specified? */
+int opt_accept = 0;     /* was an optional "Accept:" header specified? */
  /*
   * XXX - this is now a per read/write transact type of value
   */
@@ -731,7 +736,7 @@
     printf("\n\n");
     printf("Server Software:        %s\n", servername);
     printf("Server Hostname:        %s\n", hostname);
-    printf("Server Port:            %hd\n", port);
+    printf("Server Port:            %hu\n", port);
 #ifdef USE_SSL
     if (is_ssl && ssl_info) {
         printf("SSL/TLS Protocol:       %s\n", ssl_info);
@@ -990,7 +995,7 @@
        "<td colspan=2 %s>%s</td></tr>\n",
        trstring, tdstring, tdstring, hostname);
     printf("<tr %s><th colspan=2 %s>Server Port:</th>"
-       "<td colspan=2 %s>%hd</td></tr>\n",
+       "<td colspan=2 %s>%hu</td></tr>\n",
        trstring, tdstring, tdstring, port);
     printf("<tr %s><th colspan=2 %s>Document Path:</th>"
        "<td colspan=2 %s>%s</td></tr>\n",
@@ -1512,37 +1517,54 @@
         apr_err("apr_pollset_create failed", status);
     }
 
+    /* add default headers if necessary */
+    if (!opt_host) {
+        /* Host: header not overridden, add default value to hdrs */
+        hdrs = apr_pstrcat(cntxt, hdrs, "Host: ", host_field, colonhost, "\r\n", NULL);
+    }
+    else {
+        /* Header overridden, no need to add, as it is already in hdrs */
+    }
+
+    if (!opt_useragent) {
+        /* User-Agent: header not overridden, add default value to hdrs */
+        hdrs = apr_pstrcat(cntxt, hdrs, "User-Agent: ApacheBench/", AP_AB_BASEREVISION, "\r\n",
NULL);
+    }
+    else {
+        /* Header overridden, no need to add, as it is already in hdrs */
+    }
+
+    if (!opt_accept) {
+        /* Accept: header not overridden, add default value to hdrs */
+        hdrs = apr_pstrcat(cntxt, hdrs, "Accept: */*\r\n", NULL);
+    }
+    else {
+        /* Header overridden, no need to add, as it is already in hdrs */
+    }
+
     /* setup request */
     if (posting <= 0) {
         snprintf_res = apr_snprintf(request, sizeof(_request),
             "%s %s HTTP/1.0\r\n"
-            "User-Agent: ApacheBench/%s\r\n"
             "%s" "%s" "%s"
-            "Host: %s%s\r\n"
-            "Accept: */*\r\n"
             "%s" "\r\n",
             (posting == 0) ? "GET" : "HEAD",
             (isproxy) ? fullurl : path,
-            AP_AB_BASEREVISION,
             keepalive ? "Connection: Keep-Alive\r\n" : "",
-            cookie, auth, host_field, colonhost, hdrs);
+            cookie, auth, hdrs);
     }
     else {
         snprintf_res = apr_snprintf(request,  sizeof(_request),
             "POST %s HTTP/1.0\r\n"
-            "User-Agent: ApacheBench/%s\r\n"
             "%s" "%s" "%s"
-            "Host: %s%s\r\n"
-            "Accept: */*\r\n"
             "Content-length: %" APR_SIZE_T_FMT "\r\n"
             "Content-type: %s\r\n"
             "%s"
             "\r\n",
             (isproxy) ? fullurl : path,
-            AP_AB_BASEREVISION,
             keepalive ? "Connection: Keep-Alive\r\n" : "",
             cookie, auth,
-            host_field, colonhost, postlen,
+            postlen,
             (content_type[0]) ? content_type : "text/plain", hdrs);
     }
     if (snprintf_res >= sizeof(_request)) {
@@ -2035,6 +2057,16 @@
                 break;
             case 'H':
                 hdrs = apr_pstrcat(cntxt, hdrs, optarg, "\r\n", NULL);
+                /*
+                 * allow override of some of the common headers that ab adds
+                 */
+                if (strncasecmp(optarg, "Host:", 5) == 0) {
+                    opt_host = 1;
+                } else if (strncasecmp(optarg, "Accept:", 7) == 0) {
+                    opt_accept = 1;
+                } else if (strncasecmp(optarg, "User-Agent:", 11) == 0) {
+                    opt_useragent = 1;
+                }
                 break;
             case 'w':
                 use_html = 1;



Mime
View raw message