Asterbing wrote:
> In article <3qqdnTP9wK4AytzZRVn->, says...
>> Let me reiterate: Under your control is the HTML that you send
>> to provide a FORM to the client. You have control of what gets
>> executed after the POST request reaches your server. You do not
>> have control of what happens in between. The behavior of code
>> running on the client depends on the software that is installed
>> on the client, and you do not have control over that.
>>
>
> OK
Thus, even if I'm checking content-length, data file has
> already been sent : right ?
Maybe, maybe not. It depends on your web server, the speed of the
connection between the client and the server, and maybe some other
things.
The client sends an HTTP POST request, which contains the URL, the
Content-Type and the Content-Length in the header and the data file(s)
as well as any other form data in the body.
The server receives the request and has to read the header to know what
to do with the request and to fill in various environment variables
before invoking the CGI script.
Then the server has inkove the CGI script so that the CGI script can
read the body from STDIN. There are (at least) three ways to do that:
1) if the server has read *only* the header (which is difficult to
ensure in a efficient manner) it can simply pass the open socket to
the script.
2) It can also set up a pair of pipes or a socket to the script and send
everything it gets from the client to the script and vice versa.
3) Finally, it could read the rest of the body, save it to a temporary
file and invoke the script with stdin redirected to that file.
I believe most web servers use option 2 or maybe 1 with some trickery.
In these cases, the script is invoked as soon as the web server has
received and parsed the header of the request. For a large request, this
means that most of the content has not yet been sent by the client.
So theoretically, your script can just look at $ENV{HTTP_CONTENT_LENGTH}
before reading anything and - if it decides that the content length is
too long to process - send back an error message and exit.
With option 2, the web server may still read the rest of the request and
discard it. Or it may pass the output from the script to the client and
close the connection. In this case the client will notice that the
connection is broken and stop uploading. So you save some bandwidth.
However, if you do that, be sure to test it thoroughly with as many
browsers as possible. Some may display the message you sent back. Some
may additionally display a message that the connection was broken. Some
may only display this message and discard yours. Some may even retry the
upload automatically (early Mozilla versions used to do this).
None of this has anything to do with perl, of course.
hp
--
_ | Peter J. Holzer | Löschung von at.usenet.schmankerl?
|_|_) | Sysadmin WSR/LUGA |
| | |
| Diskussion derzeit in at.usenet.gruppen
__/ |
http://www.hjp.at/ |