title: Handling client-side timeout with a Sinatra web service
body: <p>I'm a rank beginner with Ruby and Sinatra, but have managed to come up with a web service that works pretty well, running on Heroku. I access this web service from Salesforce.com.</p>
  
  <p>The HTTPRequest class that I use in Salesforce/Apex has a maximum timeout of 60s. If I hit that timeout (or, when I hit a 1 second timeout I'm using for testing purposes), I get an exception on the Salesforce side, which I can easily handle. What I'm interested in is how to handle this on the Sinatra side.</p>
  
  <p>If my client gets a timeout, and somehow closes the connection, is there a way to "sense" this in my Sintra app? I'd like to note client timeout, continue doing the work the app had started, and then send an email to let the user know the job had finished after the timeout.</p>
  
  <p>I should note that when I do get the timeout now, the Sinatra app happily finishes what it was doing, and, I'm guessing, returns the JSON data that it is supposed to. Only there's nothing on the client side to get that data.</p>
  
  <p>Any thoughts?</p>