From be69df86a9e5539822f45fc819138934369fb438 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 18 Jul 2019 07:05:20 +1200 Subject: [PATCH] Add more formats --- src/commands/open.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/commands/open.rs b/src/commands/open.rs index 92e53c906..fda4fa335 100644 --- a/src/commands/open.rs +++ b/src/commands/open.rs @@ -81,6 +81,17 @@ pub fn fetch( Value::string(r.text().unwrap()), span, )), + (mime::APPLICATION, mime::OCTET_STREAM) => { + let mut buf: Vec = vec![]; + r.copy_to(&mut buf).map_err(|_| { + ShellError::labeled_error( + "Could not load binary file", + "could not load", + span, + ) + })?; + Ok((None, Value::Binary(buf), span)) + } (mime::IMAGE, image_ty) => { let mut buf: Vec = vec![]; r.copy_to(&mut buf).map_err(|_| { @@ -92,6 +103,11 @@ pub fn fetch( })?; Ok((Some(image_ty.to_string()), Value::Binary(buf), span)) } + (mime::TEXT, mime::HTML) => Ok(( + Some("html".to_string()), + Value::string(r.text().unwrap()), + span, + )), (mime::TEXT, mime::PLAIN) => { let path_extension = r .url()