Send a http response before the entire binary data is received

I am using the postman application to communicate using REST APIs between https server and client.
https client needs to send a binary file to the server. http get request is used for this over postman application. A snippet from postman when sending the http get request is as below:

–header ‘Content-Type: application/octet-stream’
–data-binary ‘file.txt’

The http client would begin uploading the binary file. However, there are times when the http server would like to abort the request before receiving the entire file. Is it possible for the http server to send a bad request (400) response while the client is uploading the file? The idea is instead of waiting for the entire file to be uploaded onto the server, the server cancels/aborts/sends a response with failure so the client would stop uploading the file. Can someone help me if this is possible?

The reason I ask is I observed that when the server sends 400 response while the client is uploading, postman on the client side mentions about a parse error, though the response is properly structured. Not sure where I am going wrong.

Regards

Hi @fariya.fatima03 Welcome to the community :wave:

In the scenario described by you where the server abruptly aborts the request, I assume that in Postman you are receiving SOCKET Hang Up error or something among those lines - if on the client side the request still continues I assume that the server didn’t actually kill the connection, even though there was an error logged internally.

If there’s an error that is being thrown on the server side I assume you can use trycatch and catch the error then send a response that states the request was not processed.

Regarding the error you see in Postman, can you provide us with some screenshots on how you handle the response body, and a screenshot of the error you see in Postman?