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.


In reply to IO::Socket problem by js1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.