LWP and firewall

Discussion in 'Perl Misc' started by Larry, Jan 10, 2006.

  1. Larry

    Larry Guest

    I have a script on Windows which uses LWP to make a simple GET request
    through a proxy:

    #!/usr/bin/perl

    use strict;
    use warnings;
    use LWP::UserAgent;

    my $url = "https://mysite.com";

    my $ua = LWP::UserAgent->new;
    $ua->proxy(['http', 'https'] => 'http://myproxy.org:80');
    my $response = $ua->get( $url );

    $response->is_success or
    die "Failed to GET '$url': ", $response->status_line;

    print $response->as_string, "\n";


    I also have Crypt::SSLeay installed so that I can access https sites.
    When I try to run the script as above, it prints some HTTP headers and
    an HTML-formatted error message from the firewall server which says
    "Scheme not supported".

    However:

    -If I change $url to point to a an http site, the script will
    successfully fetch the page, and

    - If I change $url to point to an internal https server and comment out
    the proxy setting line, the script will successfully get the internal
    page.

    I checked my proxy settinng in Internet Explorer and both http and
    https are set to myproxy.org on port 80 (server name changed to protect
    privacy)
     
    Larry, Jan 10, 2006
    #1
    1. Advertising

  2. Larry

    Xicheng Guest

    You may need to add one line before setting $ua->proxy to make sure you
    can use those proxies in your system...... I dont have a chance to test
    it anyway...:)

    my $ua = LWP::UserAgent->new;
    $ua->env_proxy;
    .......
    Good luck,
    Xicheng

    Larry wrote:
    > I have a script on Windows which uses LWP to make a simple GET request
    > through a proxy:
    >
    > #!/usr/bin/perl
    >
    > use strict;
    > use warnings;
    > use LWP::UserAgent;
    >
    > my $url = "https://mysite.com";
    >
    > my $ua = LWP::UserAgent->new;
    > $ua->proxy(['http', 'https'] => 'http://myproxy.org:80');
    > my $response = $ua->get( $url );
    >
    > $response->is_success or
    > die "Failed to GET '$url': ", $response->status_line;
    >
    > print $response->as_string, "\n";
    >
    >
    > I also have Crypt::SSLeay installed so that I can access https sites.
    > When I try to run the script as above, it prints some HTTP headers and
    > an HTML-formatted error message from the firewall server which says
    > "Scheme not supported".
    >
    > However:
    >
    > -If I change $url to point to a an http site, the script will
    > successfully fetch the page, and
    >
    > - If I change $url to point to an internal https server and comment out
    > the proxy setting line, the script will successfully get the internal
    > page.
    >
    > I checked my proxy settinng in Internet Explorer and both http and
    > https are set to myproxy.org on port 80 (server name changed to protect
    > privacy)
     
    Xicheng, Jan 11, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. demonhunter
    Replies:
    3
    Views:
    2,155
  2. Der Script Meister
    Replies:
    2
    Views:
    507
    Saravana [MVP]
    May 19, 2004
  3. =?Utf-8?B?TkcgV0VJIENIVU5H?=

    Unable to view ASP .NET page due to proxy server and firewall

    =?Utf-8?B?TkcgV0VJIENIVU5H?=, Jul 29, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,672
    =?Utf-8?B?TkcgV0VJIENIVU5H?=
    Jul 30, 2005
  4. Robert Dodier
    Replies:
    6
    Views:
    2,405
    Matthias Kraft
    Sep 14, 2004
  5. Replies:
    0
    Views:
    614
Loading...

Share This Page