CherryPy Project Download

Block Google Web Accelerator

def block_gwa():
    if cherrypy.request.headers.get("X_MOZ", "") == "prefetch":
        msg = "Google Web Accelerator requests are not allowed."
        raise cherrypy.HTTPError(403, msg)
cherrypy.tools.block_gwa = cherrypy.Tool('on_start_resource', block_gwa)

Older versions

2.2

class GoogleWebAcceleratorBlocker:
    def onStartResource(self):
        if cherrypy.request.headerMap.get("X_MOZ", "") == "prefetch":
            msg = "Google Web Accelerator requests are not allowed."
            raise cherrypy.HTTPError(403, msg)

2.1

Use HTTPClientError instead of HTTPError.

Hosted by WebFaction

Log in as guest/cherrypy to create/edit wiki pages