#!/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.
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;
}
+