Skip Menu |

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 13642
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: mt [...] nta-monitor.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 5.803
Fixed in: (no value)



Subject: Host header always being sent with requests
Distro: libwww-perl-5.803 uname -a: Linux dbdev 2.4.29 #2 Tue May 24 12:19:46 BST 2005 i686 GNU/Linux perl -v: This is perl, v5.8.4 built for i386-linux-thread-multi Net::HTTP::Methods.pm always sends a "Host" header on HTTP version 1.0 requests. This does not effect normal operation but webservers can deal with HTTP 1.0 requests differently if a "Host" header is present. I have attached a quick patch to Net::HTTP version 1.02 to fix this Mark Terry NTA Monitor Ltd. http://www.nta-monitor.com
--- Methods.pm 2005-07-06 17:33:43.000000000 +0100 +++ Methods.pm_orig 2005-07-06 17:33:43.000000000 +0100 @@ -7,8 +7,7 @@ use strict; use vars qw($VERSION); -#-mt up version num by .1 -$VERSION = "1.02.1"; +$VERSION = "1.02"; my $CRLF = "\015\012"; # "\r\n" is not portable @@ -28,11 +27,10 @@ if ($host) { $cnf->{PeerAddr} = $host unless $peer; } - #-mt we dont want to set a default host header - #else { - #$host = $peer; - #$host =~ s/:.*//; - #} + else { + $host = $peer; + $host =~ s/:.*//; + } $cnf->{PeerPort} = $self->http_default_port unless $cnf->{PeerPort}; $cnf->{Proto} = 'tcp'; @@ -48,10 +46,9 @@ $max_header_lines = 128 unless defined $max_header_lines; return undef unless $self->http_connect($cnf); - #-mt we dont want to add on the port if we havent got a host - #unless ($host =~ /:/) { - if($host && $host !~ /:/){ - my $p = $self->peerport; + + unless ($host =~ /:/) { + my $p = $self->peerport; $host .= ":$p"; } $self->host($host); @@ -161,11 +158,8 @@ } } push(@h2, "Connection: " . join(", ", @connection)) if @connection; - #-mt dont add a host header if we have not already set one - if (!$given{host} && ${*$self}{'http_host'}) { - push(@h2, "Host: ${*$self}{'http_host'}"); - } - #push(@h2, "Host: ${*$self}{'http_host'}") unless $given{host}; + push(@h2, "Host: ${*$self}{'http_host'}") unless $given{host}; + return join($CRLF, "$method $uri HTTP/$ver", @h2, @h, "", $content); }