Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
6c335036
提交
6c335036
authored
5月 28, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2516 from Stebalien/protobuf-content-type
Correctly set the content type for `object get --encoding=protobuf`
上级
eaaefd51
a72d26b8
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
29 行增加
和
7 行删除
+29
-7
handler.go
commands/http/handler.go
+4
-3
response.go
commands/response.go
+4
-3
object.go
core/commands/object/object.go
+1
-1
t0051-object.sh
test/sharness/t0051-object.sh
+20
-0
没有找到文件。
commands/http/handler.go
浏览文件 @
6c335036
...
@@ -65,9 +65,10 @@ const (
...
@@ -65,9 +65,10 @@ const (
)
)
var
mimeTypes
=
map
[
string
]
string
{
var
mimeTypes
=
map
[
string
]
string
{
cmds
.
JSON
:
"application/json"
,
cmds
.
Protobuf
:
"application/protobuf"
,
cmds
.
XML
:
"application/xml"
,
cmds
.
JSON
:
"application/json"
,
cmds
.
Text
:
"text/plain"
,
cmds
.
XML
:
"application/xml"
,
cmds
.
Text
:
"text/plain"
,
}
}
type
ServerConfig
struct
{
type
ServerConfig
struct
{
...
...
commands/response.go
浏览文件 @
6c335036
...
@@ -36,9 +36,10 @@ type EncodingType string
...
@@ -36,9 +36,10 @@ type EncodingType string
// Supported EncodingType constants.
// Supported EncodingType constants.
const
(
const
(
JSON
=
"json"
JSON
=
"json"
XML
=
"xml"
XML
=
"xml"
Text
=
"text"
Protobuf
=
"protobuf"
Text
=
"text"
// TODO: support more encoding types
// TODO: support more encoding types
)
)
...
...
core/commands/object/object.go
浏览文件 @
6c335036
...
@@ -215,7 +215,7 @@ This command outputs data in the following encodings:
...
@@ -215,7 +215,7 @@ This command outputs data in the following encodings:
},
},
Type
:
Node
{},
Type
:
Node
{},
Marshalers
:
cmds
.
MarshalerMap
{
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
EncodingType
(
"protobuf"
)
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
cmds
.
Protobuf
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
node
:=
res
.
Output
()
.
(
*
Node
)
node
:=
res
.
Output
()
.
(
*
Node
)
// deserialize the Data field as text as this was the standard behaviour
// deserialize the Data field as text as this was the standard behaviour
object
,
err
:=
deserializeNode
(
node
,
"text"
)
object
,
err
:=
deserializeNode
(
node
,
"text"
)
...
...
test/sharness/t0051-object.sh
浏览文件 @
6c335036
...
@@ -289,12 +289,32 @@ test_object_cmd() {
...
@@ -289,12 +289,32 @@ test_object_cmd() {
'
'
}
}
test_object_content_type
()
{
test_expect_success
"'ipfs object get --encoding=protobuf' returns the correct content type"
'
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf"
'
test_expect_success
"'ipfs object get --encoding=json' returns the correct content type"
'
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json"
'
test_expect_success
"'ipfs object get --encoding=text' returns the correct content type"
'
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain"
'
test_expect_success
"'ipfs object get --encoding=xml' returns the correct content type"
'
curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml"
'
}
# should work offline
# should work offline
test_object_cmd
test_object_cmd
# should work online
# should work online
test_launch_ipfs_daemon
test_launch_ipfs_daemon
test_object_cmd
test_object_cmd
test_object_content_type
test_kill_ipfs_daemon
test_kill_ipfs_daemon
test_done
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论