2013-08-06 99 views
1

我用LWP :: UserAgent的LWP ::用戶代理和代理錯誤

時,這是代碼有一個代理的錯誤:

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

,這是對用戶代理

$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 

我使用的ActiveState Perl的5.10.1一個WinXP的機器上

訪問來自瀏覽器鏈接時它的工作

有人可以幫助?

感謝

+0

什麼是$ link值? 「https:// some_link」看起來是一個錯誤的URL –

+0

確實$ link是來自HTTP :: Request對象的「https:// some_link」,我替換它是因爲我無法給你真正的鏈接。我保證我不是從網絡上抓取信息,只是從網絡應用程序 –

回答

0

我總是需要設置https_proxy(而不僅僅是HTTP_PROXY)與SSL URI來工作。

+0

中得到了與https_proxy相同的錯誤,並且從錯誤消息'可能是非SSL URL'我認爲簡單的http可能是解決方案 –

+0

您是否嘗試過使用http:而不是https:? –

+0

請求或我應該在哪裏嘗試http? –