Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c1847e9f
提交
c1847e9f
authored
10月 31, 2015
作者:
Henry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
putHandler: addressed CR from @jbenet
License: MIT Signed-off-by:
Henry
<
cryptix@riseup.net
>
上级
b8b4e456
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
9 行删除
+12
-9
gateway_handler.go
core/corehttp/gateway_handler.go
+8
-5
t0111-gateway-writeable.sh
test/sharness/t0111-gateway-writeable.sh
+4
-4
没有找到文件。
core/corehttp/gateway_handler.go
浏览文件 @
c1847e9f
...
...
@@ -6,7 +6,6 @@ import (
"io"
"net/http"
gopath
"path"
"path/filepath"
"strings"
"time"
...
...
@@ -276,6 +275,10 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) {
}
func
(
i
*
gatewayHandler
)
putHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
// TODO(cryptix): move me to ServeHTTP and pass into all handlers
ctx
,
cancel
:=
context
.
WithCancel
(
i
.
node
.
Context
())
defer
cancel
()
rootPath
,
err
:=
path
.
ParsePath
(
r
.
URL
.
Path
)
if
err
!=
nil
{
webError
(
w
,
"putHandler: ipfs path not valid"
,
err
,
http
.
StatusBadRequest
)
...
...
@@ -306,20 +309,20 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
}
var
newkey
key
.
Key
rnode
,
err
:=
core
.
Resolve
(
i
.
node
.
Context
()
,
i
.
node
,
rootPath
)
rnode
,
err
:=
core
.
Resolve
(
ctx
,
i
.
node
,
rootPath
)
switch
ev
:=
err
.
(
type
)
{
case
path
.
ErrNoLink
:
// ev.Node < node where resolve failed
// ev.Name < new link
// but we need to patch from the root
rnode
,
err
:=
i
.
node
.
DAG
.
Get
(
i
.
node
.
Context
()
,
key
.
B58KeyDecode
(
rsegs
[
1
]))
rnode
,
err
:=
i
.
node
.
DAG
.
Get
(
ctx
,
key
.
B58KeyDecode
(
rsegs
[
1
]))
if
err
!=
nil
{
webError
(
w
,
"putHandler: Could not create DAG from request"
,
err
,
http
.
StatusInternalServerError
)
return
}
e
:=
dagutils
.
NewDagEditor
(
i
.
node
.
DAG
,
rnode
)
err
=
e
.
InsertNodeAtPath
(
i
.
node
.
Context
()
,
newPath
,
newnode
,
uio
.
NewEmptyDirectory
)
err
=
e
.
InsertNodeAtPath
(
ctx
,
newPath
,
newnode
,
uio
.
NewEmptyDirectory
)
if
err
!=
nil
{
webError
(
w
,
"putHandler: InsertNodeAtPath failed"
,
err
,
http
.
StatusInternalServerError
)
return
...
...
@@ -350,7 +353,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) {
i
.
addUserHeaders
(
w
)
// ok, _now_ write user's headers.
w
.
Header
()
.
Set
(
"IPFS-Hash"
,
newkey
.
String
())
http
.
Redirect
(
w
,
r
,
file
path
.
Join
(
ipfsPathPrefix
,
newkey
.
String
(),
newPath
),
http
.
StatusCreated
)
http
.
Redirect
(
w
,
r
,
go
path
.
Join
(
ipfsPathPrefix
,
newkey
.
String
(),
newPath
),
http
.
StatusCreated
)
}
func
(
i
*
gatewayHandler
)
deleteHandler
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
test/sharness/t0111-gateway-writeable.sh
浏览文件 @
c1847e9f
...
...
@@ -14,10 +14,10 @@ test_launch_ipfs_daemon
port
=
$PORT_GWAY
# TODO(cryptix): netstat not avail on testing system?
#test_expect_success "ipfs daemon listening to TCP port $port" '
# test_wait_open_tcp_port_10_sec "$PORT_GWAY"
#
'
test_expect_success
"ipfs daemon up"
'
pollEndpoint -host $ADDR_GWAY -ep=/version -v -tout=1s -tries=60 2>poll_apierr > poll_apiout ||
test_fsh cat poll_apierr || test_fsh cat poll_apiout
'
test_expect_success
"HTTP gateway gives access to sample file"
'
curl -s -o welcome "http://localhost:$PORT_GWAY/ipfs/$HASH_WELCOME_DOCS/readme" &&
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论