Blob url's changes now build and test

This commit is contained in:
ms2300 2018-09-25 14:24:43 -07:00 committed by Fernando Jiménez Moreno
parent e84e1d607b
commit 2f3affcfc8
3 changed files with 29 additions and 32 deletions

View file

@ -13,9 +13,9 @@ use mime::{self, Mime};
use net_traits::blob_url_store::parse_blob_url;
use net_traits::filemanager_thread::ReadFileProgress;
use net_traits::response::{Response, ResponseBody};
use net_traits::{http_percent_encode, NetworkError};
use net_traits::{http_percent_encode, NetworkError, ResourceFetchTiming};
use servo_url::ServoUrl;
use std::sync::mpsc::channel;
use servo_channel::channel;
// TODO: Check on GET
// https://w3c.github.io/FileAPI/#requestResponseModel
@ -24,22 +24,21 @@ use std::sync::mpsc::channel;
pub fn load_blob_async(
url: ServoUrl,
filemanager: FileManager,
response: &Response,
done_chan: &mut DoneChannel
) -> Result<(), NetworkError> {
)-> Response {
let (id, origin) = match parse_blob_url(&url) {
Ok((id, origin)) => (id, origin),
Err(()) => {
let e = format!("Invalid blob URL format {:?}", url);
return Err(NetworkError::Internal(e));
},
return Response::network_error(NetworkError::Internal("Invalid blob url".into()));
}
};
let mut response = Response::new(url, ResourceFetchTiming::new(request.timing_type()));
let (sender, receiver) = channel();
*done_chan = Some((sender.clone(), receiver));
*response.body.lock().unwrap() = ResponseBody::Receiving(vec![]);
let check_url_validity = true;
filemanager.fetch_file(sender, id, check_url_validity, origin, response);
filemanager.fetch_file(sender, id, check_url_validity, origin, &mut response);
Ok(())
response
}