-
Notifications
You must be signed in to change notification settings - Fork 6
/
fg_metar_xml_proxy.cgi
executable file
·47 lines (34 loc) · 908 Bytes
/
fg_metar_xml_proxy.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -wT
# Under debian, you need libwww-perl
use strict;
use Net::HTTP;
use HTTP::Status;
my($host) = 'pigeond.net';
my($port) = 80;
my($url) = '/flightgear/fgmap/fg_metar_xml.cgi';
my($buf);
if(!defined($ENV{'QUERY_STRING'}))
{
exit(-1);
}
binmode(STDOUT, ":utf8");
my($req) = Net::HTTP->new(Host => $host, PeerPort => $port, Timeout => 30);
if($req)
{
$req->http_version('1.1');
$req->write_request(GET => ${url}.'?'.$ENV{'QUERY_STRING'});
my($code, $mess, %h) = $req->read_response_headers();
if($code == RC_OK)
{
print("Pragma: no-cache\r\n");
print("Cache-Control: no-cache\r\n");
print("Expires: Sat, 17 Sep 1977 00:00:00 GMT\r\n");
print("Content-Type: text/xml\r\n\r\n");
while($req->read_entity_body($buf, 1024))
{
print($buf);
}
}
}
exit(0);
# vim: set sw=4 sts=4 expandtab: #