aboutsummaryrefslogtreecommitdiffstats
path: root/components/net
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-06-18 13:21:04 +0200
committerSimon Sapin <simon.sapin@exyr.org>2017-06-18 13:21:51 +0200
commit316cd35767ce94e33cd778a684ebd2dcedfde537 (patch)
tree3c21637169f75113d3c17a214a8693ff64770836 /components/net
parent7af5a7fd5409ab8db0274eb829136e5953e718ed (diff)
downloadservo-316cd35767ce94e33cd778a684ebd2dcedfde537.tar.gz
servo-316cd35767ce94e33cd778a684ebd2dcedfde537.zip
Untry
Diffstat (limited to 'components/net')
-rw-r--r--components/net/connector.rs2
-rw-r--r--components/net/filemanager_thread.rs20
-rw-r--r--components/net/http_loader.rs4
-rw-r--r--components/net/image_cache.rs4
-rw-r--r--components/net/mime_classifier.rs18
5 files changed, 24 insertions, 24 deletions
diff --git a/components/net/connector.rs b/components/net/connector.rs
index 50d8c11a6c5..659fb4b6ad9 100644
--- a/components/net/connector.rs
+++ b/components/net/connector.rs
@@ -36,7 +36,7 @@ impl NetworkConnector for HttpsConnector {
// Perform host replacement when making the actual TCP connection.
let addr = &(&*replace_host(host), port);
- let stream = HttpStream(try!(TcpStream::connect(addr)));
+ let stream = HttpStream(TcpStream::connect(addr)?);
if scheme == "http" {
Ok(HttpsStream::Http(stream))
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs
index 4af2d868025..393613d1a7b 100644
--- a/components/net/filemanager_thread.rs
+++ b/components/net/filemanager_thread.rs
@@ -357,14 +357,14 @@ impl FileManagerStore {
fn create_entry(&self, file_path: &Path, origin: &str) -> Result<SelectedFile, FileManagerThreadError> {
use net_traits::filemanager_thread::FileManagerThreadError::FileSystemError;
- let file = try!(File::open(file_path).map_err(|e| FileSystemError(e.to_string())));
- let metadata = try!(file.metadata().map_err(|e| FileSystemError(e.to_string())));
- let modified = try!(metadata.modified().map_err(|e| FileSystemError(e.to_string())));
- let elapsed = try!(modified.elapsed().map_err(|e| FileSystemError(e.to_string())));
+ let file = File::open(file_path).map_err(|e| FileSystemError(e.to_string()))?;
+ let metadata = file.metadata().map_err(|e| FileSystemError(e.to_string()))?;
+ let modified = metadata.modified().map_err(|e| FileSystemError(e.to_string()))?;
+ let elapsed = modified.elapsed().map_err(|e| FileSystemError(e.to_string()))?;
// Unix Epoch: https://doc.servo.org/std/time/constant.UNIX_EPOCH.html
let modified_epoch = elapsed.as_secs() * 1000 + elapsed.subsec_nanos() as u64 / 1000000;
let file_size = metadata.len();
- let file_name = try!(file_path.file_name().ok_or(FileSystemError("Invalid filepath".to_string())));
+ let file_name = file_path.file_name().ok_or(FileSystemError("Invalid filepath".to_string()))?;
let file_impl = FileImpl::MetaDataOnly(FileMetaData {
path: file_path.to_path_buf(),
@@ -400,7 +400,7 @@ impl FileManagerStore {
fn get_blob_buf(&self, sender: &IpcSender<FileManagerResult<ReadFileProgress>>,
id: &Uuid, origin_in: &FileOrigin, rel_pos: RelativePos,
check_url_validity: bool) -> Result<(), BlobURLStoreError> {
- let file_impl = try!(self.get_impl(id, origin_in, check_url_validity));
+ let file_impl = self.get_impl(id, origin_in, check_url_validity)?;
match file_impl {
FileImpl::Memory(buf) => {
let range = rel_pos.to_abs_range(buf.size as usize);
@@ -430,10 +430,10 @@ impl FileManagerStore {
let mime = guess_mime_type_opt(metadata.path.clone());
let range = rel_pos.to_abs_range(metadata.size as usize);
- let mut file = try!(File::open(&metadata.path)
- .map_err(|e| BlobURLStoreError::External(e.to_string())));
- let seeked_start = try!(file.seek(SeekFrom::Start(range.start as u64))
- .map_err(|e| BlobURLStoreError::External(e.to_string())));
+ let mut file = File::open(&metadata.path)
+ .map_err(|e| BlobURLStoreError::External(e.to_string()))?;
+ let seeked_start = file.seek(SeekFrom::Start(range.start as u64))
+ .map_err(|e| BlobURLStoreError::External(e.to_string()))?;
if seeked_start == (range.start as u64) {
let type_string = match mime {
diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs
index 570144e43de..5489a49594b 100644
--- a/components/net/http_loader.rs
+++ b/components/net/http_loader.rs
@@ -317,7 +317,7 @@ impl StreamedResponse {
fn from_http_response(response: WrappedHttpResponse) -> io::Result<StreamedResponse> {
let decoder = match response.content_encoding() {
Some(Encoding::Gzip) => {
- Decoder::Gzip(try!(GzDecoder::new(response)))
+ Decoder::Gzip(GzDecoder::new(response)?)
}
Some(Encoding::Deflate) => {
Decoder::Deflate(DeflateDecoder::new(response))
@@ -1340,7 +1340,7 @@ fn cors_check(request: &Request, response: &Response) -> Result<(), ()> {
let origin = response.headers.get::<AccessControlAllowOrigin>().cloned();
// Step 2
- let origin = try!(origin.ok_or(()));
+ let origin = origin.ok_or(())?;
// Step 3
if request.credentials_mode != CredentialsMode::Include &&
diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs
index 3842537f8ba..516101f7b34 100644
--- a/components/net/image_cache.rs
+++ b/components/net/image_cache.rs
@@ -53,9 +53,9 @@ fn decode_bytes_sync(key: LoadKey, bytes: &[u8]) -> DecoderMsg {
}
fn get_placeholder_image(webrender_api: &webrender_traits::RenderApi, path: &PathBuf) -> io::Result<Arc<Image>> {
- let mut file = try!(File::open(path));
+ let mut file = File::open(path)?;
let mut image_data = vec![];
- try!(file.read_to_end(&mut image_data));
+ file.read_to_end(&mut image_data)?;
let mut image = load_from_memory(&image_data).unwrap();
set_webrender_image_key(webrender_api, &mut image);
Ok(Arc::new(image))
diff --git a/components/net/mime_classifier.rs b/components/net/mime_classifier.rs
index e4e1d7c0093..95ad0b543c0 100644
--- a/components/net/mime_classifier.rs
+++ b/components/net/mime_classifier.rs
@@ -169,14 +169,14 @@ impl MimeClassifier {
}
pub fn validate(&self) -> Result<(), String> {
- try!(self.image_classifier.validate());
- try!(self.audio_video_classifier.validate());
- try!(self.scriptable_classifier.validate());
- try!(self.plaintext_classifier.validate());
- try!(self.archive_classifier.validate());
- try!(self.binary_or_plaintext.validate());
- try!(self.feeds_classifier.validate());
- try!(self.font_classifier.validate());
+ self.image_classifier.validate()?;
+ self.audio_video_classifier.validate()?;
+ self.scriptable_classifier.validate()?;
+ self.plaintext_classifier.validate()?;
+ self.archive_classifier.validate()?;
+ self.binary_or_plaintext.validate()?;
+ self.feeds_classifier.validate()?;
+ self.font_classifier.validate()?;
Ok(())
}
@@ -547,7 +547,7 @@ impl MIMEChecker for GroupedClassifier {
fn validate(&self) -> Result<(), String> {
for byte_matcher in &self.byte_matchers {
- try!(byte_matcher.validate())
+ byte_matcher.validate()?
}
Ok(())
}