]> 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 13:26:58 +0000 (07:26 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 17 Jun 2011 13:26:58 +0000 (07:26 -0600)
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 77e9a83e6a1c38d78149f96f875590e1a222efa1..b298732e74fbac576eafdf2aa0393b3d5f6118f6 100644 (file)
@@ -387,11 +387,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);