[mod_python] in modpython ,how to restrict the upload file size?

Martin Šenkeřík martinsenkerik at email.cz
Thu May 3 15:43:51 EDT 2007


Dne Sun, 01 Apr 2007 03:18:22 +0200 Graham Dumpleton  
<graham.dumpleton at gmail.com> napsal/-a:

> On 01/04/07, Martin Šenkeřík <martinsenkerik at email.cz> wrote:
>> Thank you for your explanation!
>>
>> I think, now I understand more deeply the machinery around.
>>
>> I realized that in my case I need to close connection to client at my  
>> own.
>> Some clients, while sending POST request, don't react to any response  
>> from
>> the server. However, I was reading through manual and internet but I
>> didn't find way, how to do it. The connection object doesn't seem to
>> provide a way how to close connection....
>>
>> So, my question is: what is the way to force closing the TCP connection  
>> to
>> client?
>
> In general Apache will do that for you, when appropriate. This will
> not stop the client sending data straight away. The client may only
> detect that the connection has closed after writing some amount of
> data and it gets an error. So you can't eliminate the client sending
> at least some data except by the client using the 100-continue feature
> properly.
>
> BTW, please use reply-all to keep discussion on mailing list.
>
> Graham
>

Yes, I understand, maybe I didn't formed my question well.
If client starts sending POST request and didn't use 100-continue feature  
and I decide to stop him sending the data, the only way, as far as I know,  
is by disconnecting him from the server (i expect that than client ends up  
with some error message about lost connection). And this is the point - I  
didn't find any information how to handle this from mod_python. Is there  
any way?


>> Dne Sat, 31 Mar 2007 07:28:41 +0200 Graham Dumpleton
>> <graham.dumpleton at gmail.com> napsal/-a:
>>
>> > On 31/03/07, Martin Šenkeřík <martinsenkerik at email.cz> wrote:
>> >>
>> >> This solution works fine only for Opera web browser for me. Others  
>> (I've
>> >> tested Firefox and IE6) continues with transfer. In http  
>> specification
>> >> is
>> >> about "413: Request Entity Too Large" among others written:
>> >>
>> >> "The server MAY close the connection to prevent the client from
>> >> continuing
>> >> the request."
>> >>
>> >> I was trying to find way, how force client to stop the transfer and  
>> to
>> >> redirect them to some explanation page. But with no result. Do you  
>> have
>> >> any ideas? Or is it possible, that problem is somewhere else? e.g.  
>> wrong
>> >> configuration of Apache, mod_python...?
>> >>
>> >> (using Apache/2.2.3, mod_python/3.3.1 Python/2.4.4 on Debian)
>> >
>> > See:
>> >
>> >  http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
>> >
>> > Especially section 8.2.3
>> >
>> > It all depends on whether the browser is using HTTP/1.1 and whether it
>> > is sending an Expect header with value 100-continue and subsequently
>> > waiting for a 100 continue response before sending the content.
>> >
>> > If it isn't then the client would be sending the content anyway and
>> > once it does you can't stop it.
>> >
>> > Thus, on your server side dump out to the log what headers are being
>> > sent by client and see what browsers are sending the Expect header and
>> > which aren't.
>> >
>> > I don't know how you might tell the browser to use this.
>> >
>> > Graham
>>
>>
>>



More information about the Mod_python mailing list