Non-blocking network IO

This commit is contained in:
Naveen Gattu 2021-12-05 23:14:49 -08:00
parent f77e66bbf8
commit 903e0cd857
13 changed files with 475 additions and 345 deletions

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crossbeam_channel::unbounded;
use http::header::{HeaderValue, EXPIRES};
use http::StatusCode;
use msg::constellation_msg::TEST_PIPELINE_ID;
@ -11,6 +10,7 @@ use net_traits::request::{Origin, Referrer, Request};
use net_traits::response::{HttpsState, Response, ResponseBody};
use net_traits::{ResourceFetchTiming, ResourceTimingType};
use servo_url::ServoUrl;
use tokio2::sync::mpsc::unbounded_channel as unbounded;
#[test]
fn test_refreshing_resource_sets_done_chan_the_appropriate_value() {
@ -40,7 +40,8 @@ fn test_refreshing_resource_sets_done_chan_the_appropriate_value() {
cache.store(&request, &response);
// Second, mutate the response into a 304 response, and refresh the stored one.
response.status = Some((StatusCode::NOT_MODIFIED, String::from("304")));
let mut done_chan = Some(unbounded());
let (send, recv) = unbounded();
let mut done_chan = Some((send, recv));
let refreshed_response = cache.refresh(&request, response.clone(), &mut done_chan);
// Ensure a resource was found, and refreshed.
assert!(refreshed_response.is_some());