I am working on a file transfer client/server and when sending large files I want to abort the sending of the file if some of the post vars (in the url or headers) is not correct.

I tried to do this by checking the headers in OnRequestHeadersReceived and setting the Accepted parameter to False. Hoewever, this seems to do nothing (even in SBHTTPSServer.pas the Accept var seems to do nothing).
I also think that OnRequestHeadersReceived is not a good place to send a response and close the connection if the right parameters are not set.

What would be a good approach to send a correct response to the client and close the connection before the client can send the whole (large) file?

In the newer SBB releases setting the Accepted to False parameter sends an ErrorCode and closes the connection.

However it seems that TElHTTPSServer.IntDoData will continue to process the incoming data that is in the buffer (I am posting a file that I want to refuse on the server). When TElHTTPSServer.ProcessRawData is called then still the FConnState = csHeader. The rest of the buffer (which seems to be the beginning of the content) is then processed with TElHTTPSServer.ParseHeader which leads to an exception (SB_HTTP_ERROR_CANT_PARSE_REQUEST).

I'm not sure if my observation is correct. Is it possible that the client sends the header and the beginning of the body so that they are both in the buffer? Can I change something in my code to stop processing data after Accepted = False or must something be changed in the SBB code?

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.