LWP :: UserAgent和代理错误

时间:2013-08-06 13:52:01

标签: perl

使用LWP :: UserAgent

时出现代理错误

这是代码:

my $ua = LWP::UserAgent->new();
$ua->proxy( http => $ENV{HTTP_PROXY});
print Dumper($ua);
my $request = new HTTP::Request('GET', $link);
print Dumper( $request );

这是UserAgent的转储程序

$VAR1 = bless( {
             'max_redirect' => 7,
             'protocols_forbidden' => undef,
             'show_progress' => undef,
             'handlers' => {
                             'response_header' => bless( [
                                                           {
                                                             'owner' => 'LWP::UserAgent::parse_head',
                                                             'callback' => sub { "DUMMY" },
                                                             'm_media_type' => 'html',
                                                             'line' => 'C:/Perl/lib/LWP/UserAgent.pm:612'
                                                           }
                                                         ], 'HTTP::Config' ),
                             'request_preprepare' => bless( [
                                                              {
                                                                'owner' => 'LWP::UserAgent::proxy',
                                                                'callback' => sub { "DUMMY" },
                                                                'line' => 'C:/Perl/lib/LWP/UserAgent.pm:920'
                                                              }
                                                            ], 'HTTP::Config' )
                           },
             'no_proxy' => [],
             'protocols_allowed' => undef,
             'local_address' => undef,
             'use_eval' => 1,
             'requests_redirectable' => [
                                          'GET',
                                          'HEAD'
                                        ],
             'timeout' => 90,
             'def_headers' => bless( {
                                       'user-agent' => 'libwww-perl/5.837'
                                     }, 'HTTP::Headers' ),
             'proxy' => {
                          'http' => 'http://igate:8080'
                        },
             'max_size' => undef
           }, 'LWP::UserAgent' );

这是针对请求的:

$VAR1 = bless( {
             '_content' => '',
             '_uri' => bless( do{\(my $o = 'https://some_link')}, 'URI::https' ),
             '_headers' => bless( {}, 'HTTP::Headers' ),
             '_method' => 'GET'
           }, 'HTTP::Request' );

问题是响应是错误的:

FAIL response, 500 proxy connect failed: PROXY ERROR HEADER, could be non-SSL URL:
HTTP/1.1 503 Service Unavailable

我在WinXP机器上使用ActiveState perl 5.10.1

从浏览器访问链接时可以正常工作

有人可以帮忙吗?

由于

1 个答案:

答案 0 :(得分:0)

我总是需要设置https_proxy(而不仅仅是http_proxy)才能使用SSL URI。