otac0n / WebGitNet

WebGit .NET is an ASP.NET MVC app that provides access to your git repositories over HTTP. It supports browsing in a web browser AND push / pull over Git's "Smart HTTP protocol".
zlib License
132 stars 62 forks source link

Powershell files served as binary #72

Open seankearon opened 11 years ago

seankearon commented 11 years ago

Powershell scripts are served up as application/octet-stream. Is there a way to serve these up as text? (I've already tried adding a MIME type in IIS.)

otac0n commented 11 years ago

The current implementation first checks a file, called "mime-types.txt", located in the sharedlib project.

If it fails to find the file extension in that file, it searches the windows registry for the mime type.

See: https://github.com/otac0n/WebGitNet/blob/master/WebGitNet.SharedLib/MimeUtilities.cs

You can add a value HKEY_CLASSES_ROOT\.ps1\ContentType set to something like text/x-powershell-source on your server, or you can modify that mime-types.txt file.

I'm going to keep this bug open until we have an entry in mime-types.txt for powershell.

seankearon commented 11 years ago

That does the job - many thanks!

otac0n commented 11 years ago

There are several examples of this issue:

.cmd, .nsi, .ls, .bxrc

The point is that it is an insurmountable challenge to build an exhaustive list. We should default to the git method of detecting a binary vs text file. Specifically, we should check the first chunk (1kb?) of the file for any null bytes. This is slightly problematic when dealing with multibyte encodings.