[squid-users] Adding headers in ICAP server with no preview

Moti Berger moberger at metanetworks.com
Sun Jan 17 20:08:54 UTC 2021


Hi

I have an environment with squid version 5.0.4 with ICAP server adapting
requests by adding an header.
When I'm trying to send a POST request with a body I'm having an issue of a
stuck connection.
What should the ICAP response look like?

What I do is to reply like this:

> (dI./M..ICAP/1.0 200 OK
> ISTag: "SjIzlRA4te41axxcDOoiSl6rBRg4ZK"
> Date: Sun, 17 Jan 2021 19:34:12 GMT
> Server: BaseICAP/1.0 Python/3.6.12
> Encapsulated: req-hdr=0, req-body=360
>
> POST http://www.dst-server.com:22222/v1/test HTTP/1.1
> x-new-header: {"key": "value"}
> user-agent: python-requests/2.25.1
> accept-encoding: gzip, deflate
> accept: */*
> content-length: 16
> content-type: application/json
> host: www.dst-server.com:22222
>

 Please assume the number in req-body=360 is correct (I trimmed here the
content of the new header).
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.

When the ICAP doesn't adapt the request, everything looks fine.
When it adapts the request I see that the POST request squid sends to
www.dst-server.com doesn't contain the body.

On the logs of the server behind www.dst-server.com I see an entry for the
API request only after I abort the request I sent.

I use python's requests module to make the request:

import requests
> s = requests.Session()
> s.proxies = {'http': 'localhost:8000', 'https': 'localhost:8000'}

resp = s.post('http://www.dst-server.com:22222/v1/test',
> allow_redirects=False, json={'key': 'value'})
>

I'll highly appreciate any help.
Thanks,
Moti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squid-cache.org/pipermail/squid-users/attachments/20210117/04f81a05/attachment.htm>


More information about the squid-users mailing list