]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - scripts/cachetrace.pl
Source Format Enforcement (#763)
[thirdparty/squid.git] / scripts / cachetrace.pl
index 0bf0972dd4b84b76325216b45fb6b3d40d1abbab..1a5d406f60513a837ef9526f31fc4148577536dd 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/local/bin/perl
 #
-## Copyright (C) 1996-2018 The Squid Software Foundation and contributors
+## Copyright (C) 1996-2021 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
@@ -27,35 +27,36 @@ $that = pack($sockaddr, &AF_INET, $port, $thataddr);
 
 
 sub try_http_11 {
-       local($url) = @_;
-       local($path) = undef;
-
-       $source = $1 if ($url =~ /^[^:]+:\/\/([^:\/]+)/);
-       
-       die "socket: $!\n" unless
-                socket (SOCK, &AF_INET, &SOCK_STREAM, $proto);
-        die "bind: $!\n" unless
-                bind (SOCK, $thissock);
-        die "$proxy:$port: $!\n" unless
-                connect (SOCK, $that);
-        select (SOCK); $| = 1;
-        select (STDOUT);
-       print SOCK "TRACE $url HTTP/1.1\r\nHost: $host\r\nAccept: */*\r\n\r\n";
-       while (<SOCK>) {
-               s/\r//g;
-               s/\n//g;
-               $code = $1 if (/^HTTP\/\d\.\d (\d+)/);
-               $server = $1 if (/^Server:\s*(.*)$/);
-               $path = $1 if (/^Via:\s*(.*)$/);
-       }
-       return 0 unless ($path && $code == 200);
-       print "Received TRACE reply from $source\n";
-       @F = split(',', $path);
-       $i = 0;
-       foreach $n (@F) {
-               $n =~ s/^\s+//;
-               printf " %2d   %s\n", ++$i, $n;
-       }
-       printf " %2d   %s (%s)\n", ++$i, $source, $server;
-       1;
+    local($url) = @_;
+    local($path) = undef;
+
+    $source = $1 if ($url =~ /^[^:]+:\/\/([^:\/]+)/);
+
+    die "socket: $!\n" unless
+        socket (SOCK, &AF_INET, &SOCK_STREAM, $proto);
+    die "bind: $!\n" unless
+        bind (SOCK, $thissock);
+    die "$proxy:$port: $!\n" unless
+        connect (SOCK, $that);
+    select (SOCK); $| = 1;
+    select (STDOUT);
+    print SOCK "TRACE $url HTTP/1.1\r\nHost: $host\r\nAccept: */*\r\n\r\n";
+    while (<SOCK>) {
+        s/\r//g;
+        s/\n//g;
+        $code = $1 if (/^HTTP\/\d\.\d (\d+)/);
+        $server = $1 if (/^Server:\s*(.*)$/);
+        $path = $1 if (/^Via:\s*(.*)$/);
+    }
+    return 0 unless ($path && $code == 200);
+    print "Received TRACE reply from $source\n";
+    @F = split(',', $path);
+    $i = 0;
+    foreach $n (@F) {
+        $n =~ s/^\s+//;
+        printf " %2d   %s\n", ++$i, $n;
+    }
+    printf " %2d   %s (%s)\n", ++$i, $source, $server;
+    1;
 }
+