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

Gateway: handleSuperfluousNamespace doesn't work with Hostnames #344

Closed
1 task
hacdias opened this issue Jun 9, 2023 · 2 comments · Fixed by #572
Closed
1 task

Gateway: handleSuperfluousNamespace doesn't work with Hostnames #344

hacdias opened this issue Jun 9, 2023 · 2 comments · Fixed by #572
Assignees
Labels
P2 Medium: Good to have, but can wait until someone steps up topic/gateway Issues related to HTTP Gateway

Comments

@hacdias
Copy link
Member

hacdias commented Jun 9, 2023

When the gateway is wrapped with the Hostname Handler, the superfluous namespace redirect doesn't work. This is because HostnameHandler will immediately say that the path is invalid. I suspect this may be happening with other things. It has probably happened before, but we've never noticed.

Solutions:

  1. Remove it. Do we really need it?
  2. Add it to the hostname handler. Then, we'll be verifying this twice which contains path validation. We already check the URI query twice, but that's cheap: if it doesn't exist, nothing is done. Here we always run the path.IsValid, which costs more.
  3. Rework it to make it simpler: just check if URL starts with /ipfs/ipfs or /ipfs/ipns and do the redirect. Do not do path validation. That will happen after redirection anyways. Then add it to the Hostname handler again.
  • Add conformance test, hint should say it's quality of life improvement.
@hacdias hacdias added the need/triage Needs initial labeling and prioritization label Jun 9, 2023
@hacdias hacdias changed the title Gateway: handleSuperfluousNamespace with NewHostnameHandler Gateway: handleSuperfluousNamespace doesn't work with Hostnames Jun 9, 2023
@hacdias hacdias added P2 Medium: Good to have, but can wait until someone steps up topic/gateway Issues related to HTTP Gateway and removed need/triage Needs initial labeling and prioritization labels Jun 9, 2023
@hacdias hacdias self-assigned this Jun 9, 2023
@hacdias hacdias moved this to 🥞 Todo in IPFS Shipyard Team Jun 9, 2023
@hacdias
Copy link
Member Author

hacdias commented Jun 14, 2023

@lidel right now the handler does a 400 Bad Request with an HTML document that does a redirection using http-equiv. What do you think about simplifying this to a Permanent Redirect and streamlining our redirects?

@lidel
Copy link
Member

lidel commented Jan 25, 2024

@hacdias that HTML stop-gap was introduced in ipfs/kubo#7930 during NFT bubble, when people started using IPFS but were not familiar with IPFS, there were not man ydocs/resources at the time, so they did integration and addressing poorly, with invalid paths or URIs.

Example: https://opensea.io/assets/ethereum/0x3B3ee1931Dc30C1957379FAc9aba94D1C48a5405/219 which has ipfs://ipfs/Qmcg8f4F9cig2JWXunxJcdBe58Q5myYXPmGfuMn1TVeswD/nft.mp4 🙃

Times changed and most of people know how to use ipfs://, so the http-equiv stop-gap served its purpose, and we could clean this up, but we should keep a redirect to not break things.

Your suggestion to switch to HTTP 301 SGTM 👍

@github-project-automation github-project-automation bot moved this from 🥞 Todo to 🎉 Done in IPFS Shipyard Team Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Medium: Good to have, but can wait until someone steps up topic/gateway Issues related to HTTP Gateway
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants