forked from extern/nushell
Add more formats
This commit is contained in:
parent
00b3106f05
commit
be69df86a9
@ -81,6 +81,17 @@ pub fn fetch(
|
|||||||
Value::string(r.text().unwrap()),
|
Value::string(r.text().unwrap()),
|
||||||
span,
|
span,
|
||||||
)),
|
)),
|
||||||
|
(mime::APPLICATION, mime::OCTET_STREAM) => {
|
||||||
|
let mut buf: Vec<u8> = 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) => {
|
(mime::IMAGE, image_ty) => {
|
||||||
let mut buf: Vec<u8> = vec![];
|
let mut buf: Vec<u8> = vec![];
|
||||||
r.copy_to(&mut buf).map_err(|_| {
|
r.copy_to(&mut buf).map_err(|_| {
|
||||||
@ -92,6 +103,11 @@ pub fn fetch(
|
|||||||
})?;
|
})?;
|
||||||
Ok((Some(image_ty.to_string()), Value::Binary(buf), span))
|
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) => {
|
(mime::TEXT, mime::PLAIN) => {
|
||||||
let path_extension = r
|
let path_extension = r
|
||||||
.url()
|
.url()
|
||||||
|
Loading…
Reference in New Issue
Block a user