Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
彭彦祖
code-server
提交
6b579d65
C
code-server
项目概览
彭彦祖
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
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,发现更多精彩内容 >>
未验证
提交
6b579d65
编写于
8月 08, 2019
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix webview address when using a proxy
上级
d4ed2efa
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
13 deletion
+10
-13
src/server.ts
src/server.ts
+10
-13
未找到文件。
src/server.ts
浏览文件 @
6b579d65
...
...
@@ -119,7 +119,7 @@ export abstract class Server {
protected
readonly
server
:
http
.
Server
|
https
.
Server
;
protected
rootPath
=
path
.
resolve
(
__dirname
,
"
../../../..
"
);
private
listenPromise
:
Promise
<
string
>
|
undefined
;
public
readonly
protocol
:
string
;
public
readonly
protocol
:
"
http
"
|
"
https
"
;
public
readonly
options
:
ServerOptions
;
public
constructor
(
options
:
ServerOptions
)
{
...
...
@@ -157,17 +157,12 @@ export abstract class Server {
}
/**
* The local address of the server. If you pass in a request, it will use the
* request's host if listening on a port (rather than a socket). This enables
* setting the webview endpoint to the same host the browser is using.
* The *local* address of the server.
*/
public
address
(
request
?:
http
.
IncomingMessage
):
string
{
public
address
():
string
{
const
address
=
this
.
server
.
address
();
const
endpoint
=
typeof
address
!==
"
string
"
?
(
request
?
request
.
headers
.
host
!
.
split
(
"
:
"
,
1
)[
0
]
:
(
address
.
address
===
"
::
"
?
"
localhost
"
:
address
.
address
)
)
+
"
:
"
+
address
.
port
?
(
address
.
address
===
"
::
"
?
"
localhost
"
:
address
.
address
)
+
"
:
"
+
address
.
port
:
address
;
return
`
${
this
.
protocol
}
://
${
endpoint
}
`
;
}
...
...
@@ -189,15 +184,17 @@ export abstract class Server {
return
{
content
:
await
util
.
promisify
(
fs
.
readFile
)(
filePath
),
filePath
};
}
protected
withBase
(
request
:
http
.
IncomingMessage
,
path
:
string
):
string
{
return
`
${
this
.
protocol
}
://
${
request
.
headers
.
host
}${
this
.
options
.
basePath
}${
path
}
`
;
}
private
onRequest
=
async
(
request
:
http
.
IncomingMessage
,
response
:
http
.
ServerResponse
):
Promise
<
void
>
=>
{
try
{
const
payload
=
await
this
.
preHandleRequest
(
request
);
response
.
writeHead
(
payload
.
redirect
?
HttpCode
.
Redirect
:
payload
.
code
||
HttpCode
.
Ok
,
{
"
Cache-Control
"
:
"
max-age=86400
"
,
// TODO: ETag?
"
Content-Type
"
:
getMediaMime
(
payload
.
filePath
),
...(
payload
.
redirect
?
{
Location
:
`
${
this
.
protocol
}
://
${
request
.
headers
.
host
}${
this
.
options
.
basePath
}${
payload
.
redirect
}
`
,
}
:
{}),
...(
payload
.
redirect
?
{
Location
:
this
.
withBase
(
request
,
payload
.
redirect
)
}
:
{}),
...
payload
.
headers
,
});
response
.
end
(
payload
.
content
);
...
...
@@ -464,11 +461,11 @@ export class MainServer extends Server {
]);
const
environment
=
this
.
services
.
get
(
IEnvironmentService
)
as
IEnvironmentService
;
const
locale
=
environment
.
args
.
locale
||
await
getLocaleFromConfig
(
environment
.
userDataPath
);
const
webviewEndpoint
=
this
.
address
(
request
)
+
"
/webview/
"
;
const
cwd
=
process
.
env
.
VSCODE_CWD
||
process
.
cwd
();
const
workspacePath
=
parsedUrl
.
query
.
workspace
as
string
|
undefined
;
const
folderPath
=
!
workspacePath
?
parsedUrl
.
query
.
folder
as
string
|
undefined
||
this
.
options
.
folderUri
||
cwd
:
undefined
;
const
remoteAuthority
=
request
.
headers
.
host
as
string
;
const
webviewEndpoint
=
this
.
withBase
(
request
,
"
/webview/
"
);
const
transformer
=
getUriTransformer
(
remoteAuthority
);
const
options
:
Options
=
{
WORKBENCH_WEB_CONGIGURATION
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录