Re: HTTP proxy authentication
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
OK, I did a lot of searching in the archives and tried the following: ================================================ #!/usr/bin/perl -w use strict; $|++; use LWP::UserAgent; use LWP::Debug qw(+); my $ua = LWP::UserAgent->new; $ua->proxy(['http', 'https'], 'http://x52635:[email protected]:1080'); my $req = HTTP::Request->new(CONNECT => 'https://mail.yahoo.com/'); my $res = $ua->request($req); if ($res->is_success) { print $res->as_string; } else { print "Failed: ", $res->status_line, "\n"; } ================================================ This returns: ################################################ LWP::UserAgent::new: () LWP::UserAgent::proxy: ARRAY(0x225524) http://x52635:[email protected]:1080 LWP::UserAgent::proxy: http http://x52635:[email protected]:1080 LWP::UserAgent::proxy: https http://x52635:[email protected]:1080 LWP::UserAgent::request: () LWP::UserAgent::send_request: CONNECT https://mail.yahoo.com/ LWP::UserAgent::_need_proxy: Proxied to http://x52635:[email protected]:1080 LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: OK HTTP/1.1 200 (OK) Connection established Client-Date: Sun, 23 Oct 2005 10:49:23 GMT Client-Peer: 10.213.80.200:1080 Proxy-Agent: BlueCoat-Security-Appliance ################################################ But, I do not get any content. If only I change CONNECT to GET, I get: ################################################ LWP::UserAgent::new: () LWP::UserAgent::proxy: ARRAY(0x225524) http://x52635:[email protected]:1080 LWP::UserAgent::proxy: http http://x52635:[email protected]:1080 LWP::UserAgent::proxy: https http://x52635:[email protected]:1080 LWP::UserAgent::request: () LWP::UserAgent::send_request: GET https://mail.yahoo.com/ LWP::UserAgent::_need_proxy: Proxied to http://x52635:[email protected]:1080 LWP::Protocol::http::request: () LWP::Protocol::collect: read 862 bytes LWP::Protocol::collect: read 1716 bytes LWP::UserAgent::request: Simple response: Bad Request Failed: 400 Bad Request ################################################ So, the culprit was I was that CONNECT was not being sent. But, how do I get the content?