ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
15.98k stars 3k forks source link

ipns gateway show resolution in headers #2045

Open jbenet opened 8 years ago

jbenet commented 8 years ago

would be nice if the headers of the http request to a /ipns/... path showed the resolution steps:

> curl -I http://voxelot.us/ipns/foo.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Content-Length: 4438
Content-Type: text/html; charset=utf-8
Last-Modified: Mon, 07 Dec 2015 16:41:41 GMT
Suborigin: foo.com
X-Ipns-Path: /ipns/foo.com 
X-Ipns-Resolution: /ipns/foo.com /ipns/QmUqBf56JeGUvuf2SiJNJahAqaVhFSHS6r9gYk5FbS4TAn /ipfs/<resolved-hash-here>
X-Ipfs-Path: /ipfs/<resolved-hash-here>
Date: Mon, 07 Dec 2015 16:41:41 GMT
jbenet commented 8 years ago
kalmi commented 8 years ago

I decided to take a crack at this. (I am quite new to golang, and this seemed simple enough.) "X-Ipfs-Path" is "X-IPFS-Path" at the moment, and has the old behavior of returning a (non-root) ipns path upon requests to ipns paths. I assume we are okay with changing it to "X-Ipfs-Path". Looks better imo, and header keys are case-insensitive, so it shouldn't matter.

Are you sure you want X-Ipns-Path to return an ipns root path? Imo it would make more sense to return the full ipns path. X-Ipns-Resolution would already contain the ipns root path.

agentofuser commented 5 years ago

I noticed today that gateway are still returning an IPNS path instead of an IPFS path in x-ipfs-path (both on ipfs.io and cloudflare-ipfs.com). It would be nice to get the actual hash and have a separate header for IPNS.

Stebalien commented 5 years ago

At this point, I'd rather leave X-IPFS-Path and add some X-IPFS-Resolved header (or something like that).

Rational: addons like the browser companion are using the X-IPFS-Path header to detect resources available on IPFS. That is, we're treating this header as a "content also available here" header.

Stebalien commented 5 years ago

@agentofuser up for writing a patch (core/corehttp/gateway_handler.go)?

agentofuser commented 5 years ago

@Stebalien good point. I haven't used Go before but this seems like it would be a good way to get acquainted with it. I'm working on ipfs-deploy at the moment and need some things from js-ipfsd-ctl that I want to contribute back too, so it'll probably take me some time to get around to this issue. If more people show interest I can bump its priority in my queue.

Stebalien commented 5 years ago

Given the age of this issue, you can probably take your time.