diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2017-11-17 13:25:50 -0800 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2017-11-17 16:00:09 -0800 |
commit | 27457e4d84f6f3ef05dc9f7ee3f84fa82e0de9da (patch) | |
tree | 0c915a9de020b6fec8509657c8c8d9207ef6295c /components/script/dom/xmlhttprequest.rs | |
parent | 87e4c15280ac29eb7efc7f7824b6647c6ee1b0e0 (diff) | |
download | servo-27457e4d84f6f3ef05dc9f7ee3f84fa82e0de9da.tar.gz servo-27457e4d84f6f3ef05dc9f7ee3f84fa82e0de9da.zip |
Fetch cancellation: Send cancellation message whenever XHR needs to abort a fetch
Diffstat (limited to 'components/script/dom/xmlhttprequest.rs')
-rw-r--r-- | components/script/dom/xmlhttprequest.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 734355ee20d..f1ae76ad087 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1023,6 +1023,12 @@ impl XMLHttpRequest { } fn terminate_ongoing_fetch(&self) { + if let Some(ref cancel_chan) = *self.cancellation_chan.borrow() { + // The receiver will be destroyed if the request has already completed; + // so we throw away the error. Cancellation is a courtesy call, + // we don't actually care if the other side heard. + let _ = cancel_chan.send(()); + } let GenerationId(prev_id) = self.generation_id.get(); self.generation_id.set(GenerationId(prev_id + 1)); self.response_status.set(Ok(())); |