【问题标题】:LWP::UserAgent and proxy errorLWP::UserAgent 和代理错误
【发布时间】:2023-03-06 02:28:01
【问题描述】:

使用 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

当从浏览器访问链接时它可以工作

有人可以帮忙吗?

谢谢

【问题讨论】:

  • 什么是 $link 价值? “https://some_link”看起来是一个错误的 URL
  • 确实 $link 是来自 HTTP::Request 对象的“some_link”,我替换了它,因为我不能给你真正的链接。我保证我不是从网络上抓取信息,只是从网络应用程序内部获取信息

标签: perl


【解决方案1】:

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

【讨论】:

  • 我在使用 https_proxy 时遇到了同样的错误,从错误消息 could be non-SSL URL 我认为简单的 http 可能是一个解决方案
  • 请求或者我应该在哪里尝试http?
  • 网址是我的建议。您可以使用网络浏览器连接到该 URL 吗?
猜你喜欢
  • 2011-06-02
  • 2015-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-26
  • 2011-09-24
  • 1970-01-01
相关资源
最近更新 更多