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

tar cat should return appropriate headers #2427

Closed
wants to merge 1 commit into from

Conversation

RichardLitt
Copy link
Member

I've added application:x-tar and a sharness test, although I can't figure out how to run the test.

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

License: MIT
Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
@RichardLitt
Copy link
Member Author

So, the code works, but I am unhappy with it. The approach in the handler is too specific to tar cat; at times, we'll need to return other headers, like application/x-gzip in ipfs get (#2376). Also, the test doesn't work, and I'm not sure how to fix it.

This is blocking ipfs-inactive/http-api-spec#46 and needs to be incorporated into the tar Group in the API.

@RichardLitt RichardLitt added the help wanted Seeking public contribution on this issue label Mar 3, 2016
@RichardLitt RichardLitt added the need/review Needs a review label Jun 22, 2016
@RichardLitt
Copy link
Member Author

@whyrusleeping Thoughts on this?

@whyrusleeping
Copy link
Member

@keks In your commands lib refactor, will making this change be easy?

@keks
Copy link
Contributor

keks commented Mar 2, 2017

I don't think I get the change. Richard's code checks whether the request path is /cat/cat and, if so, sets the application/x-tar header. The test does a request for /tar/cat though, which makes much more sense.

Also this is a rather unclean approach, if we want to add static checks like that I think adding a new field in the Command struct is a much better option.
However, if we want a solution that also fixes #2376 this is not enough. We will need to be able to set the content type from Run, maybe adding a Response.SetContentType() method. In my rewrite that would be ResponseEmitter.SetContentType() and work pretty much the same. What is important though is that SetContentType will need to be called before the first Emit().

If we take one of the approaches above, go-ipfs-cmds can handle this. If we choose to do it another way I will need to check again.

By the way: should /cat maybe return the content type of the served data? Not sure if that is important and/or a good idea, just wondering.

@whyrusleeping
Copy link
Member

whyrusleeping commented Mar 2, 2017 via email

@whyrusleeping whyrusleeping deleted the feature/tar-cat-headers branch March 2, 2017 16:31
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 need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants