From a4096eefa2f338e0a6e3b32e77f140291503ab4b Mon Sep 17 00:00:00 2001 From: short <> Date: Sun, 19 Jun 2005 13:55:33 +0000 Subject: [PATCH] Fixed "Host" header. Fixed "X-httpgetdumb" header. Provided generic headers generating framework. --- bin/httpgetdumb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/httpgetdumb b/bin/httpgetdumb index 5ab7c5e..9c6d83c 100755 --- a/bin/httpgetdumb +++ b/bin/httpgetdumb @@ -14,9 +14,9 @@ use constant BUFFER_LENGTH=>0x1000; my %opts; getopts "hH",\%opts or die "getopts()"; -@ARGV==1 && $ARGV[0]=~m#^http://([^/:]+)(?::(\d+))?(/.*)$# +@ARGV==1 && $ARGV[0]=~m#^http://(([^/:]+)(?::(\d+))?)(/.*)$# or die "Syntax: $0 [-hH] http://hostname/pathname"; -my($host,$port,$path)=($1,$2,$3); +my($hostport,$host,$port,$path)=($1,$2,$3,$4); defined $port or $port=DEFAULT_PORT; my $proto=getprotobyname "tcp" or die "getprotobyname \"tcp\": $!"; @@ -25,7 +25,15 @@ my $hostaddr=gethostbyname $host or die "hostname \"$host\": $!"; my $sockaddr=sockaddr_in $port,$hostaddr or die "sockaddr_in(".inet_ntoa($hostaddr).":$port): $!"; connect SOCK,$sockaddr or die "connect \"$host\"(".inet_ntoa($hostaddr).":$port): $!"; -print SOCK ($opts{"h"} ? "HEAD" : "GET")." $path HTTP/1.0\r\nHost: $host\r\nX-httpgetdumb: $Id$\r\n\r\n"; +print SOCK ($opts{"h"} ? "HEAD" : "GET")." $path HTTP/1.0\r\n"; +my %header=( + "Host"=>$hostport, + "X-httpgetdumb"=>'$Id$', + ); +while (my($key,$val)=each(%header)) { + print SOCK "$key: $val\r\n"; + } +print SOCK "\r\n"; if ($opts{"H"}) { while () { chomp; -- 1.8.3.1