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

Website: 'NEWS' tab causes download #10

Open
njh opened this issue Dec 25, 2015 · 2 comments
Open

Website: 'NEWS' tab causes download #10

njh opened this issue Dec 25, 2015 · 2 comments

Comments

@njh
Copy link
Contributor

njh commented Dec 25, 2015

When I click on the 'NEWS' tab on the check website, in Chrome on Mac OS X, it causes it to download the file instead of viewing it.

Fetching the page with curl shows that the MIME type is 'application/octet-stream'.

$ curl -v 'http://libcheck.github.io/check/NEWS'
*   Trying 185.31.19.133...
* Connected to libcheck.github.io (185.31.19.133) port 80 (#0)
> GET /check/NEWS HTTP/1.1
> Host: libcheck.github.io
> User-Agent: curl/7.44.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: GitHub.com
< Content-Type: application/octet-stream
< Last-Modified: Thu, 24 Dec 2015 22:16:38 GMT
< Access-Control-Allow-Origin: *
< Expires: Fri, 25 Dec 2015 23:53:16 GMT
< Cache-Control: max-age=600
< X-GitHub-Request-Id: B91F1319:2F47:22CE40CE:567DD493
< Content-Length: 20291
< Accept-Ranges: bytes
< Date: Fri, 25 Dec 2015 23:43:16 GMT
< Via: 1.1 varnish
< Age: 0
< Connection: keep-alive
< X-Served-By: cache-lhr6333-LHR
< X-Cache: MISS
< X-Cache-Hits: 0
< X-Timer: S1451086996.058975,VS0,VE197
< Vary: Accept-Encoding
< X-Fastly-Request-ID: b7683b36740a99519ba7343452e15b5ffceae2c4
< 
@brarcher
Copy link
Contributor

Well, that stinks. The same thing happens with the LGPL license, and also on other browsers besides Chrome.

According to this:

http://stackoverflow.com/questions/15951012/can-mime-types-of-github-pages-files-be-configured

it seems that GitHub is unable to determine the mimetype of the files because they do not have an extension, and fall back to application/octet-stream.

I attempted to set the target of the link to open in a new browser tab, hoping that this would convince a browser to not download the file.

http://www.w3schools.com/tags/att_a_target.asp

However, the browser still downloaded the file. Example here:

http://brarcher.github.io/check/

Without adding the extension of these files, I'm not sure of a way to resolve this, as the issue is on GitHub's side.

@ladar
Copy link

ladar commented Aug 27, 2018

I believe there is a way. You can create a .gitattributes file, and then specify which files, like NEWS, etc, are in fact text files, and not binary blobs. See this URL for details on the syntax:

https://github.com/git/git/blob/master/Documentation/gitattributes.txt

I should note that I spent quite a bit of time trying to use the .gitattribtes file to force GitHub into displaying my project README file as Markdown. The attributes were respected when I viewed the individual file, but I never could get it to render the style information on the project page.

That's a long way of saying, your mileage may vary.

jflopezfernandez added a commit to jflopezfernandez/check that referenced this issue Oct 24, 2020
As the related issue documents, GitHub pages cannot
determine the file type of the NEWS or LGPL files because
they do not have a file extension, so the server uses a
default MIME type of application/octet-stream, which
triggers a download, rather than letting the user actually
read the file.

To circumvent this problem, I changed to file links from
relative links to full hyperlinks referencing the GitHub
repository URL instead. The NEWS file is now viewable via
the "raw" view option accessible through GitHub, and the
LGPL file links to the GitHub license file default.

I chose not to simply use the raw view for the license file
since I felt most people looking at that file would
probably not be lawyers, and would therefore benefit from
the summary GitHub displays at the top of the page.

This pull request fixes issue libcheck#10
brarcher added a commit that referenced this issue Oct 25, 2020
…ab-causes-download

Fix GitHub Pages Site Download Bug #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants