wiswaud wrote:
> sorry to butt in, but it's quite interesting to me too...
>
> [EMAIL PROTECTED] a écrit :
>
> > If I understand what you want to do, the quick answer is that you can't
> > do it. Even at the level of mod_python, sending back a response before
> > all data has been read is unlikely to prevent the client from sending
> > all data in the first place. Even if you used some AJAX magic which
>
> is it possible to just get the first few packets of data (any amount,
> just some amount) to be able to see how big the upload is going to be
> (as per the header from the client), and then get the data chunk by
> chunk?

Down at the Apache/mod_python level it is possible to interrogate the
headers before you have read any data in from the body of the request.
Thus, you can take actions based on the expected amount of data before
you read it. How big a block of data you then read is up to you.

There is a lot more to it than that though because Apache provides the
ability to insert input filters. As an example of a input filter for
mod_python see Tramline:

  http://www.infrae.com/products/tramline

This is an upload and download accelerator. The idea is that the input
filter intercepts any upload and automatically shovels it out to
storage for you without the actual handler needing to do it. A header
is then set so a key is available for referencing it from the storage
area.

> that it's not 1kB chunks exactly wouldn't matter to me (maybe it
> does to the OP, though).
> And what about, if we decide it's too big or wrong or whatever, having
> the view (or whichever part would be getting this data) send back a
> response immediately?
> and since we have the socket object buried in there (don't we?), can't
> we close() it then?

If you simply want to block uploads of more than a certain size then
use the Apache LimitRequestBody directive. See:

  http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody

> i do realize that the client might not notice, and might keep
> uploading, but i'm just wondering.
>
> In my case, what i'm interested in is to know how much data is coming
> my way, have the option to close the socket if it's too big, and if
> not, be able to send upload progress data back to the client's js.

The idea of upload progress bars has been discussed a number of times
on the mod_python mailing list. People generally have a quite dim view
of them and I haven't seen anyone actually demonstrate one that might
work properly.

> I'm sure this has been covered previously, but last time i checked the
> options were mostly centered on having the upload go to a cgi-bin perl
> or python file which would then do this in a more raw fashion. Is there
> now an alternative way through django? or mod_python?
>
> (where is the mod_python mailing list archive? i can't seem to find it.
> feel free to just point me to it if it's all covered there, and i
> apologize in advance if it is).

Details are on the mod_python web site at www.modpython.org.

Graham


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to