File tree 4 files changed +25
-7
lines changed
4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -65,9 +65,10 @@ const (
65
65
)
66
66
67
67
var mimeTypes = map [string ]string {
68
- cmds .JSON : "application/json" ,
69
- cmds .XML : "application/xml" ,
70
- cmds .Text : "text/plain" ,
68
+ cmds .Protobuf : "application/protobuf" ,
69
+ cmds .JSON : "application/json" ,
70
+ cmds .XML : "application/xml" ,
71
+ cmds .Text : "text/plain" ,
71
72
}
72
73
73
74
type ServerConfig struct {
Original file line number Diff line number Diff line change @@ -36,9 +36,10 @@ type EncodingType string
36
36
37
37
// Supported EncodingType constants.
38
38
const (
39
- JSON = "json"
40
- XML = "xml"
41
- Text = "text"
39
+ JSON = "json"
40
+ XML = "xml"
41
+ Protobuf = "protobuf"
42
+ Text = "text"
42
43
// TODO: support more encoding types
43
44
)
44
45
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ This command outputs data in the following encodings:
222
222
},
223
223
Type : Node {},
224
224
Marshalers : cmds.MarshalerMap {
225
- cmds .EncodingType ( "protobuf" ) : func (res cmds.Response ) (io.Reader , error ) {
225
+ cmds .Protobuf : func (res cmds.Response ) (io.Reader , error ) {
226
226
node := res .Output ().(* Node )
227
227
object , err := deserializeNode (node )
228
228
if err != nil {
Original file line number Diff line number Diff line change @@ -43,6 +43,22 @@ test_object_cmd() {
43
43
ipfs object get $HASH >actual_getOut
44
44
'
45
45
46
+ test_expect_success " 'ipfs object get --encoding=protobuf' returns the correct content type" '
47
+ curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=protobuf" | grep -q "^Content-Type: application/protobuf"
48
+ '
49
+
50
+ test_expect_success " 'ipfs object get --encoding=json' returns the correct content type" '
51
+ curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=json" | grep -q "^Content-Type: application/json"
52
+ '
53
+
54
+ test_expect_success " 'ipfs object get --encoding=text' returns the correct content type" '
55
+ curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=text" | grep -q "^Content-Type: text/plain"
56
+ '
57
+
58
+ test_expect_success " 'ipfs object get --encoding=xml' returns the correct content type" '
59
+ curl -sI "http://$API_ADDR/api/v0/object/get?arg=$HASH&encoding=xml" | grep -q "^Content-Type: application/xml"
60
+ '
61
+
46
62
test_expect_success " 'ipfs object get' output looks good" '
47
63
test_cmp ../t0051-object-data/expected_getOut actual_getOut
48
64
'
You can’t perform that action at this time.
0 commit comments