{"action":"created","issue":{"url":"https://api.github.com/repos/ipfs/go-ipfs/issues/4545","repository_url":"https://api.github.com/repos/ipfs/go-ipfs","labels_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/4545/labels{/name}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/4545/comments","events_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/4545/events","html_url":"https://github.com/ipfs/go-ipfs/pull/4545","id":286069393,"node_id":"MDExOlB1bGxSZXF1ZXN0MTYxMTg0MjUz","number":4545,"title":"[RFC] don't sniff the filename to determine the content type","user":{"login":"Stebalien","id":310393,"node_id":"MDQ6VXNlcjMxMDM5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/310393?v=4","gravatar_id":"","url":"https://api.github.com/users/Stebalien","html_url":"https://github.com/Stebalien","followers_url":"https://api.github.com/users/Stebalien/followers","following_url":"https://api.github.com/users/Stebalien/following{/other_user}","gists_url":"https://api.github.com/users/Stebalien/gists{/gist_id}","starred_url":"https://api.github.com/users/Stebalien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stebalien/subscriptions","organizations_url":"https://api.github.com/users/Stebalien/orgs","repos_url":"https://api.github.com/users/Stebalien/repos","events_url":"https://api.github.com/users/Stebalien/events{/privacy}","received_events_url":"https://api.github.com/users/Stebalien/received_events","type":"User","site_admin":false},"labels":[{"id":129070658,"node_id":"MDU6TGFiZWwxMjkwNzA2NTg=","url":"https://api.github.com/repos/ipfs/go-ipfs/labels/in%20progress","name":"in progress","color":"ededed","default":false}],"state":"open","locked":false,"assignee":{"login":"Stebalien","id":310393,"node_id":"MDQ6VXNlcjMxMDM5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/310393?v=4","gravatar_id":"","url":"https://api.github.com/users/Stebalien","html_url":"https://github.com/Stebalien","followers_url":"https://api.github.com/users/Stebalien/followers","following_url":"https://api.github.com/users/Stebalien/following{/other_user}","gists_url":"https://api.github.com/users/Stebalien/gists{/gist_id}","starred_url":"https://api.github.com/users/Stebalien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stebalien/subscriptions","organizations_url":"https://api.github.com/users/Stebalien/orgs","repos_url":"https://api.github.com/users/Stebalien/repos","events_url":"https://api.github.com/users/Stebalien/events{/privacy}","received_events_url":"https://api.github.com/users/Stebalien/received_events","type":"User","site_admin":false},"assignees":[{"login":"Stebalien","id":310393,"node_id":"MDQ6VXNlcjMxMDM5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/310393?v=4","gravatar_id":"","url":"https://api.github.com/users/Stebalien","html_url":"https://github.com/Stebalien","followers_url":"https://api.github.com/users/Stebalien/followers","following_url":"https://api.github.com/users/Stebalien/following{/other_user}","gists_url":"https://api.github.com/users/Stebalien/gists{/gist_id}","starred_url":"https://api.github.com/users/Stebalien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stebalien/subscriptions","organizations_url":"https://api.github.com/users/Stebalien/orgs","repos_url":"https://api.github.com/users/Stebalien/repos","events_url":"https://api.github.com/users/Stebalien/events{/privacy}","received_events_url":"https://api.github.com/users/Stebalien/received_events","type":"User","site_admin":false}],"milestone":null,"comments":13,"created_at":"2018-01-04T18:11:47Z","updated_at":"2018-10-02T23:49:42Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/4545","html_url":"https://github.com/ipfs/go-ipfs/pull/4545","diff_url":"https://github.com/ipfs/go-ipfs/pull/4545.diff","patch_url":"https://github.com/ipfs/go-ipfs/pull/4545.patch"},"body":"fixes #4543, may break other things\n\nIMO, this is the best way to do this (for now, until we start manually storing the content type along with the files). I'd rather not guess at all but we can at least avoid guessing by filename."},"comment":{"url":"https://api.github.com/repos/ipfs/go-ipfs/issues/comments/426467580","html_url":"https://github.com/ipfs/go-ipfs/pull/4545#issuecomment-426467580","issue_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/4545","id":426467580,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjQ2NzU4MA==","user":{"login":"Stebalien","id":310393,"node_id":"MDQ6VXNlcjMxMDM5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/310393?v=4","gravatar_id":"","url":"https://api.github.com/users/Stebalien","html_url":"https://github.com/Stebalien","followers_url":"https://api.github.com/users/Stebalien/followers","following_url":"https://api.github.com/users/Stebalien/following{/other_user}","gists_url":"https://api.github.com/users/Stebalien/gists{/gist_id}","starred_url":"https://api.github.com/users/Stebalien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stebalien/subscriptions","organizations_url":"https://api.github.com/users/Stebalien/orgs","repos_url":"https://api.github.com/users/Stebalien/repos","events_url":"https://api.github.com/users/Stebalien/events{/privacy}","received_events_url":"https://api.github.com/users/Stebalien/received_events","type":"User","site_admin":false},"created_at":"2018-10-02T23:49:42Z","updated_at":"2018-10-02T23:49:42Z","author_association":"CONTRIBUTOR","body":"No, I still believe this is the correct solution (for now). I just got distracted.\r\n\r\n@djdv, @kevina when we actually *add* proper MIME-Type support, we can pre-set the content type in `serveFile`. However, I still don't see why we should manually set the content type if we can't do a better job than `http.ServeContent`. All we'll end up doing is duplicating this block of code from `http` which seems like a waste of time and effort.\r\n\r\n```go\r\n// read a chunk to decide between utf-8 text and binary\r\nvar buf [sniffLen]byte\r\nn, _ := io.ReadFull(content, buf[:])\r\nctype = DetectContentType(buf[:n])\r\n_, err := content.Seek(0, io.SeekStart) // rewind to output whole file\r\nif err != nil {\r\n    Error(w, \"seeker can't seek\", StatusInternalServerError)\r\n    return\r\n}\r\nw.Header().Set(\"Content-Type\", ctype)\r\n```"}}
{"actor":{"display_login":"Stebalien"}}