]> granicus.if.org Git - apache/commitdiff
Made AB's use of the Host: header rfc2616 compliant as
authorDirk-Willem van Gulik <dirkx@apache.org>
Mon, 1 Apr 2002 04:32:40 +0000 (04:32 +0000)
committerDirk-Willem van Gulik <dirkx@apache.org>
Mon, 1 Apr 2002 04:32:40 +0000 (04:32 +0000)
reported by Taisuke Yamada <tai@iij.ad.jp>

PR:
Obtained from: Mailing list
Submitted by: Taisuke Yamada <tai@iij.ad.jp>
Reviewed by: Dirk-Willem van Gulik

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94355 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/ab.c

diff --git a/CHANGES b/CHANGES
index 30bfc5a4e8b4dfbf5bfa41fd3ffc218da47e238a..c23af1e7dd5624c54943ea3111a2c407f46059c5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,9 @@ Changes with Apache 2.0.34
   *) Update mod_cgid to not do single-byte socket reads for CGI headers
      [Brian Pane]
 
+  *) Made AB's use of the Host: header rfc2616 compliant
+     by Taisuke Yamada <tai@iij.ad.jp> [Dirk-Willem van Gulik].
+
   *) The old, legacy (and unused) code in which the scoreboard was totally
      and completely contained in a file (SCOREBOARD_FILE) has been
      removed. This does not affect scoreboards which are *mapped* to
index 2ba854a3c0c44a21d3309d3a2b2073d29ba9ea70..76ce0630e7e5400bb46181995b29077120d5f5ef 100644 (file)
@@ -275,7 +275,7 @@ apr_port_t connectport;
 char *gnuplot;                 /* GNUplot file */
 char *csvperc;                 /* CSV Percentile file */
 char url[1024];
-char fullurl[1024];
+char * fullurl, * colonhost;
 int isproxy = 0;
 apr_short_interval_time_t aprtimeout = 30 * APR_USEC_PER_SEC;  /* timeout value */
  /*
@@ -1150,20 +1150,20 @@ static void test(void)
        sprintf(request, "%s %s HTTP/1.0\r\n"
                "User-Agent: ApacheBench/%s\r\n"
                "%s" "%s" "%s"
-               "Host: %s\r\n"
+               "Host: %s%s\r\n"
                "Accept: */*\r\n"
                "%s" "\r\n",
                (posting == 0) ? "GET" : "HEAD",
                (isproxy) ? fullurl : path,
                AP_SERVER_BASEREVISION,
                keepalive ? "Connection: Keep-Alive\r\n" : "",
-               cookie, auth, host_field, hdrs);
+               cookie, auth, host_field, colonhost, hdrs);
     }
     else {
        sprintf(request, "POST %s HTTP/1.0\r\n"
                "User-Agent: ApacheBench/%s\r\n"
                "%s" "%s" "%s"
-               "Host: %s\r\n"
+               "Host: %s%s\r\n"
                "Accept: */*\r\n"
                "Content-length: %" APR_SIZE_T_FMT "\r\n"
                "Content-type: %s\r\n"
@@ -1173,7 +1173,7 @@ static void test(void)
                AP_SERVER_BASEREVISION,
                keepalive ? "Connection: Keep-Alive\r\n" : "",
                cookie, auth,
-               host_field, postlen,
+               host_field, colonhost, postlen,
                (content_type[0]) ? content_type : "text/plain", hdrs);
     }
 
@@ -1302,14 +1302,14 @@ static void test(void)
 static void copyright(void)
 {
     if (!use_html) {
-       printf("This is ApacheBench, Version %s\n", AP_SERVER_BASEREVISION " <$Revision: 1.92 $> apache-2.0");
+       printf("This is ApacheBench, Version %s\n", AP_SERVER_BASEREVISION " <$Revision: 1.93 $> apache-2.0");
        printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
        printf("Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/\n");
        printf("\n");
     }
     else {
        printf("<p>\n");
-       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AP_SERVER_BASEREVISION, "$Revision: 1.92 $");
+       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AP_SERVER_BASEREVISION, "$Revision: 1.93 $");
        printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
        printf(" Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/<br>\n");
        printf("</p>\n<p>\n");
@@ -1368,6 +1368,9 @@ static int parse_url(char *url)
     char *scope_id;
     apr_status_t rv;
 
+    /* Save a copy for the proxy */
+    fullurl = apr_pstrdup(cntxt, url);
+
     if (strlen(url) > 7 && strncmp(url, "http://", 7) == 0)
        url += 7;
     else
@@ -1401,9 +1404,19 @@ static int parse_url(char *url)
     else {
        host_field = hostname;
     }
+
     if (port == 0) {           /* no port specified */
        port = 80;
-    }
+    };
+    if ((
+#if USE_SSL
+         (ssl == 1) && (port != 443)) || (( ssl == 0 ) && 
+#endif
+         (port != 80)))
+    {
+       colonhost = apr_psprintf(cntxt,":%d",port);
+    } else
+       colonhost = "";
     return 0;
 }