Subject: | Proxy Support fixes |
This patch make proxy support working. There is no tests for proxy, but I will to it soon.
Index: Request.pm
===================================================================
--- Request.pm (revision 200)
+++ Request.pm (working copy)
@@ -121,7 +121,8 @@
# This request qualifies for proxying. Replace the host and port
# with the proxy's host and port. This comes after the Host:
# header is set, so it doesn't break the request object.
- ($host, $port) = $params{Proxy}->[rand @{$params{Proxy}}];
+ ($host, $port) = @{$params{Proxy}->[rand @{$params{Proxy}}]};
+
$using_proxy = 1;
}
else {
@@ -516,6 +517,16 @@
return;
}
+sub host { shift->[REQ_HOST] }
+
+sub port { shift->[REQ_PORT] }
+
+sub scheme {
+ my $self = shift;
+
+ $self->[REQ_USING_PROXY] ? 'http' : $self->[REQ_REQUEST]->uri->scheme;
+}
+
sub DESTROY {
my ($self) = @_;
Index: HTTP.pm
===================================================================
--- HTTP.pm (revision 200)
+++ HTTP.pm (working copy)
@@ -164,13 +164,13 @@
);
}
-
+
eval {
# get a connection from Client::Keepalive
$heap->{cm}->allocate(
- scheme => $http_request->uri->scheme,
- addr => $http_request->uri->host,
- port => $http_request->uri->port,
+ scheme => $request->scheme,
+ addr => $request->host,
+ port => $request->port,
context => $request->ID,
event => 'got_connect_done',
@timeout,
Index: RequestFactory.pm
===================================================================
--- RequestFactory.pm (revision 200)
+++ RequestFactory.pm (working copy)
@@ -288,20 +288,19 @@
# request URI.
my $proxy = $self->[FCT_PROXY];
- my $using_proxy;
if (defined $proxy) {
# This request qualifies for proxying. Replace the host and port
# with the proxy's host and port. This comes after the Host:
# header is set, so it doesn't break the request object.
my $host = $http_request->uri->host;
- if (not _in_no_proxy ($host, $self->[FCT_NOPROXY])) {
- my $using_proxy = $proxy->[@$proxy];
- }
+
+ undef $proxy
+ if _in_no_proxy ($host, $self->[FCT_NOPROXY]);
}
my $request = POE::Component::Client::HTTP::Request->new (
Request => $http_request,
- Proxy => $using_proxy,
+ Proxy => $proxy,
Postback => $postback,
Tag => $tag,
Progress => $progress_postback,