Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set correct content-type for ipfs get #2673

Closed
wants to merge 1 commit into from

Conversation

RichardLitt
Copy link
Member

This is a version of #2004, with CR from @jbenet integrated in, and should close #1824

Related to ipfs-inactive/js-ipfs-http-client#263.

License: MIT
Signed-off-by: Richard Littauer richard.littauer@gmail.com

test_expect_success "ipfs get response has the correct content-type" '
curl -I "http://localhost:$PORT_API/api/v0/get?arg=$HASH" | grep "^Content-Type: application/x-tar"
'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a negative test in here, too.

@whyrusleeping whyrusleeping added the need/review Needs a review label May 13, 2016
This is a version of #2004, with CR from @jbenet integrated in, and should close #1824

License: MIT
Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
@Kubuxu Kubuxu force-pushed the feature/set-get-content-type branch from 14bb435 to ddb8585 Compare May 31, 2016 20:53
@Kubuxu Kubuxu added need/author-input Needs input from the original author and removed need/review Needs a review labels May 31, 2016
@Kubuxu Kubuxu assigned Kubuxu and unassigned Kubuxu May 31, 2016
@Kubuxu
Copy link
Member

Kubuxu commented Jun 1, 2016

Any idea why this test fails all over the board: https://travis-ci.org/ipfs/go-ipfs/jobs/134285028#L6773-L6779 ?

@Kubuxu Kubuxu added the help wanted Seeking public contribution on this issue label Jun 1, 2016
@RichardLitt
Copy link
Member Author

I have no idea. @whyrusleeping?

@whyrusleeping
Copy link
Member

the tests that fail are ipfs config? Thats weird... what content type is being returned through that command?

@RichardLitt
Copy link
Member Author

When running on this branch:

curl -i -X POST "http://localhost:5001/api/v0/config?arg=API.HTTPHeaders"
HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
Content-Type: application/json
Server: go-ipfs/0.4.2
Trailer: X-Stream-Error
Vary: Origin
Date: Mon, 13 Jun 2016 10:53:24 GMT
Transfer-Encoding: chunked

{"Key":"API.HTTPHeaders","Value":null}

@RichardLitt RichardLitt removed the need/author-input Needs input from the original author label Jun 13, 2016
@RichardLitt RichardLitt added the need/review Needs a review label Jun 22, 2016
@whyrusleeping
Copy link
Member

@RichardLitt the reason this breaks the config command is because ipfs config show sets its output type as json (because, its output is json). Previously, made it so that any type we had an arbitrary byte stream being returned through the API, we called it text. When ipfs config show is rendered as text, its pretty printed with tabs and such for the user. Your change makes it so that hardcoding of text/plain changes back to json, and when json output is set, the output is not pretty printed (its meant to be machine readable, not so much human readable).

So here lies the issue. Should the output type of ipfs config show be text/plain when run from the command line? (even though the output is valid json)

@whyrusleeping whyrusleeping added need/author-input Needs input from the original author and removed need/review Needs a review labels Aug 18, 2016
@RichardLitt
Copy link
Member Author

This isn't for ipfs config show, but for ipfs get, so I'm a bit confused.

@whyrusleeping
Copy link
Member

@RichardLitt re-read my comment. You made a change that touches every command, that had some side effects. Take a look at the assumptions the old code made, and compare it to what your change does.

@RichardLitt
Copy link
Member Author

Should the output type of ipfs config show be text/plain when run from the command line? (even though the output is valid json)

I would say no. It should be JSON. But I am not sure.

@whyrusleeping
Copy link
Member

@RichardLitt Yeah, so thats the problem. The json formatter produces minified output, If a commands normal content type is JSON, then this PR will cause that command to produce the condensed minified output.

@RichardLitt
Copy link
Member Author

Could we add an option to pretty-print, as desired?

@RichardLitt RichardLitt removed the need/author-input Needs input from the original author label Sep 1, 2016
@RichardLitt RichardLitt removed their assignment Sep 1, 2016
@Kubuxu
Copy link
Member

Kubuxu commented Sep 28, 2016

What is follow up for this?

@RichardLitt
Copy link
Member Author

I am not attached to it. #2004 was not originally my pull request, and was closed without comment; I was trying to save what good there was in it. I don't feel familiar enough with the specific use case or the go-ipfs codebase right now to adequately change this. Feel free to close.

@whyrusleeping whyrusleeping deleted the feature/set-get-content-type branch November 19, 2016 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP API - Content-Type returned by get command should be application/x-tar
3 participants