Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
2b41ca17
Unverified
提交
2b41ca17
authored
5月 26, 2019
作者:
Steven Allen
提交者:
GitHub
5月 26, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6379 from ipfs/fix/http-errors
fix: use http.Error for sending errors
上级
9847416f
23d35184
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
13 行增加
和
18 行删除
+13
-18
gateway_handler.go
core/corehttp/gateway_handler.go
+5
-6
mutex_profile.go
core/corehttp/mutex_profile.go
+4
-6
proxy.go
core/corehttp/proxy.go
+1
-3
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
没有找到文件。
core/corehttp/gateway_handler.go
浏览文件 @
2b41ca17
...
...
@@ -102,14 +102,15 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
errmsg
:=
"Method "
+
r
.
Method
+
" not allowed: "
var
status
int
if
!
i
.
config
.
Writable
{
w
.
WriteHeader
(
http
.
StatusMethodNotAllowed
)
status
=
http
.
StatusMethodNotAllowed
errmsg
=
errmsg
+
"read only access"
}
else
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
status
=
http
.
StatusBadRequest
errmsg
=
errmsg
+
"bad request for "
+
r
.
URL
.
Path
}
fmt
.
Fprint
(
w
,
errmsg
)
http
.
Error
(
w
,
errmsg
,
status
)
}
func
(
i
*
gatewayHandler
)
optionsHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
@@ -600,9 +601,7 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int)
}
func
webErrorWithCode
(
w
http
.
ResponseWriter
,
message
string
,
err
error
,
code
int
)
{
w
.
WriteHeader
(
code
)
fmt
.
Fprintf
(
w
,
"%s: %s
\n
"
,
message
,
err
)
http
.
Error
(
w
,
fmt
.
Sprintf
(
"%s: %s"
,
message
,
err
),
code
)
if
code
>=
500
{
log
.
Warningf
(
"server error: %s: %s"
,
err
)
}
...
...
core/corehttp/mutex_profile.go
浏览文件 @
2b41ca17
...
...
@@ -15,25 +15,23 @@ func MutexFractionOption(path string) ServeOption {
return
func
(
_
*
core
.
IpfsNode
,
_
net
.
Listener
,
mux
*
http
.
ServeMux
)
(
*
http
.
ServeMux
,
error
)
{
mux
.
HandleFunc
(
path
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
r
.
Method
!=
http
.
MethodPost
{
w
.
WriteHeader
(
http
.
StatusMethodNotAllowed
)
http
.
Error
(
w
,
"only POST allowed"
,
http
.
StatusMethodNotAllowed
)
return
}
if
err
:=
r
.
ParseForm
();
err
!=
nil
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
_
,
_
=
w
.
Write
([]
byte
(
err
.
Error
()))
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
asfr
:=
r
.
Form
.
Get
(
"fraction"
)
if
len
(
asfr
)
==
0
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
http
.
Error
(
w
,
"parameter 'fraction' must be set"
,
http
.
StatusBadRequest
)
return
}
fr
,
err
:=
strconv
.
Atoi
(
asfr
)
if
err
!=
nil
{
w
.
WriteHeader
(
http
.
StatusBadRequest
)
_
,
_
=
w
.
Write
([]
byte
(
err
.
Error
()))
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
}
log
.
Infof
(
"Setting MutexProfileFraction to %d"
,
fr
)
...
...
core/corehttp/proxy.go
浏览文件 @
2b41ca17
...
...
@@ -73,7 +73,5 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
}
func
handleError
(
w
http
.
ResponseWriter
,
msg
string
,
err
error
,
code
int
)
{
w
.
WriteHeader
(
code
)
fmt
.
Fprintf
(
w
,
"%s: %s
\n
"
,
msg
,
err
)
log
.
Warningf
(
"http proxy error: %s: %s"
,
err
)
http
.
Error
(
w
,
fmt
.
Sprintf
(
"%s: %s"
,
msg
,
err
),
code
)
}
go.mod
浏览文件 @
2b41ca17
...
...
@@ -34,7 +34,7 @@ require (
github.com/ipfs/go-ipfs-blockstore v0.0.1
github.com/ipfs/go-ipfs-blocksutil v0.0.1
github.com/ipfs/go-ipfs-chunker v0.0.1
github.com/ipfs/go-ipfs-cmds v0.0.
7
github.com/ipfs/go-ipfs-cmds v0.0.
8
github.com/ipfs/go-ipfs-config v0.0.3
github.com/ipfs/go-ipfs-ds-help v0.0.1
github.com/ipfs/go-ipfs-exchange-interface v0.0.1
...
...
go.sum
浏览文件 @
2b41ca17
...
...
@@ -267,8 +267,8 @@ github.com/ipfs/go-ipfs-blocksutil v0.0.1 h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IW
github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtLb449gwKqXjIsnRk=
github.com/ipfs/go-ipfs-chunker v0.0.1 h1:cHUUxKFQ99pozdahi+uSC/3Y6HeRpi9oTeUHbE27SEw=
github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw=
github.com/ipfs/go-ipfs-cmds v0.0.
7 h1:0N2NXxYAZn1kHpHrZMHZYRcVGJSxQogDD89oKc0GZMg
=
github.com/ipfs/go-ipfs-cmds v0.0.
7/go.mod h1:E5ou2OpwkAtR8LdneNdq4w1vPcrTWvh/6WPhjxGaX/Y
=
github.com/ipfs/go-ipfs-cmds v0.0.
8 h1:ZMo0ZeQOr10ZKY4yxYA3lRHUbnF/ZYcV9cpU0IrlGFI
=
github.com/ipfs/go-ipfs-cmds v0.0.
8/go.mod h1:TiK4e7/V31tuEb8YWDF8lN3qrnDH+BS7ZqWIeYJlAs8
=
github.com/ipfs/go-ipfs-config v0.0.1 h1:6ED08emzI1imdsAjixFi2pEyZxTVD5ECKtCOxLBx+Uc=
github.com/ipfs/go-ipfs-config v0.0.1/go.mod h1:KDbHjNyg4e6LLQSQpkgQMBz6Jf4LXiWAcmnkcwmH0DU=
github.com/ipfs/go-ipfs-config v0.0.3 h1:Ep4tRdP1iVK76BgOprD9B/qtOEdpno+1Xb57BqydgGk=
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论