]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix squidclient -V option and allow non-HTTP protocols to be tested
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 17 Jun 2011 02:31:45 +0000 (14:31 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 17 Jun 2011 02:31:45 +0000 (14:31 +1200)
The "-" case is for old style HTTP (called 0.9) where there is no version
string. The "-V 0.9" is for testing servers with broken version number
tag "HTTP/0.9". Do not mix these up!

This also adds the ability to send non-HTTP version tags for testing.
 ie "-V ICAP/1.0" or "-V ICY/1.0"

tools/squidclient.cc

index 005bd95f7dc02cf01c44df0f8f10cda17d252bc6..f2fd99877aa40d5dc002a087b4a7caea04ba0d8d 100644 (file)
@@ -438,11 +438,14 @@ main(int argc, char *argv[])
         }
     }
 
-    if (version[0] == '-' || !version[0] || version[0] == '0') {
+    if (version[0] == '-' || !version[0]) {
         /* HTTP/0.9, no headers, no version */
         snprintf(msg, BUFSIZ, "%s %s\r\n", method, url);
     } else {
-        snprintf(msg, BUFSIZ, "%s %s HTTP/%s\r\n", method, url, version);
+        if (!xisdigit(version[0])) // not HTTP/n.n
+            snprintf(msg, BUFSIZ, "%s %s %s\r\n", method, url, version);
+        else
+            snprintf(msg, BUFSIZ, "%s %s HTTP/%s\r\n", method, url, version);
 
         if (host) {
             snprintf(buf, BUFSIZ, "Host: %s\r\n", host);