Is there any way for the restlet application (server-side) to detect that
the HTTP request (client-side) has terminated prematurely? (For example,
either due to the client aborting or timing out.)


Here is the scenario -- imagine a restlet application that exposes a
resource that supports POST. This resource allows a lengthy representation
to be sent from the client in the POST request body. For example, lets say
the resource models a "container" and the POST method allows clients to load
a (potentially large) dataset into this "container".

Now imagine that the resource implementation uses a relational data store to
persist records that are POSTed, but persistence is a non-trivial operation
that includes validation and various side-effects. Therefore, it might take
5 minutes to complete a POST operation for a dataset with half a million
records. However, lets say that the implementation uses application server
memory and batching techniques, so that only 10% of the total time (30
seconds) is used to send the actual POST body over the wire from client to
server. The rest of the time, the client waits for a response while the
server processes the request (the data persistence operation).

Lets include two constraints: the solution must be synchronous, and the
restlet application is running in a servlet container.


OK -- back to the question: Is there a way for the server to detect that the
client aborted or timed out, while the server was processing the POST
request (and therefore not reading from the socket)?

For example, lets say the client is curl, and the user becomes impatiant and
hits "Control-C".

Any ideas for how to code this?


Here's something I read that makes me worried:

http://stackoverflow.com/questions/155243/why-is-it-impossible-without-attem
pting-i-o-to-detect-that-tcp-socket-was-grace


Thanks,

    - Lu

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1229165

Reply via email to