[Welcome] [TitleIndex] [WordIndex

When your Quixote application is integrated with the Medusa HTTP server, it may be useful to be able to ignore certain requests that are clearly irrelevant to your application or that represent attempts to compromise the security of your server. Here is one method of "swallowing" requests that seems to work. Undesired requests are simply deleted before they are processed.

In your QuixoteHandler class, insert a new method:

  def reject_request(self, request):
    # (Code for logging the particulars of the request not shown)
    request['Connection'] = 'close'
    request.channel.current_request = None
    request.channel.close_when_done()

At the beginning of QuixoteHandler.continue_request(), insert the following:

    if not request.uri.startswith(MYAPP_URI_ROOT):
      self.reject_request(request)
      return

Obviously, you are free to define your own conditions under which reject_request() gets called.


CategoryCookbook


2010-09-22 22:14