Back in 2001 I wrote a Perl/Tk script to download tracks from a GPS unit and overlay them onto maps and aerial photos from Microsoft's TerraServer. I used
Win32::Internet (I needed the headers to tell GIFs from JPEGs.) to connect to and make requests from
terraserver.microsoft.com via the following subroutines:
sub StartInternet {
$Internet = Win32::Internet->new
}
sub Get {
my ($url, $req) = @_;
my $http;
my $result = $Internet->HTTP($http, $url, 'anonymous', '');
if ($result) {
my ($status, $header, $content) = $http->Request("/$req");
$http->Close;
return ($header, $content)
} else {
return undef
}
}
Typical values for
$url and
$req would be:
$url = 'terraserver.microsoft.com';
$req = 'tile/tile.asp?T=1&S=13&X=321&Y=3329&Z=10'
and the script worked just fine.
Now, however, Microsoft has changed the url to terraserver-usa.com and seems to be herding everyone into using their .NET RPCs. Nonetheless, the website is still able to retrieve individual tiles using addresses like:
terraserver-usa.com/tile.ashx?T=1&S=13&X=321&Y=3329&Z=10
Yet, when reconfigured for the new addresses, my script no longer works. I get a "400 Bad request" each time.
So my question is, what is my browser (Opera 6 on Windows) sending to the server that Win32::Internet isn't, or
vice-versa, and how can I turn a bad request into a good one? (I'd prefer not to use
SOAP. It seems like overkill just for accessing static content.)
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.