js1 has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I'm struggling with a small piece of code which sends an ICAP header, and some HTTP headers to an ICAP server (Antivirus scanner).
If I telnet to the ICAP server and enter the text, it works fine, but if I send the text via IO::Socket, I get back an error 400.
#!/opt/perl-5.8.0/bin/perl use IO::Socket::INET; $|=1; $remote_host="biavl01.baplc.com"; $remote_port=1344; $socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM) or die "Couldn't connect to $remote_host:$remote_port : $!\n"; die "no socket" if ! defined $socket; # get text of respmod open(FH,"/home/u752359/respmod.txt"); undef $/; $respmod=<FH>; # send respmod over the socket, print $socket $respmod; # get response $|=1; @resp=<$socket>; print @resp; close($socket);
This is the ICAP request I'm sending:
RESPMOD icap://biavl01.baplc.com/avscan ICAP/1.0 Host: biavl01.baplc.com X-Scan-Progress-Interval: 3 X-Client-IP: 161.2.124.27 X-Server-IP: 161.2.66.50 Allow: 204 Encapsulated: req-hdr=0, res-hdr=142, res-body=460 GET /EICAR.COM HTTP/1.0 Host: ebiztools.baplc.com User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .N +ET CLR 1.1.4322) HTTP/1.1 200 OK Date: Mon, 17 Oct 2005 10:22:01 GMT Server: Apache/2.0.54 (Unix) PHP/4.3.11 mod_jk/1.2.8 mod_perl/1.99_19 +Perl/v5.8.3 Last-Modified: Fri, 14 Oct 2005 10:28:23 GMT ETag: "4260-45-512d5fc0" Accept-Ranges: bytes Content-Length: 68 Connection: close Content-Type: text/plain; charset=ISO-8859-1 44 X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* 0
Any ideas where my code might be going wrong?
Thanks,
js.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket problem
by BrowserUk (Patriarch) on Oct 18, 2005 at 10:27 UTC | |
by js1 (Monk) on Oct 18, 2005 at 11:27 UTC | |
|
Re: IO::Socket problem
by tirwhan (Abbot) on Oct 18, 2005 at 11:39 UTC | |
|
Re: IO::Socket problem
by castaway (Parson) on Oct 18, 2005 at 09:30 UTC | |
by js1 (Monk) on Oct 18, 2005 at 09:49 UTC | |
by castaway (Parson) on Oct 18, 2005 at 11:40 UTC |