I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-service attacks. So I do something like this:
def application(environ, start_response): status = "200 OK" headers = [('Content-Type', 'text/html'), ] start_response(status, headers) if int(environ['CONTENT_LENGTH'])>1000: return 'File too big' But this doesn't seem to work. If I upload a huge file it still waits until the entire file has been uploaded before complaining that it's too big. Is it possible to read the HTTP headers in WSGI before the request body has been read? Thanks, rg -- http://mail.python.org/mailman/listinfo/python-list