Auto merge of #9907 - nikkisquared:async_tests, r=jdm

Add Tests For Asynchronous Fetch Calls With Filtered Responses

I've added two tests using async_fetch intended to create filtered responses. I caught and fixed a bug where waiting for response.body to be completed would never pass for Opaque or OpaqueRedirect, since their response.body is always `Empty`.

As always, I'd appreciate review and feedback! I don't plan to write new tests, but I will gladly patch up any gaps in the current tests.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9907)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-03-10 08:59:07 +05:30
commit 95883dcbcf
2 changed files with 80 additions and 4 deletions

View file

@ -133,7 +133,14 @@ impl Response {
}
pub fn wait_until_done(&self) {
while !self.body.lock().unwrap().is_done() && !self.is_network_error() {
match self.response_type {
// since these response types can't hold a body, they should be considered done
ResponseType::Error | ResponseType::Opaque | ResponseType::OpaqueRedirect => {},
_ => {
while !self.body.lock().unwrap().is_done() && !self.is_network_error() {
// loop until done
}
}
}
}