Subject: | LWP::UserAgent with proxy issues entire hostname in request |
When communicating via SSL using a proxy, requests are issued of the form:
GET https://example.com/ HTTP/1.1
Rather than:
GET / HTTP/1.1
Requests made without SSL, or using a proxy over HTTP, are made with only /. This happens whether or not the env_proxy method is
used.
I tested using Burp proxy http://www.portswigger.net/burp/proxy.html, it shows the requests coming into the proxy with the entire
hostname, and the server shows the request leaving the proxy (untampered) doing the same.
Below is a script that can demonstrate 6 combinations:
No Proxy | Proxy | Env Proxy
--------------------------------
w/o SSL | / | / |
w SSL | / | HN | HN
#!/usr/bin/perl
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $useproxy = 0;
my $useenviroment = 0;
my $usessl = 0;
if($useproxy) {
my $httpproxy = "localhost:8080";
my $proxyserver = "";
if($usessl) {
if($useenviroment) {
$ENV{HTTPS_PROXY} = "https://".$httpproxy;
$ua->env_proxy();
}
else {
$proxyserver = "https://".$httpproxy;
$ua->proxy(['http', 'https'], $proxyserver);
}
}
else {
$proxyserver = "http://".$httpproxy;
$ua->proxy(['http', 'https'], $proxyserver);
}
}
my $target = "https://server-you-can-tail-logs-for.com";
my $response = $ua->get($target);
print $response->status_line;
tested using:
perl v5.10.1 under cygwin
activestate perl