The blagotube home of Sune Kirkeby. Here are rambling rants and some bits of code.

29. Sep
2005

HTTPMiddleware

This Django middleware helps your site handle some common features of the HTTP protocol. First off it adds a Date and Content-Length header to your responses, if they are not already set. Also, it clears the content from your response object, if the request was for the response headers only.

The last thing it does is handle conditional GET requests. If the request has If-None-Match this is compared to the response ETag, and if they match the response is turned into a not modified response. Likewise for the If-Modified-SinceLast-Modified header-pair.

The middleware is available as ibofobi.middleware.http.HTTPMiddleware in the ibofobi subversion-repository http://mel.ibofobi.dk/~sune/r/ibofobi.git. Enjoy.

This post was written by Sune Kirkeby on 2005-09-29, and claimed to be mostly about rambling.