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
Content Type set by HTTP Gateway #152
Comments
wouldn't his mean that every request to the gateway becomes two request (one to the actual content, the other to figure out if .htaccess-clone exists). This may be expensive. And. if using different extensions on the filename is effectively setting the content type guessed for that file, isn't this precisely a way to hint/override the content type of certain content? |
It looks that way, however (iiuc) if gateway wants to resolve This means checking if
Unfortunately extension-based sniffing relies on arbitrary mapping hardcoded in go-ipfs and works only for popular file types, such as SVG. Publishing file with Real life example:
|
|
Just FYI there is accepted proposal ipfs/kubo#6214 for support of |
|
Has much progressed in terms of having a 404 page for ipfs hosted websites? |
|
I believe |
lidel commentedSep 4, 2019
•
edited
HTTP Gateway does content-type sniffing based on golang.org/src/net/http/sniff.go and file extension. js-ipfs uses similar setup.
Problem: there is no mechanism for website creator to override returned content-type, setting custom file extension works only for some file types.
Example
The same data produces different content-type, depending on request path.
Click to expand example!
SVG image
https://ipfs.io/ipfs/QmVdFJJBiQkVKFcvXu4WzySbZ7KnCW6uGWLJqZz5FnRWjk/ipfs-logo.svg
→ returned as
image/svg+xmlXML document
https://ipfs.io/ipfs/QmVdFJJBiQkVKFcvXu4WzySbZ7KnCW6uGWLJqZz5FnRWjk/ipfs-logo.xml
→ returned as
text/xmlUnknown extension
https://ipfs.io/ipfs/QmVdFJJBiQkVKFcvXu4WzySbZ7KnCW6uGWLJqZz5FnRWjk/ipfs-logo.foo
→ returned as
text/plainRaw CID
https://ipfs.io/ipfs/QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU
→ returned as
text/plainRaw CID + explicit filename
https://ipfs.io/ipfs/QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU?filename=/ipfs-logo.svg
→ returned as
image/svg+xmlMotivation
We want IPFS to become viable solution for hosting websites.
At the HTTP level, as a bare minimum, website owners expect to able to override:
Ideas to explore
Embedding content-type in unixfs metadata
One way to address this is to support embedding Content-Type in DAG metadata.
This is tracked in ipld/legacy-unixfs-v2#11, but is not a silver bullet.
Main cons:
Drop-in config to override content-type per directory
@warpfork noted that DAG metadata may not be the best place for storing content-type:
My take on this is:
.htaccess,.gitattributes.ipfs/content-typesand.ipfs/404.htmlto the directory, and Gateway would do the right thing when resource from directory or its subdirectories are requestedX-Content-Type-Options: nosniff)References
cc @olizilla @autonome
The text was updated successfully, but these errors were encountered: