Thomas Lindgren wrote:
Hi all,

I'm using mod_perl2. I'd like to reject user requests, e.g., very large PUTs, after examining headers and authorizing the user, but before the request body is read. Quota checking could be an example of where this is useful.

However, at this time, even if I return an error in the handler, it (surprisingly) seems as if the request body still is uploaded. What to do?
<snip>

The only way to trigger an early close so far has been to die in the handler, which confuses clients and so on.

The server could as a worst case alternative actually close the socket, but that feels inelegant and hackish. So, my question to the esteemed list, how should this sort of thing best be done? Have I forgotten something basic? Should I return something else? Is there a more appropriate phase to do this? Should I do it another way entirely?
This could be useful, but I think it's also pretty much impossible. From what I understand, the entire request is read before any processing is done at all, and definitely before the HeaderParserPhase is executed, which is why you're seeing the behavior you describe.

The only other technique you might try would be an InputFilter, but I have a feeling that even that wouldn't really stop the upload from happening (ie the consumption of bandwidth). I think this has more to do with TCP pipelining than it does with anything else, so it's actually not "fixable" in the application at all.

Adam

Reply via email to