Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
112ce0df
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,发现更多精彩内容 >>
提交
112ce0df
编写于
9月 25, 2019
作者:
B
Bartek Iwańczuk
提交者:
Ryan Dahl
9月 24, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add HTTP_PROXY tests (#2977)
上级
a497f87b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
99 addition
and
5 deletion
+99
-5
cli/flags.rs
cli/flags.rs
+3
-1
cli/tests/045_proxy_client.ts
cli/tests/045_proxy_client.ts
+7
-0
cli/tests/045_proxy_test.ts
cli/tests/045_proxy_test.ts
+75
-0
cli/tests/045_proxy_test.ts.out
cli/tests/045_proxy_test.ts.out
+3
-0
cli/tests/integration_tests.rs
cli/tests/integration_tests.rs
+5
-0
website/manual.md
website/manual.md
+6
-4
未找到文件。
cli/flags.rs
浏览文件 @
112ce0df
...
...
@@ -62,7 +62,9 @@ pub struct DenoFlags {
static
ENV_VARIABLES_HELP
:
&
str
=
"ENVIRONMENT VARIABLES:
DENO_DIR Set deno's base directory
NO_COLOR Set to disable color"
;
NO_COLOR Set to disable color
HTTP_PROXY Set proxy address for HTTP requests (module downloads, fetch)
HTTPS_PROXY Set proxy address for HTTPS requests (module downloads, fetch)"
;
fn
add_run_args
<
'a
,
'b
>
(
app
:
App
<
'a
,
'b
>
)
->
App
<
'a
,
'b
>
{
app
...
...
cli/tests/045_proxy_client.ts
0 → 100644
浏览文件 @
112ce0df
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
async
function
main
():
Promise
<
void
>
{
const
res
=
await
fetch
(
"
http://deno.land/welcome.ts
"
);
console
.
log
(
`Response http:
${
await
res
.
text
()}
`
);
}
main
();
cli/tests/045_proxy_test.ts
0 → 100644
浏览文件 @
112ce0df
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import
{
serve
,
ServerRequest
}
from
"
../../js/deps/https/deno.land/std/http/server.ts
"
;
import
{
assertEquals
}
from
"
../../js/deps/https/deno.land/std/testing/asserts.ts
"
;
const
addr
=
Deno
.
args
[
1
]
||
"
127.0.0.1:4555
"
;
async
function
proxyServer
():
Promise
<
void
>
{
const
server
=
serve
(
addr
);
console
.
log
(
`Proxy server listening on http://
${
addr
}
/`
);
for
await
(
const
req
of
server
)
{
proxyRequest
(
req
);
}
}
async
function
proxyRequest
(
req
:
ServerRequest
):
Promise
<
void
>
{
console
.
log
(
`Proxy request to:
${
req
.
url
}
`
);
const
resp
=
await
fetch
(
req
.
url
,
{
method
:
req
.
method
,
headers
:
req
.
headers
});
req
.
respond
(
resp
);
}
async
function
testFetch
():
Promise
<
void
>
{
const
c
=
Deno
.
run
({
args
:
[
Deno
.
execPath
(),
"
--no-prompt
"
,
"
--reload
"
,
"
--allow-net
"
,
"
045_proxy_client.ts
"
],
stdout
:
"
piped
"
,
env
:
{
HTTP_PROXY
:
`http://
${
addr
}
`
}
});
const
status
=
await
c
.
status
();
assertEquals
(
status
.
code
,
0
);
c
.
close
();
}
async
function
testModuleDownload
():
Promise
<
void
>
{
const
http
=
Deno
.
run
({
args
:
[
Deno
.
execPath
(),
"
--no-prompt
"
,
"
--reload
"
,
"
fetch
"
,
"
http://deno.land/welcome.ts
"
],
stdout
:
"
piped
"
,
env
:
{
HTTP_PROXY
:
`http://
${
addr
}
`
}
});
const
httpStatus
=
await
http
.
status
();
assertEquals
(
httpStatus
.
code
,
0
);
http
.
close
();
}
async
function
main
():
Promise
<
void
>
{
proxyServer
();
await
testFetch
();
await
testModuleDownload
();
Deno
.
exit
(
0
);
}
main
();
cli/tests/045_proxy_test.ts.out
0 → 100644
浏览文件 @
112ce0df
Proxy server listening on [WILDCARD]
Proxy request to: http://deno.land/welcome.ts
Proxy request to: http://deno.land/welcome.ts
cli/tests/integration_tests.rs
浏览文件 @
112ce0df
...
...
@@ -317,6 +317,11 @@ itest!(_044_bad_resource {
exit_code
:
1
,
});
itest!
(
_045_
proxy
{
args
:
"run --allow-net --allow-env --allow-run --reload 045_proxy_test.ts"
,
output
:
"045_proxy_test.ts.out"
,
});
itest!
(
async_error
{
exit_code
:
1
,
args
:
"run --reload async_error.ts"
,
...
...
website/manual.md
浏览文件 @
112ce0df
...
...
@@ -712,6 +712,8 @@ SUBCOMMANDS:
ENVIRONMENT VARIABLES:
DENO_DIR Set deno's base directory
NO_COLOR Set to disable color
HTTP_PROXY Set proxy address for HTTP requests (module downloads, fetch)
HTTPS_PROXY Set proxy address for HTTPS requests (module downloads, fetch)
```
### Environmental variables
...
...
@@ -876,12 +878,12 @@ $ deno install awesome_cli https://example.com/awesome/cli.ts
## Proxies
Deno supports proxies.
Deno supports proxies
for module downloads and
`fetch`
API
.
`HTTP_PROXY`
and
`HTTPS_PROXY`
environmental variables are used to configure
them
.
Proxy configuration is read from environmental variables:
`HTTP_PROXY`
and
`HTTPS_PROXY`
.
For Windows if environmental variables are not found Deno will fall
back to
In case of Windows if environmental variables are not found Deno falls
back to
reading proxies from registry.
## Import maps
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录