summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/Cargo.toml3
-rw-r--r--cli/http_util.rs28
-rw-r--r--cli/tests/053_import_compression.out1
-rw-r--r--cli/tests/053_import_compression/main.ts5
4 files changed, 9 insertions, 28 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index b70826d72..fdca9cceb 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -31,7 +31,6 @@ atty = "0.2.13"
base64 = "0.11.0"
bytes = "0.5.3"
byteorder = "1.3.2"
-brotli2 = "0.3.2"
clap = "2.33.0"
dirs = "2.0.2"
dlopen = "0.1.8"
@@ -47,7 +46,7 @@ notify = { version = "5.0.0-pre.2" }
rand = "0.7.2"
regex = "1.3.1"
remove_dir_all = "0.5.2"
-reqwest = { version = "0.10.1", default-features = false, features = ["rustls-tls", "stream", "gzip"] }
+reqwest = { version = "0.10.2", default-features = false, features = ["rustls-tls", "stream", "gzip", "brotli"] }
ring = "0.16.9"
rustyline = "5.0.6"
serde = { version = "1.0.104", features = ["derive"] }
diff --git a/cli/http_util.rs b/cli/http_util.rs
index 7da2c7dbd..c24792a7f 100644
--- a/cli/http_util.rs
+++ b/cli/http_util.rs
@@ -3,15 +3,12 @@ use crate::deno_error;
use crate::deno_error::DenoError;
use crate::deno_error::ErrorKind;
use crate::version;
-use brotli2::read::BrotliDecoder;
use bytes::Bytes;
use deno_core::ErrBox;
use futures::future::FutureExt;
use reqwest;
use reqwest::header::HeaderMap;
use reqwest::header::HeaderValue;
-use reqwest::header::ACCEPT_ENCODING;
-use reqwest::header::CONTENT_ENCODING;
use reqwest::header::IF_NONE_MATCH;
use reqwest::header::LOCATION;
use reqwest::header::USER_AGENT;
@@ -107,9 +104,7 @@ pub fn fetch_once(
let url = url.clone();
let fut = async move {
- let mut request = client
- .get(url.clone())
- .header(ACCEPT_ENCODING, HeaderValue::from_static("gzip, br"));
+ let mut request = client.get(url.clone());
if let Some(etag) = cached_etag {
let if_none_match_val = HeaderValue::from_str(&etag).unwrap();
@@ -157,26 +152,7 @@ pub fn fetch_once(
return Err(err.into());
}
- let content_encoding = response
- .headers()
- .get(CONTENT_ENCODING)
- .map(|content_encoding| content_encoding.to_str().unwrap().to_owned());
-
- let body;
- if let Some(content_encoding) = content_encoding {
- body = match content_encoding {
- _ if content_encoding == "br" => {
- let full_bytes = response.bytes().await?;
- let mut decoder = BrotliDecoder::new(full_bytes.as_ref());
- let mut body = vec![];
- decoder.read_to_end(&mut body)?;
- body
- }
- _ => response.bytes().await?.to_vec(),
- }
- } else {
- body = response.bytes().await?.to_vec();
- }
+ let body = response.bytes().await?.to_vec();
return Ok(FetchOnceResult::Code(body, headers_));
};
diff --git a/cli/tests/053_import_compression.out b/cli/tests/053_import_compression.out
index 5815b8ae2..371994979 100644
--- a/cli/tests/053_import_compression.out
+++ b/cli/tests/053_import_compression.out
@@ -1,3 +1,4 @@
gzip
brotli
console.log('gzip')
+console.log('brotli');
diff --git a/cli/tests/053_import_compression/main.ts b/cli/tests/053_import_compression/main.ts
index eb19cc75d..b6f7e2c9a 100644
--- a/cli/tests/053_import_compression/main.ts
+++ b/cli/tests/053_import_compression/main.ts
@@ -6,3 +6,8 @@ console.log(
"http://127.0.0.1:4545/cli/tests/053_import_compression/gziped"
).then(res => res.text())
);
+console.log(
+ await fetch(
+ "http://127.0.0.1:4545/cli/tests/053_import_compression/brotli"
+ ).then(res => res.text())
+);