Board index » delphi » How to cancel/abort incoming request

How to cancel/abort incoming request

2008-06-10 11:27:15 PM
Is it possible to abort/cancel an incoming request?
I am experimenting with file upload processing but I seem to be
unable to abort an upload of 1GB without causing an error page
in the browser saying "Connection Interrupted" (FF3) or "Cannot
display the webpage" (IE7).
I inspect the Request.ContentLength property and then send a
response saying the request is rejected when it is too big, but
this causes the error page. If I wait for the full 1GB to be
transmitted, *then* I can respond saying it failed.. *sigh*
This problem seems fundamental. Try this for example:
* Create a new WebBroker project in Delphi
* Create a new web form
* Add an Action item to the form on path /demo, but do not attach an event handler to the OnAction event
* Create a static .html file with a form method=post enctype=multipart/form-data with an input type=file and a submit button
* Run your webapp and submit the form without a file attached
* Observe: The webserver responds with:
Internal Server Error 500
Exception: EWebBrokerException
Message: No data modules registered
* This is expected. But now for the twist...
* Attach a 50MB file and submit again
* Observe: You will get a browser error page in both FF3 and IE7.
You do *not* get an HTTP 500 or any other response..
I must be missing something fundamental here..
I tried setting the response status to 413 Request Too Large.. Ironically, when using WebBroker you can apparently only respond that the request is too large *after* processing *the entire* request...
What am I missing here? Please advice, I am pulling my hairs out!
This question is related to another question I asked recently:
'When can you start writing to TWebResponse.Content?'

Re:How to cancel/abort incoming request

At least for apache webbroker applications I can give you a hint.
The Apache components are designed to download the complete request
when you first access one of the content properties. I had once a
similar problem as you did, in my case it was the implementation of
a progress callback while uploading large data files.
If you want to change something in the content downloading scheme you
have to dig into the ApacheTwoHTTP.pas file and change the
function GetStringVariable a bit.
in case 25 the download of the complete content is performed ->
therefore if you change this case for your needs (e.g. implement
a special event where you can eventually break your upload)
kind regards