#!/usr/bin/perl use strict; use Socket; my $VERSION = '0.02'; eval { my $host = "links.wm.ru"; my $servername = $ENV{SERVER_NAME}; $servername =~ s{^www\.}{}; my $request = "GET /wmc/$servername$ENV{PATH_INFO} HTTP/1.0\nHOST: $host\n\n"; local $/; my $thataddr = gethostbyname($host); die "Unable to resolve host name" unless $thataddr; die "Socket create error" unless socket(SOCK,PF_INET,SOCK_STREAM,getprotobyname('tcp')); die "Socket connect error" unless connect(SOCK,pack('S n a4 x8',PF_INET,80,$thataddr)); select(SOCK); $|=1; select(STDOUT); print SOCK $request; my $response = <SOCK>; close(SOCK); die unless $response =~ m{^HTTP/\d\.\d\s200\b}; $response =~ /\r?\n\r?\n/s; $response = $'; print "Content-type: text/html\n\n$response"; } or do { print "Content-type: text/plain", "\n"; print "Status: 503 Service Unavailable", "\n\n"; print "503 Service Unavailable"; };