summaryrefslogtreecommitdiffstats
path: root/perl-install/http.pm
blob: 8d1e8d5de9d91c7f8b7e36e32806cd3af6ab44bf (plain)
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
package http; # $Id$

use IO::Socket;
use network;


my $sock;

sub getFile {
    local($^W) = 0;

    my ($url) = @_;
    $sock->close if $sock;
    $url =~ m|/XXX$| and return; #- force closing connection.

    my ($host, $port, $path) = $url =~ m,^http://([^/:]+)(?::(\d+))?(/\S*)?$,;
    $host = network::resolv($host);

    $sock = IO::Socket::INET->new(PeerAddr => $host,
				  PeerPort => $port || 80,
				  Proto    => 'tcp',
				  Timeout  => 60) or die "can't connect $@";
    $sock->autoflush;
    print $sock join("\015\012" =>
		     "GET $path HTTP/1.0",
		     "Host: $host" . ($port && ":$port"),
		     "User-Agent: DrakX/vivelinuxabaszindozs",
		     "", "");

    #- skip until empty line
    my ($now, $last, $buf, $tmp) = 0;
    my $read = sub { sysread($sock, $buf, 1) || die; $tmp .= $buf };
    do {
	$last = $now;
	&$read; &$read if $buf =~ /\015/;
	$now = $buf =~ /\012/;
    } until ($now && $last);

    $tmp =~ /^.*\b200\b/ ? $sock : undef;
}

1;
45f26fbd66625511236e85fb7b44c5e3ec3'>changed "Country" . " / Region" to "Country / Region" and fixed Chinese po'sPablo Saratxaga2003-07-121-12/+7 * updated pot filePablo Saratxaga2003-07-101-95/+129 * updated pot filePablo Saratxaga2003-07-092-10998/+11474 * Moved Bokmaal file to nb.poPablo Saratxaga2003-06-281-21449/+0 * Fixed typos; updated Ukrainian po filePablo Saratxaga2003-06-272-33/+33 * updated pot filePablo Saratxaga2003-06-272-498/+721 * updated pot filePablo Saratxaga2003-06-162-458/+572 * change a bit how strings are passed to advertising systemGuillaume Cottenceau2003-06-123-1137/+1545 * updated Estonien, Japanese, Albanian and Vietnamese po filesPablo Saratxaga2003-06-033-3301/+3539 * UpdateArkadiusz Lipiec2003-06-021-195/+308 * updated Spanish translationsFabián Mandelbaum2003-06-021-154/+271 * changed the name of the russian phonetic layoutPablo Saratxaga2003-05-3147-6454/+11245 * updated Vietnamese filePablo Saratxaga2003-05-302-67/+68 * updated Albanian filePablo Saratxaga2003-05-281-5/+46 * updated pot filePablo Saratxaga2003-05-261-3/+43 * updated pot filePablo Saratxaga2003-05-222-75/+134 * updated pot filePablo Saratxaga2003-05-202-98/+147 * updated German, Estonian and Finnish filesPablo Saratxaga2003-05-203-1420/+1964 * update french translationThierry Vignaud2003-05-201-67/+54 * updated Spanish translationsFabián Mandelbaum2003-05-191-221/+176 * updated pot filePablo Saratxaga2003-05-16