josef has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I'm interested to implement the Internet Content Adaptation Protocol (ICAP), only server side, in Perl. The ICAP client will be Squid 3.3-Version.
Has anyone started something? I will be grateful for ideas and discussions. I have seen c-icap (writed in C), but I have low C knowledge.
ICAP description is on RFC 3507.

Thanks
Josef

Replies are listed 'Best First'.
Re: ICAP server implementation in Perl
by kcott (Archbishop) on Oct 09, 2013 at 08:50 UTC

    G'day Josef,

    I noticed this has been sitting here for over 15 hours without a response. I'm not familiar with ICAP. A CPAN search for "ICAP" only found Net::xAP. That module is 14 years old and, according to its documentation:

    "WARNING: This code is in alpha release. Expect the interface to change from release to release."

    That doesn't look too promising, but you'd probably be a better judge of that.

    -- Ken

      Looks like HTTP::Proxy and/or Plack could be leveraged for icap

      If HTTP::Response/HTTP::Request can parse these ical req/res then so can Proxy and Plack... probably even Mojolicious

      #!/usr/bin/perl -- use strict; use warnings; use HTTP::Response; use HTTP::Request; use Data::Dump qw/ dd pp /; my $req_raw = q{REQMOD icap://icap-server.net/server?arg=87 ICAP/1.0 Host: icap-server.net Encapsulated: req-hdr=0, null-body=170 GET / HTTP/1.1 Host: www.origin-server.com Accept: text/html, text/plain Accept-Encoding: compress Cookie: ff39fk3jur@4ii0e02i If-None-Match: "xyzzy", "r2d2xxxx" }; my $res_raw = q{ICAP/1.0 200 OK Date: Mon, 10 Jan 2000 09:55:21 GMT Server: ICAP-Server-Software/1.0 Connection: close ISTag: "W3E4R7U9-L2E4-2" Encapsulated: req-hdr=0, null-body=231 GET /modified-path HTTP/1.1 Host: www.origin-server.com Via: 1.0 icap-server.net (ICAP Example ReqMod Service 1.1) Accept: text/html, text/plain, image/gif Accept-Encoding: gzip, compress If-None-Match: "xyzzy", "r2d2xxxx" }; my $req = HTTP::Request->parse($req_raw); my $res = HTTP::Response->parse($res_raw); dd( $res, $req ); dd( "req_raw eq req->as_string " => int( $req_raw eq $req->as_string ) + ); dd( "res_raw eq res->as_string " => int( $res_raw eq $res->as_string ) + ); print "-" x 33, "\n", $req->dump; print "-" x 33, "\n", $res->dump; dd( $req_raw, $req->as_string ); dd( $res_raw, $res->as_string );
        Thanks for response. I'll think about a solution.

        Have a nice day, Josef
      Hi Ken,

      Net::xAPP module provide an interface to Internet Calendar Access Protocol. The Squid proxy contain a interface to the ICAP (Internet Content Adaption Protocol ) server. The only known by open source ICAP servers are in C written, except a very old implementation in python.
      The ICAP server use external modules for content scanning or virus check. I can't write these modules in C, and Perl will be perhaps to slow. My intention was to write itself a ICAP server in Perl to simplify the application to eliminate some overhead between ICAP server and ICAP modules.

      I'll think about a solution.

      Thanks and best regards, Josef