/* * This file is part of the FOSHttpCache package. * * (c) FriendsOfSymfony * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ sub fos_ban_recv { if (req.method == "BAN") { if (!client.ip ~ invalidators) { return (synth(405, "Not allowed")); } if (req.http.X-Cache-Tags) { ban("obj.http.X-Host ~ " + req.http.X-Host + " && obj.http.X-Url ~ " + req.http.X-Url + " && obj.http.content-type ~ " + req.http.X-Content-Type // the left side is the response header, the right side the invalidation header + " && obj.http.X-Cache-Tags ~ " + req.http.X-Cache-Tags ); } else { ban("obj.http.X-Host ~ " + req.http.X-Host + " && obj.http.X-Url ~ " + req.http.X-Url + " && obj.http.content-type ~ " + req.http.X-Content-Type ); } return (synth(200, "Banned")); } } sub fos_ban_backend_response { # Set ban-lurker friendly custom headers set beresp.http.X-Url = bereq.url; set beresp.http.X-Host = bereq.http.host; } sub fos_ban_deliver { # Keep ban-lurker headers only if debugging is enabled if (!resp.http.X-Cache-Debug) { # Remove ban-lurker friendly custom headers when delivering to client unset resp.http.X-Url; unset resp.http.X-Host; # Unset the tagged cache headers unset resp.http.X-Cache-Tags; } }