I'm developing a HTTP server that can receive files through standard POST forms, that is an HTML page with a form where the user can select a file, and then press an Upload button and it will be sent to the server in multipart/form-data format, so uploading can be done from Internet Explorer or any other browser that supports these kind of forms. This works fine, however I don't want to allow clients to replace already existing files on the server, but rather receive an error response when uploading a file with the same name as an existing file. This also works fine, I simply reply with a 403 Forbidden "The file you tried to upload already exists" after receiving the data for an existing file.
My problem arises when the user for example sends a 100 MB file, that takes several minutes to upload. Once I detect that the filename exists on the server, I want to immediately respond with the error message, and not receive the entire file. When I try to do this the browser I'm testing with, which is Internet Explorer on Windows XP, seems to ignore the response, and tries to continue to send the file in question. Closing the connection on the server makes the browser to reconnect (according to the HTTP spec. recommendations) and resend the file. Disconnecting again makes the browser display a "failed" message, but not my response message.
I've looked through the HTTP 1.1 specification searching for a supported way to do what I want, but I haven't found any. Is there a defined way in the protocol to abort such requests? Or is this not possible according to the standard, and I must rely on a client that has some extra built-in support for this behaviour?