summaryrefslogtreecommitdiff
path: root/src/http_util.rs
diff options
context:
space:
mode:
authorF001 <changchun.fan@qq.com>2018-12-12 17:43:42 +0800
committerRyan Dahl <ry@tinyclouds.org>2018-12-12 04:43:42 -0500
commite976b3e0414dc768624b77e431ee7f55b03b76a4 (patch)
tree7996df0a824af4875e19d92d916a4eee14567bb0 /src/http_util.rs
parent65dd0d516d14ff0ec5ec37513efc10b7882172e6 (diff)
use byte array instead of string for code fetch (#1307)
Diffstat (limited to 'src/http_util.rs')
-rw-r--r--src/http_util.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/http_util.rs b/src/http_util.rs
index 09c978aa3..8c289911e 100644
--- a/src/http_util.rs
+++ b/src/http_util.rs
@@ -55,7 +55,7 @@ fn resolve_uri_from_location(base_uri: &Uri, location: &str) -> Uri {
// The CodeFetch message is used to load HTTP javascript resources and expects a
// synchronous response, this utility method supports that.
-pub fn fetch_sync_string(module_name: &str) -> DenoResult<(String, String)> {
+pub fn fetch_sync_string(module_name: &str) -> DenoResult<(Vec<u8>, String)> {
let url = module_name.parse::<Uri>().unwrap();
let client = get_client();
// TODO(kevinkassimo): consider set a max redirection counter
@@ -93,11 +93,11 @@ pub fn fetch_sync_string(module_name: &str) -> DenoResult<(String, String)> {
let body = response
.into_body()
.concat2()
- .map(|body| String::from_utf8(body.to_vec()).unwrap())
+ .map(|body| body.to_vec())
.map_err(DenoError::from);
body.join(future::ok(content_type))
- }).and_then(|(body_string, maybe_content_type)| {
- future::ok((body_string, maybe_content_type.unwrap()))
+ }).and_then(|(body_bytes, maybe_content_type)| {
+ future::ok((body_bytes, maybe_content_type.unwrap()))
});
tokio_util::block_on(fetch_future)