views:

21

answers:

1

On Windows CE, I am currently in a situation where we implement a simplistic web server from scratch. The predominant use of this server will be in a one-to-one USB RNDIS connection. The server is hosted by the managed application running on the device.

Therefore, we tightly integrated POST request handling with delivered web pages. Instead of processing the complete request and storing POST data that would be too large, the current page (as identified by the request) is informed about any POSTed multipart by receiving its headers and a stream of its contents. This solution works and shines and everybody is happy.

Now, here's the question: One page in the web interface of the application allows for uploading a software update, which can be 11 to, say, 40 MB in size. We have various validation steps in place while handling this POST request, like a permission system based on a session cookie. We know whether the client is allowed to upload a software update as soon as all headers are processed, due to said session cookie. Is there any way we can avoid having to read in (and discard) all of the POST content, so that users get immediate feedback?

Our first idea was to just return a proper error message response after header processing and then close the connection, but the browser (correctly, it seems) complained bitterly about a prematurely reset by the peer.

A: 

The browser is going to want that full transmission to happen. The way around it to give the user better responsiveness is probably to use an AJAX call on the page - so instead of the page receiving the data, the page should make an AJAX call to post the actual upload to another page asynchronously. Myself, I'd do this with jQuery, but you can put together the script without any framework to do it fairly easily.

ctacke
That's sad :-( Thanks for the clarification
Arne