Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b9d11298
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b9d11298
编写于
8月 16, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RequestService2
上级
ca41e24f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
99 addition
and
30 deletion
+99
-30
src/vs/base/node/proxy.ts
src/vs/base/node/proxy.ts
+2
-1
src/vs/base/node/request.ts
src/vs/base/node/request.ts
+6
-4
src/vs/platform/request/common/request.ts
src/vs/platform/request/common/request.ts
+40
-1
src/vs/platform/request/node/requestService2.ts
src/vs/platform/request/node/requestService2.ts
+50
-0
src/vs/workbench/services/request/node/requestService.ts
src/vs/workbench/services/request/node/requestService.ts
+1
-24
未找到文件。
src/vs/base/node/proxy.ts
浏览文件 @
b9d11298
...
...
@@ -7,6 +7,7 @@
import
{
Url
,
parse
as
parseUrl
}
from
'
url
'
;
import
{
isBoolean
}
from
'
vs/base/common/types
'
;
import
{
Agent
}
from
'
./request
'
;
import
HttpProxyAgent
=
require
(
'
http-proxy-agent
'
);
import
HttpsProxyAgent
=
require
(
'
https-proxy-agent
'
);
...
...
@@ -25,7 +26,7 @@ export interface IOptions {
strictSSL
?:
boolean
;
}
export
function
getProxyAgent
(
rawRequestURL
:
string
,
options
:
IOptions
=
{}):
any
{
export
function
getProxyAgent
(
rawRequestURL
:
string
,
options
:
IOptions
=
{}):
Agent
{
const
requestURL
=
parseUrl
(
rawRequestURL
);
const
proxyURL
=
options
.
proxyUrl
||
getSystemProxyURI
(
requestURL
);
...
...
src/vs/base/node/request.ts
浏览文件 @
b9d11298
...
...
@@ -15,6 +15,8 @@ import { createWriteStream } from 'fs';
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
createGunzip
}
from
'
zlib
'
;
export
type
Agent
=
any
;
export
interface
IRequestOptions
{
type
?:
string
;
url
?:
string
;
...
...
@@ -23,21 +25,21 @@ export interface IRequestOptions {
headers
?:
any
;
timeout
?:
number
;
data
?:
any
;
agent
?:
any
;
agent
?:
Agent
;
followRedirects
?:
number
;
strictSSL
?:
boolean
;
}
export
interface
IRequest
Resul
t
{
export
interface
IRequest
Contex
t
{
req
:
http
.
ClientRequest
;
res
:
http
.
ClientResponse
;
stream
:
Stream
;
}
export
function
request
(
options
:
IRequestOptions
):
TPromise
<
IRequest
Resul
t
>
{
export
function
request
(
options
:
IRequestOptions
):
TPromise
<
IRequest
Contex
t
>
{
let
req
:
http
.
ClientRequest
;
return
new
TPromise
<
IRequest
Resul
t
>
((
c
,
e
)
=>
{
return
new
TPromise
<
IRequest
Contex
t
>
((
c
,
e
)
=>
{
let
endpoint
=
parseUrl
(
options
.
url
);
let
opts
:
https
.
RequestOptions
=
{
...
...
src/vs/platform/request/common/request.ts
浏览文件 @
b9d11298
...
...
@@ -4,9 +4,13 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
http
=
require
(
'
vs/base/common/http
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IRequestOptions
,
IRequestContext
}
from
'
vs/base/node/request
'
;
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
export
const
IRequestService
=
createDecorator
<
IRequestService
>
(
'
requestService
'
);
...
...
@@ -18,4 +22,39 @@ export interface IRequestService {
* of calling WinJS.XHR directly.
*/
makeRequest
(
options
:
http
.
IXHROptions
):
TPromise
<
http
.
IXHRResponse
>
;
}
\ No newline at end of file
}
export
const
IRequestService2
=
createDecorator
<
IRequestService
>
(
'
requestService2
'
);
export
interface
IRequestService2
{
_serviceBrand
:
any
;
request
(
options
:
IRequestOptions
):
TPromise
<
IRequestContext
>
;
}
export
interface
IHTTPConfiguration
{
http
?:
{
proxy
?:
string
;
proxyStrictSSL
?:
boolean
;
};
}
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
)
.
registerConfiguration
({
id
:
'
http
'
,
order
:
15
,
title
:
localize
(
'
httpConfigurationTitle
'
,
"
HTTP
"
),
type
:
'
object
'
,
properties
:
{
'
http.proxy
'
:
{
type
:
'
string
'
,
pattern
:
'
^https?://([^:]*(:[^@]*)?@)?([^:]+)(:
\\
d+)?/?$|^$
'
,
description
:
localize
(
'
proxy
'
,
"
The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"
)
},
'
http.proxyStrictSSL
'
:
{
type
:
'
boolean
'
,
default
:
true
,
description
:
localize
(
'
strictSSL
'
,
"
Whether the proxy server certificate should be verified against the list of supplied CAs.
"
)
}
}
});
\ No newline at end of file
src/vs/platform/request/node/requestService2.ts
0 → 100644
浏览文件 @
b9d11298
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IRequestOptions
,
IRequestContext
,
request
}
from
'
vs/base/node/request
'
;
import
{
getProxyAgent
}
from
'
vs/base/node/proxy
'
;
import
{
IRequestService2
,
IHTTPConfiguration
}
from
'
vs/platform/request/common/request
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
/**
* This service exposes the `request` API, while using the global
* or configured proxy settings.
*/
export
class
RequestService2
implements
IRequestService2
{
_serviceBrand
:
any
;
private
proxyUrl
:
string
;
private
strictSSL
:
boolean
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
this
.
configure
(
configurationService
.
getConfiguration
<
IHTTPConfiguration
>
());
configurationService
.
onDidUpdateConfiguration
(
this
.
onDidUpdateConfiguration
,
this
,
this
.
disposables
);
}
private
onDidUpdateConfiguration
(
e
:
IConfigurationServiceEvent
)
{
this
.
configure
(
e
.
config
);
}
private
configure
(
config
:
IHTTPConfiguration
)
{
this
.
proxyUrl
=
config
.
http
&&
config
.
http
.
proxy
;
this
.
strictSSL
=
config
.
http
&&
config
.
http
.
proxyStrictSSL
;
}
request
(
options
:
IRequestOptions
):
TPromise
<
IRequestContext
>
{
if
(
!
options
.
agent
)
{
const
{
proxyUrl
,
strictSSL
}
=
this
;
options
.
agent
=
getProxyAgent
(
options
.
url
,
{
proxyUrl
,
strictSSL
});
}
return
request
(
options
);
}
}
src/vs/workbench/services/request/node/requestService.ts
浏览文件 @
b9d11298
...
...
@@ -7,11 +7,9 @@
import
{
TPromise
,
Promise
}
from
'
vs/base/common/winjs.base
'
;
import
{
xhr
}
from
'
vs/base/common/network
'
;
import
{
IConfigurationRegistry
,
Extensions
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
nls
=
require
(
'
vs/nls
'
);
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
platform
=
require
(
'
vs/platform/platform
'
);
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
BaseRequestService
}
from
'
vs/platform/request/common/baseRequestService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -132,25 +130,4 @@ export class RequestService extends BaseRequestService {
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
// Configuration
let
confRegistry
=
<
IConfigurationRegistry
>
platform
.
Registry
.
as
(
Extensions
.
Configuration
);
confRegistry
.
registerConfiguration
({
id
:
'
http
'
,
order
:
15
,
title
:
nls
.
localize
(
'
httpConfigurationTitle
'
,
"
HTTP
"
),
type
:
'
object
'
,
properties
:
{
'
http.proxy
'
:
{
type
:
'
string
'
,
pattern
:
'
^https?://([^:]*(:[^@]*)?@)?([^:]+)(:
\\
d+)?/?$|^$
'
,
description
:
nls
.
localize
(
'
proxy
'
,
"
The proxy setting to use. If not set will be taken from the http_proxy and https_proxy environment variables
"
)
},
'
http.proxyStrictSSL
'
:
{
type
:
'
boolean
'
,
default
:
true
,
description
:
nls
.
localize
(
'
strictSSL
'
,
"
Whether the proxy server certificate should be verified against the list of supplied CAs.
"
)
}
}
});
\ No newline at end of file
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录