<div dir="ltr">Hi<div>I want to write my own ICAP server, but all the sample code I've found is failing, the majority with this error from squidclient:</div><div><br></div><div>squidclient -h 192.168.0.7 -p 1344 icap://<a href="http://192.168.0.7:1344/request_mod">192.168.0.7:1344/request_mod</a><br>ICAP/1.0 400 Bad Request<br><br></div><div><div>And this error when accessed through Squid itself:</div><div><br></div><div>ICAP protocol error.<br><br>The system returned: [No Error]<br><br>This means that some aspect of the ICAP communication failed.</div></div><div><br></div><div>I've got this in my squid.conf:</div><div><br></div><div># Enable ICAP for request and response modification<br>icap_enable on<br>icap_service service_req reqmod_precache icap://<a href="http://192.168.0.7:1344/request_mod">192.168.0.7:1344/request_mod</a><br>icap_service service_resp respmod_precache icap://<a href="http://192.168.0.7:1344/response_mod">192.168.0.7:1344/response_mod</a><br><br># ICAP adaptation rules<br>adaptation_access service_req allow all<br>adaptation_access service_resp allow all<br></div><div><br></div><div>And I've tried running both Python and Ruby servers taken from various places. A lot are logging that they've received and replied to requests:</div><div><br></div><div>Received request: OPTIONS icap://<a href="http://192.168.0.7:1344/request_mod">192.168.0.7:1344/request_mod</a> ICAP/1.0<br>Responded to OPTIONS request<br></div><div><br></div><div>The servers are all listening, I've checked that:</div><div><br></div><div>$ ss -antp | grep 1344<br>LISTEN     0      4096                       <a href="http://0.0.0.0:1344">0.0.0.0:1344</a>                  0.0.0.0:*     users:(("ruby",pid=563029,fd=5))</div><div><br></div><div>The closest I've got is this one:</div><div><br></div><div><a href="https://gist.github.com/digininja/a98b3567e0aeb218d37cdd337bb12f34">https://gist.github.com/digininja/a98b3567e0aeb218d37cdd337bb12f34</a></div><div><br></div><div>It seems to be working as it sees the headers and says it has returned data:</div><div><br></div><div>Received request: REQMOD icap://<a href="http://192.168.0.7:1344/request_mod">192.168.0.7:1344/request_mod</a> ICAP/1.0<br>Original Headers:<br>Host: <a href="http://192.168.0.7:1344">192.168.0.7:1344</a><br>Date: Fri, 07 Feb 2025 10:10:30 GMT<br>Encapsulated: req-hdr=0, null-body=91<br>Preview: 0<br>Allow: 204, trailers<br>Modified request sent back<br></div><div><br></div><div>But I still get errors.</div><div><br></div><div>What could be wrong?</div><div><br></div><div>Does someone have some example server code they know works that I can test to help debug it?</div><div><br></div><div>Robin</div></div>