Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
7c128df4
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7c128df4
编写于
9月 24, 2018
作者:
R
Ryan Dahl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use lazy_static for HttpsConnector
And rename net.rs to http.rs Share HTTP connection.
上级
7fb28219
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
11 deletion
+30
-11
BUILD.gn
BUILD.gn
+1
-0
src/deno_dir.rs
src/deno_dir.rs
+2
-2
src/handlers.rs
src/handlers.rs
+1
-1
src/http.rs
src/http.rs
+23
-7
src/main.rs
src/main.rs
+3
-1
未找到文件。
BUILD.gn
浏览文件 @
7c128df4
...
...
@@ -47,6 +47,7 @@ main_extern = [
"$rust_build:hyper",
"$rust_build:hyper_rustls",
"$rust_build:futures",
"$rust_build:lazy_static",
"$rust_build:libc",
"$rust_build:log",
"$rust_build:ring",
...
...
src/deno_dir.rs
浏览文件 @
7c128df4
...
...
@@ -4,7 +4,7 @@ use errors::DenoError;
use
errors
::
DenoResult
;
use
errors
::
ErrorKind
;
use
fs
as
deno_fs
;
use
net
;
use
http
;
use
ring
;
use
std
;
use
std
::
fmt
::
Write
;
...
...
@@ -114,7 +114,7 @@ impl DenoDir {
let
src
=
if
self
.reload
||
!
p
.exists
()
{
println!
(
"Downloading {}"
,
module_name
);
let
source
=
net
::
fetch_sync_string
(
module_name
)
?
;
let
source
=
http
::
fetch_sync_string
(
module_name
)
?
;
match
p
.parent
()
{
Some
(
ref
parent
)
=>
fs
::
create_dir_all
(
parent
),
None
=>
Ok
(()),
...
...
src/handlers.rs
浏览文件 @
7c128df4
...
...
@@ -147,7 +147,7 @@ fn permission_denied() -> DenoError {
fn
not_implemented
()
->
DenoError
{
DenoError
::
from
(
std
::
io
::
Error
::
new
(
std
::
io
::
ErrorKind
::
Other
,
"Not implemented"
"Not implemented"
,
))
}
...
...
src/
net
.rs
→
src/
http
.rs
浏览文件 @
7c128df4
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
use
errors
::
DenoResult
;
use
futures
::
Future
;
use
futures
::
Stream
;
use
hyper
;
use
hyper
::
rt
::{
Future
,
Stream
}
;
use
hyper
::
{
Client
,
Uri
}
;
use
hyper
::
client
::
HttpConnector
;
use
hyper
::
Uri
;
use
hyper_rustls
;
use
tokio
::
runtime
::
current_thread
::
Runtime
;
type
Connector
=
hyper_rustls
::
HttpsConnector
<
HttpConnector
>
;
lazy_static!
{
static
ref
CONNECTOR
:
Connector
=
{
let
num_dns_threads
=
4
;
Connector
::
new
(
num_dns_threads
)
};
}
pub
fn
get_client
()
->
Client
<
Connector
,
hyper
::
Body
>
{
// TODO use Hyper's connection pool.
let
c
=
CONNECTOR
.clone
();
Client
::
builder
()
.build
(
c
)
}
// 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
>
{
let
url
=
module_name
.parse
::
<
Uri
>
()
.unwrap
();
let
https
=
hyper_rustls
::
HttpsConnector
::
new
(
4
);
let
client
:
Client
<
_
,
hyper
::
Body
>
=
Client
::
builder
()
.build
(
https
);
let
client
=
get_client
();
// TODO Use Deno's RT
let
mut
rt
=
Runtime
::
new
()
.unwrap
();
let
body
=
rt
.block_on
(
client
.get
(
url
)
...
...
src/main.rs
浏览文件 @
7c128df4
...
...
@@ -9,6 +9,8 @@ extern crate tempfile;
extern
crate
tokio
;
extern
crate
url
;
#[macro_use]
extern
crate
lazy_static
;
#[macro_use]
extern
crate
log
;
extern
crate
dirs
;
extern
crate
hyper_rustls
;
...
...
@@ -20,9 +22,9 @@ mod errors;
mod
flags
;
mod
fs
;
pub
mod
handlers
;
mod
http
;
mod
isolate
;
mod
libdeno
;
mod
net
;
mod
version
;
use
isolate
::
Isolate
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录