From 85c51404aed21813df34c518a00c52a564d6fc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 11 Sep 2019 13:31:00 +0200 Subject: feat: Set user agent for http client (#2916) --- cli/http_util.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cli') diff --git a/cli/http_util.rs b/cli/http_util.rs index ec035d6bf..6411a9ad6 100644 --- a/cli/http_util.rs +++ b/cli/http_util.rs @@ -1,11 +1,14 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. use crate::deno_error; use crate::deno_error::DenoError; +use crate::version; use deno::ErrBox; use futures::{future, Future}; use reqwest; +use reqwest::header::HeaderMap; use reqwest::header::CONTENT_TYPE; use reqwest::header::LOCATION; +use reqwest::header::USER_AGENT; use reqwest::r#async::Client; use reqwest::RedirectPolicy; use url::Url; @@ -13,8 +16,14 @@ use url::Url; /// Create new instance of async reqwest::Client. This client supports /// proxies and doesn't follow redirects. pub fn get_client() -> Client { + let mut headers = HeaderMap::new(); + headers.insert( + USER_AGENT, + format!("Deno/{}", version::DENO).parse().unwrap(), + ); Client::builder() .redirect(RedirectPolicy::none()) + .default_headers(headers) .use_sys_proxy() .build() .unwrap() -- cgit v1.2.3