<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hey Moti,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I had an example on my local git which also works with gzip and other stuff for BGU however I cannot find it now.<o:p></o:p></p><p class=MsoNormal>From what I remember this worked with POST but only like an external acl helper.<o:p></o:p></p><p class=MsoNormal>Ie blocking or allowing OK/ERR:<o:p></o:p></p><p class=MsoNormal><a href="https://github.com/elico/drbl-icap-service">https://github.com/elico/drbl-icap-service</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any modification of the headers is a bit complicated.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I can try to check/test it but it will take time.<o:p></o:p></p><p class=MsoNormal>From what I see 5.0.4 is pretty stable however there are specific issues related to TLS 1.3.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Eliezer<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>----<o:p></o:p></p><p class=MsoNormal>Eliezer Croitoru<o:p></o:p></p><p class=MsoNormal>Tech Support<o:p></o:p></p><p class=MsoNormal>Mobile: +972-5-28704261<o:p></o:p></p><p class=MsoNormal>Email: <a href="mailto:ngtech1ltd@gmail.com">ngtech1ltd@gmail.com</a><o:p></o:p></p><p class=MsoNormal>Zoom: Coming soon<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> squid-users <squid-users-bounces@lists.squid-cache.org> <b>On Behalf Of </b>Moti Berger<br><b>Sent:</b> Sunday, January 17, 2021 10:09 PM<br><b>To:</b> squid-users@lists.squid-cache.org<br><b>Subject:</b> [squid-users] Adding headers in ICAP server with no preview<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hi<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I have an environment with squid version 5.0.4 with ICAP server adapting requests by adding an header.<o:p></o:p></p></div><div><p class=MsoNormal>When I'm trying to send a POST request with a body I'm having an issue of a stuck connection.<o:p></o:p></p></div><div><p class=MsoNormal>What should the ICAP response look like?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>What I do is to reply like this:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>(dI./M..ICAP/1.0 200 OK<br>ISTag: "SjIzlRA4te41axxcDOoiSl6rBRg4ZK"<br>Date: Sun, 17 Jan 2021 19:34:12 GMT<br>Server: BaseICAP/1.0 Python/3.6.12<br>Encapsulated: req-hdr=0, req-body=360<br><br>POST <a href="http://www.dst-server.com:22222/v1/test">http://www.dst-server.com:22222/v1/test</a> HTTP/1.1<br>x-new-header: {"key": "value"}<br>user-agent: python-requests/2.25.1<br>accept-encoding: gzip, deflate<br>accept: */*<br>content-length: 16<br>content-type: application/json<br>host: <a href="http://www.dst-server.com:22222">www.dst-server.com:22222</a><o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal> Please assume the number in req-body=360 is correct (I trimmed here the content of the new header).<o:p></o:p></p></div><div><p class=MsoNormal>As I said, I use 'Preview: 0' since I don't mind the body. The question is whether declaring the body starts at X (req-body=X) is OK even though I don't have a body to send? I think having req-null=X is bad since it probably tells squid that I decided the adapted request should have no body, but that's only a guess.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>When the ICAP doesn't adapt the request, everything looks fine.<o:p></o:p></p></div><div><p class=MsoNormal>When it adapts the request I see that the POST request squid sends to <a href="http://www.dst-server.com">www.dst-server.com</a> doesn't contain the body.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>On the logs of the server behind <a href="http://www.dst-server.com">www.dst-server.com</a> I see an entry for the API request only after I abort the request I sent.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I use python's requests module to make the request:<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>import requests<br>s = requests.Session()<br>s.proxies = {'http': 'localhost:8000', 'https': 'localhost:8000'} <o:p></o:p></p></blockquote><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>resp = <a href="http://s.post">s.post</a>('<a href="http://www.dst-server.com:22222/v1/test">http://www.dst-server.com:22222/v1/test</a>', allow_redirects=False, json={'key': 'value'})<o:p></o:p></p></blockquote><div><p class=MsoNormal> <o:p></o:p></p></div></div><div><p class=MsoNormal>I'll highly appreciate any help.<o:p></o:p></p></div><div><p class=MsoNormal>Thanks,<o:p></o:p></p></div><div><p class=MsoNormal>Moti<o:p></o:p></p></div></div></div></body></html>