Leser: 3
|< 1 2 >| | 18 Einträge, 2 Seiten |
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
use Socket; sub post { local($res); eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm(10); # Timeout - 10 Sekunden $url = shift; $content = shift; $referer = shift; $content_type = shift || "application/x-www-form-urlencoded"; $content_length = length($content); ($host, $uri) = ($url =~ m!http://(.*?)(/.*)!); socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp'); connect SOCK, sockaddr_in(80, inet_aton($host)); send SOCK, "POST $uri HTTP/1.0\r\nHost: $host\r\n" . "Content-Type: $content_type\r\nContent-Length:" . "$content_length\r\n\r\n$content", 0; 0 while <SOCK> !~ /^\r\n$/; $res .= $_ while <SOCK>; close SOCK; alarm(0); }; return($res); }
|< 1 2 >| | 18 Einträge, 2 Seiten |