Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
92967619
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
92967619
编写于
12月 18, 2020
作者:
A
Anmol Sethi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
proxy_agent: Improve documentation
上级
6e4e7adc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
18 deletion
+22
-18
src/node/proxy_agent.ts
src/node/proxy_agent.ts
+22
-18
未找到文件。
src/node/proxy_agent.ts
浏览文件 @
92967619
...
...
@@ -15,18 +15,20 @@ import * as proxyagent from "proxy-agent"
*/
/**
* monkeyPatch patches the node HTTP/HTTPS library to route all requests through our
* custom agent from the proxyAgent package.
* monkeyPatch patches the node http and https modules to route all requests through the
* agent we get from the proxy-agent package.
*
* We do not support $HTTPS_PROXY here as it's equivalent to proxy-agent.
* See the mapping at https://www.npmjs.com/package/proxy-agent
*
* I guess with most proxies support both HTTP and HTTPS proxying on the same port and
* so two variables aren't required anymore. And there's plenty of SOCKS proxies too.
*
* See https://stackoverflow.com/a/10442767/4283659 for HTTP vs HTTPS proxy.
* To be clear, both support HTTP/HTTPS resources, the difference is in how they fetch
* them.
*/
export
function
monkeyPatch
(
vscode
:
boolean
):
void
{
// We do not support HTTPS_PROXY here to avoid confusion. proxy-agent will automatically
// use the correct protocol to connect to the proxy depending on the requested URL.
//
// We could implement support ourselves to allow people to configure the proxy used for
// HTTPS vs HTTP but there doesn't seem to be much value in that.
//
// At least of right now, it'd just be plain confusing to support HTTPS_PROXY when proxy-agent
// will still use HTTP to hit it for HTTP requests.
const
proxyURL
=
process
.
env
.
HTTP_PROXY
||
process
.
env
.
http_proxy
if
(
!
proxyURL
)
{
return
...
...
@@ -47,14 +49,16 @@ export function monkeyPatch(vscode: boolean): void {
pa
=
new
(
proxyagent
as
any
).
default
(
proxyURL
)
}
/**
* None of our code ever passes in a explicit agent to the http modules but VS Code's
* does sometimes but only when a user sets the http.proxy configuration.
* See https://code.visualstudio.com/docs/setup/network#_legacy-proxy-server-support
*
* Even if they do, it's probably the same proxy so we should be fine! And those are
* deprecated anyway.
*/
// None of our code ever passes in a explicit agent to the http modules but VS Code's
// does sometimes but only when a user sets the http.proxy configuration.
// See https://code.visualstudio.com/docs/setup/network#_legacy-proxy-server-support
//
// Even if they do, it's probably the same proxy so we should be fine! And those are
// deprecated anyway. In fact, they implemented it incorrectly as they won't retrieve
// HTTPS resources over a HTTP proxy which is perfectly valid! Both HTTP and HTTPS proxies
// support HTTP/HTTPS resources.
//
// See https://stackoverflow.com/a/10442767/4283659
const
http
=
require
(
"
http
"
)
const
https
=
require
(
"
https
"
)
http
.
globalAgent
=
pa
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录