Authenticate ajax multicast request before starting file upload
I am uploading files to Java Servlet via ajax. I need to authenticate the download request before starting the download.
I added my authentication token before sending the request like (AJAX)
beforeSend: function(request) { request.setRequestHeader("tokenName", "tokenData");
},
and got it in a servlet filter like
String tokenData=httpRequest.getHeader("tokenName");
This works fine until the token is valid. Now when I upload a large file, say 512MB, the browser starts uploading and before it finishes uploading, I already check the authentication token on the servlet side and if it is not a valid token I return a JSON ERROR, resulting in net :: ERR_CONNECTION_RESET is on CHROME and does not display the JSON response I sent.
How can I avoid net :: ERR_CONNECTION_RESET or check the token before starting the download.
+3
source to share
No one has answered this question yet
Check out similar questions: