1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
From e105876f84220791f2a6b1e64d2a913658c1d269 Mon Sep 17 00:00:00 2001
From: Slaven Rezic <slaven@rezic.de>
Date: Fri, 12 Nov 2010 11:37:59 +0100
Subject: [PATCH] add port to Via header
RFC 2616 kind of suggests to add the port to the Via header if it's not
the default port:
"If the port is not given, it MAY be assumed to be the default port
of the received-protocol."
This patch sets the port in the generated Via header if it's not the
default 80.
---
lib/HTTP/Proxy.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/lib/HTTP/Proxy.pm
+++ b/lib/HTTP/Proxy.pm
@@ -91,7 +91,6 @@
port => 8080,
stash => {},
timeout => 60,
- via => hostname() . " (HTTP::Proxy/$VERSION)",
x_forwarded_for => 1,
);
@@ -117,6 +116,10 @@
$self->{$_} = exists $params{$_} ? delete( $params{$_} ) : $defaults{$_}
for keys %defaults;
+ if (!defined $self->{via}) {
+ $self->{via} = hostname() . ($self->{port} != 80 ? ':' . $self->{port} : '') . " (HTTP::Proxy/$VERSION)";
+ }
+
# choose an engine with the remaining parameters
$self->{engine} = HTTP::Proxy::Engine->new( %params, proxy => $self );
$self->log( PROXY, "PROXY", "Selected engine " . ref $self->{engine} );
|