I have a CGI script I'm writing that's handling a streaming file upload. I'm also using Apache. If a certain size limit is reached, I have the CGI script finish things up, then it sends an HTTP redirect and exit. What I'd like to have happen at this point is for Apache to close the connection. Instead, what Apache does is keep the connection open, continuing to receive the rest of the upload. There's a comment in mod_cgi.c that even says "silly script stopped reading, soak up remaining message." I guess I'm silly, but I DON'T want the remaining message soaked up, I want my response to be sent and the connection closed.
I don't know why this is so silly, since Apache has a core option, LimitRequestBody, that pretty much has the same behavior I want, except it sends an error response instead of a custom redirect, and the limit has to be configured ahead of time, when in my case I actually might have different limits for different users.
What are my alternatives? I'm open to anything, even switching web servers.
My CGI script is written in Python but that doesn't really matter, this is an Apache issue.