[squid-users] Is it possible to modify cached object?
rousskov at measurement-factory.com
Tue Feb 7 00:55:43 UTC 2017
On 02/06/2017 03:27 PM, boruc wrote:
> So I've installed squid 3.5.12, libecap 1.0.1 and sample adapter 1.0.0. I
> was able to test a simple "the -> a" replacement shown in documentation
> <http://www.e-cap.org/Documentation> . Next I tried some HTML injection,
> also from documentation. However, it didn't work and I got error like below:
> 2017/02/06 17:56:30 kid1| FATAL: dying from an unhandled exception:
> Modifying Adapter: configuration error: unsupported configuration parameter:
As you have figured out already, the following bug report adds
replacement-src support to sample adapter v1.0:
> What is more, when I try regular text replacement and I use space in
> replacement text I get no error message in cache.log, but browser says that
> "proxy server is refusing connections" and executing command "squid -k
> check" gives me this:
Squid is picky about spaces because they often separate various
configuration tokens. You can try to quote your replacement string,
possibly after turning configuration_includes_quoted_values on.
On the other hand, virtually all production adapters that inject content
into HTML pages need a far more sophisticated injection algorithm then
the primitive sample adapter you are using, so it probably does not make
sense to spend time on making spaces work in this configuration context.
> 2017/02/06 19:11:11| /etc/squid/squid.conf:84: Duplicate option "uri" in
> adaptation service definition
> FATAL: /etc/squid/squid.conf:84: malformed adaptation service configuration
> Squid Cache (Version 3.5.12): Terminated abnormally.
> I managed to find a bugfix <https://bugs.launchpad.net/ecap/+bug/1634621>
> to *replacement-src* problem, but how should I
> appy this? Just add lines with "+" at the beginning and recompile sources
> one more time?
You should use a "patch" program to apply the patch to the adapter
sample sources and then rebuild the adapter from scratch.
> Will it work with spaces in replacement text?
Yes, spaces are supported in the replacement text loaded from a file.
> My main goal is to add a
> paragraph to requested page, with link or image, but tags for those require
> spaces in string.
If you have not already, please read the following FAQ page for various
problems you will need to solve. The sample adapter does _not_ solve
most of them: https://answers.launchpad.net/ecap/+faq/1793
> Or maybe I have to write my own adapter to this?
YMMV, but I speculate that most folks that do not know how to patch
source files would have to learn a lot of complex topics before they
would be able to write a quality injection adapter from scratch. That
speculation, together with the complications mentioned at the above FAQ
page, prompt me to discourage you from attempting to write your own
adapter in C++.
I have not tried it myself yet, but you might be interested in the
following Tcl wrapper for eCAP API:
The other standard options include, if your project allows for that,
finding a capable C++ developer to write an adapter for you and buying a
More information about the squid-users