UPDATE: I figured it out. It turns out asking for "http://www.google.com" is very different from asking for "http://www.google.com/". Thanks to everyone who replied. Original post is below.
I understand that the answer to this question is going to be something like, "You're missing a hyphen, jackass!" But I've banged my head against the wall long enough.
This script should hit my HTTP proxy, retrieve the Google front page, and display the HTTP return code and the HTML content to standard output. I think.
use strict;
use LWP::UserAgent;
our $ua = LWP::UserAgent->new;
$ua->proxy('http', "http://localhost:8080");
my $url = "http://www.google.com";
my $response = $ua->get($url);
print $response->status_line, "\n";
print $response->content, "\n";
Running it returns "400 Invalid header received from browser".
I know the proxy works because both Mozilla and Wget are happy to use it. It's possible that the proxy requires broken HTTP that both of those use and LWP::UserAgent doesn't, I suppose. Any help would be much appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.