0

We are developing a Web server with tomcat. We have a requirement that if the disk is about to full (a threshold about 500MB left), we will respond to the file upload request with error code 503 server unavailable.

The question is we don't want to read this request body (file upload) at all, so we just respond to the client with error code without reading the request body. But in this case, we will get an "connection reset" issue, since client is still send the request but we (the server) close the connection.

So is there a way that servlet/tomcat do not need read the request body and just send a response code?

morgan117
  • 338
  • 1
  • 5
  • 16
  • That's really not the way that form uploads work. Once it gets started it isn't really interruptible. But check [this post](https://stackoverflow.com/questions/3717793/javascript-file-upload-size-validation) to allow you to validate on the client side the size of the file before you even begin the upload. This will take some more work - the client will need to ask the server somehow if an upload of a particular size is ok before actually uploading. The user experience on the browser may be a bit weird - you'll select the file and it may be rejected. – stdunbar Jul 12 '19 at 16:44
  • I am trying to find solution from server side, not client side. – morgan117 Jul 17 '19 at 08:35

0 Answers0