sstephenson/prototype — pull request #100 by michielbuddingh (2013-03-31 10:23:12+00:00)
Title: Fix: Ajax.Request considers timeout/connection close to be a success.

Hey, it's quite possible to never run into this, but the `Ajax.Request` object doesn't seem to handle the case when a connection times out. An exception is thrown when the request is made synchronously, but even then the `onSuccess` callback will trigger.

The `XMLHTTPRequest` specification, at least in its older incarnation, doesn't really account for connection errors; testing for an empty header string is a plausible workaround that seems to work on all browsers.

Note that the included unit test is rather clunky, as it actually waits for a timeout on a synchronous request. The failure can also be triggered by making the webserver close the connection (without sending any response), but I've been unable to cajole Webrick into doing that.