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."
The attached patch sets the port in the generated Via header if it's not
the default 80.
Regards,
Slaven
Subject: | 0001-add-port-to-Via-header.patch |
From 4b10efb448278e2201c7b3245ead60944639d547 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
---
lib/HTTP/Proxy.pm | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/HTTP/Proxy.pm b/lib/HTTP/Proxy.pm
index b248eb6..a25dc19 100644
--- a/lib/HTTP/Proxy.pm
+++ b/lib/HTTP/Proxy.pm
@@ -91,7 +91,6 @@ sub new {
port => 8080,
stash => {},
timeout => 60,
- via => hostname() . " (HTTP::Proxy/$VERSION)",
x_forwarded_for => 1,
);
@@ -117,6 +116,10 @@ sub new {
$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} );
--
1.7.0.3