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

Add Suborigin header to gateway responses #3914

Merged
merged 1 commit into from May 18, 2017

Conversation

Projects
None yet
4 participants
@jes
Contributor

jes commented May 10, 2017

This existed before but was disabled in 912a972 because the Suborigin spec
changed and it became incompatible.

This commit updates the generated Suborigin header to be conformant with the
latest spec.

Thank you Stskeeps, Kubuxu, and TUSF on IRC for holding my hand with this.

//
// NOTE: This is not yet widely supported by browsers.
if !ipnsHostname {
// e.g.: 0="ipfs.io", 1="ipfs", 2="QmYuNaKwY...", ...

This comment has been minimized.

@lgierth

lgierth May 12, 2017

Member

Part 0 is simply empty, urlPath is something like /ipfs/QmFoo/a/b.

This comment has been minimized.

@jes

jes May 12, 2017

Contributor

Noted, I'll fix.

if !ipnsHostname {
// e.g.: 0="ipfs.io", 1="ipfs", 2="QmYuNaKwY...", ...
pathComponents := strings.SplitN(urlPath, "/", 4)
suboriginRaw := []byte(strings.ToLower(pathComponents[2]))

This comment has been minimized.

@Kubuxu

Kubuxu May 12, 2017

Member

This isn't right. You can't 'ToLower' encoded value as it will change the IPFS hash.

This comment has been minimized.

@jes

jes May 12, 2017

Contributor

I guess the code isn't clear enough -- this part handles the /ipns/EXAMPLE.COM/ case; when the second part will decode as base58, it is handled accordingly. I'll add a comment to explain this.

This comment has been minimized.

@Kubuxu

Kubuxu May 12, 2017

Member

Ahh, I missed that. Yeah, it is better not to be clever in places like that.

Add Suborigin header to gateway responses (#3209)
This existed before but was disabled in 912a972 because the Suborigin spec
changed and it became incompatible.

This commit updates the generated Suborigin header to be conformant with the
latest spec.

License: MIT
Signed-off-by: James Stanley <james@incoherency.co.uk>
@whyrusleeping

This comment has been minimized.

Member

whyrusleeping commented May 15, 2017

@lgierth @Kubuxu hows this one looking?

@lgierth

One more small thing, otherwise LGTM 👍

base32Encoded, err := multibase.Encode(multibase.Base32, suboriginRaw)
if err != nil {
internalWebError(w, err)

This comment has been minimized.

@lgierth

lgierth May 16, 2017

Member

This should be a 4xx error via webError(), probably just 400 Bad Request. It's an error that can only be recovered from by altering the request.

This comment has been minimized.

@jes

jes May 17, 2017

Contributor

I don't see how base32 encoding can fail -- if it does, surely that's an internal server error, and nothing to do with the client?

This comment has been minimized.

@lgierth

lgierth May 17, 2017

Member

Mh -- yeah in this case the error can only come from an unsupported encoding parameter: https://github.com/multiformats/go-multibase/blob/master/multibase.go

LGTM then 👍

This comment has been minimized.

@jes

jes May 17, 2017

Contributor

:) Thanks mate.

@whyrusleeping whyrusleeping merged commit 5ef2f42 into ipfs:master May 18, 2017

7 checks passed

ci/circleci Your tests passed on CircleCI!
Details
codeclimate no new or fixed issues
Details
codecov/patch 78.57% of diff hit (target 35.72%)
Details
codecov/project 62.65% (+26.93%) compared to 864bf47
Details
commit-message-check/gitcop All commit messages are valid
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment