]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Cleaning up/fix proxy/Host: header logic. Working to do the same
authorDirk-Willem van Gulik <dirkx@apache.org>
Fri, 25 May 2001 08:09:47 +0000 (08:09 +0000)
committerDirk-Willem van Gulik <dirkx@apache.org>
Fri, 25 May 2001 08:09:47 +0000 (08:09 +0000)
for apache-2.0 where we also have an ascii [num] representation of
IPv6's to take into account which currently only takes the non
proxy situation into account.

PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@89230 13f79535-47bb-0310-9956-ffa450edef68

src/support/ab.c

index 913b80fb1a2ea5bfec8ea17b215ed637347cf0e5..d9978f413fea8673deeb154c4ab82787089ec81b 100644 (file)
@@ -1195,16 +1195,35 @@ static void test(void)
     struct timeval timeout, now;
     fd_set sel_read, sel_except, sel_write;
     long i;
-    char connecthost[1024];
     int connectport;
+    char * url_on_request, * host;
 
+    /* There are four hostname's involved:
+     * The 'hostname' from the URL, the
+     * hostname of the proxy, the value which
+     * is to go into the Host: header and
+     * the hostname we connect to over TCP.
+     */
     if (isproxy) {
-       strcpy(connecthost, proxyhost);
+       /* Connect to proxyhost:proxyport
+         * And set Host: to the hostname of
+         * the proxy - whistl quoting the
+        * full URL in the GET/POST line.
+        */
+       host  = proxyhost;
        connectport = proxyport;
+       url_on_request = fullurl;
     }
     else {
-       strcpy(connecthost, hostname);
+       /* When there is no proxy: 
+        * use the hostname to connect to,
+        * use the hostname in the Host:
+        * header; and do not quote a full
+        * URL in the GET/POST line.
+        */
+       host  = hostname;
        connectport = port;
+       url_on_request = path;
     }
 
     if (!use_html) {
@@ -1215,10 +1234,10 @@ static void test(void)
     {
        /* get server information */
        struct hostent *he;
-       he = gethostbyname(connecthost);
+       he = gethostbyname(host);
        if (!he) {
            char theerror[1024];
-           sprintf(theerror, "Bad hostname: %s\n", connecthost);
+           sprintf(theerror, "Bad hostname: %s\n", host);
            err(theerror);
        }
        server.sin_family = he->h_addrtype;
@@ -1243,12 +1262,11 @@ static void test(void)
                "Accept: */*\r\n"
                "%s" "\r\n",
                (posting == 0) ? "GET" : "HEAD",
-               (isproxy) ? fullurl : path,
+               url_on_request,
                VERSION,
                keepalive ? "Connection: Keep-Alive\r\n" : "",
                cookie, auth, 
-               proxyhost, 
-               hdrs);
+               host, hdrs);
     }
     else {
        sprintf(request, "POST %s HTTP/1.0\r\n"
@@ -1260,11 +1278,11 @@ static void test(void)
                "Content-type: %s\r\n"
                "%s"
                "\r\n",
-               (isproxy) ? fullurl : path, 
+               url_on_request,
                VERSION,
                keepalive ? "Connection: Keep-Alive\r\n" : "",
                cookie, auth,
-               proxyhost, postlen,
+               host, postlen,
                (content_type[0]) ? content_type : "text/plain", hdrs);
     }
 
@@ -1338,14 +1356,14 @@ static void test(void)
 static void copyright(void)
 {
     if (!use_html) {
-       printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.53 $> apache-1.3");
+       printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.54 $> apache-1.3");
        printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
        printf("Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/\n");
        printf("\n");
     }
     else {
        printf("<p>\n");
-       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-1.3<br>\n", VERSION, "$Revision: 1.53 $");
+       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-1.3<br>\n", VERSION, "$Revision: 1.54 $");
        printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
        printf(" Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/<br>\n");
        printf("</p>\n<p>\n");