Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ajax.Request considers timeout/connection close to be a success. #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michielbuddingh
Copy link

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.

Browsers will return a 0 status when the connection is broken off or
times out ... but this is also used to indicate success.  Checking for
an empty header string seems to be a portable workaround.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants