summaryrefslogtreecommitdiff
path: root/src/http_util.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-01-03 22:11:01 -0500
committerGitHub <noreply@github.com>2019-01-03 22:11:01 -0500
commitea6c9f2f365698e8120177bb7a1344e83f859180 (patch)
tree3174c0cc4004063fb626255c82fbb4ffefad5d7a /src/http_util.rs
parent6be1164d8917b1ee40d344151f387417352fc804 (diff)
Revert "use byte array instead of string for code fetch (#1307)" (#1455)
This reverts commit e976b3e0414dc768624b77e431ee7f55b03b76a4. There is nothing technically wrong with this commit, but it's adding complexity to a big refactor (native ES modules #975). Since it's not necessary and simply a philosophical preference, I will revert for now and try to bring it back later.
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 3d8ae6791..e3c21e0a9 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<(Vec<u8>, String)> {
+pub fn fetch_sync_string(module_name: &str) -> DenoResult<(String, 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<(Vec<u8>, String)> {
let body = response
.into_body()
.concat2()
- .map(|body| body.to_vec())
+ .map(|body| String::from_utf8(body.to_vec()).unwrap())
.map_err(DenoError::from);
body.join(future::ok(content_type))
- }).and_then(|(body_bytes, maybe_content_type)| {
- future::ok((body_bytes, maybe_content_type.unwrap()))
+ }).and_then(|(body_string, maybe_content_type)| {
+ future::ok((body_string, maybe_content_type.unwrap()))
});
tokio_util::block_on(fetch_future)