-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
don't use the domain name as a filename in /ipns/a.com #5564
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,14 @@ func TestGatewayGet(t *testing.T) { | |
ns["/ipns/double.example.com"] = path.FromString("/ipns/working.example.com") | ||
ns["/ipns/triple.example.com"] = path.FromString("/ipns/double.example.com") | ||
ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k) | ||
// We picked .man because: | ||
// 1. It's a valid TLD. | ||
// 2. Go treats it as the file extension for "man" files (even though | ||
// nobody actually *uses* this extension, AFAIK). | ||
// | ||
// Unfortunately, this may not work on all platforms as file type | ||
// detection is platform dependent. | ||
ns["/ipns/example.man"] = path.FromString("/ipfs/" + k) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I take it that Alternatively I would have the content be a small html file and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I picked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a comment. |
||
|
||
t.Log(ts.URL) | ||
for _, test := range []struct { | ||
|
@@ -175,6 +183,8 @@ func TestGatewayGet(t *testing.T) { | |
{"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link by that name\n"}, | ||
{"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, | ||
{"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, | ||
// This test case ensures we don't treat the TLD as a file extension. | ||
{"example.man", "/", http.StatusOK, "fnord"}, | ||
} { | ||
var c http.Client | ||
r, err := http.NewRequest("GET", ts.URL+test.path, nil) | ||
|
@@ -190,6 +200,10 @@ func TestGatewayGet(t *testing.T) { | |
continue | ||
} | ||
defer resp.Body.Close() | ||
contentType := resp.Header.Get("Content-Type") | ||
if contentType != "text/plain; charset=utf-8" { | ||
t.Errorf("expected content type to be text/plain, got %s", contentType) | ||
} | ||
if resp.StatusCode != test.status { | ||
t.Errorf("got %d, expected %d from %s", resp.StatusCode, test.status, urlstr) | ||
continue | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is system dependent. http.ServeContext calls mime.TypeByExtension which in the sandbox go environment does not detect it as a
application/x-troff-man
. See: https://play.golang.org/p/ohNcHHsVArqThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Damn, that's why
.com
wasn't working.