Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yysun committed Apr 22, 2011
2 parents 9c40421 + 9c68bad commit 39d760f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions GitTools/GitHandler.cs
Expand Up @@ -88,9 +88,9 @@ private bool HasAccess()
{
var authMode = ConfigurationManager.AppSettings["GitAuthenticationMode"];

if (string.Compare(authMode, "none", true)==0) return true;
if (string.Compare(authMode, "all")==0 || context.Request.RawUrl.IndexOf("git-receive-pack") >= 0)
if (string.IsNullOrEmpty(authMode) || authMode.Equals("none")) return true;

if (authMode.Equals("all") || context.Request.RawUrl.IndexOf("git-receive-pack") >= 0)
{
string authHeader = context.Request.Headers["Authorization"];

Expand Down Expand Up @@ -138,11 +138,20 @@ private void ServiceRpc(string serviceName)

using (var file = File.Create(fin))
{
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = context.Request.InputStream.Read(buffer, 0, buffer.Length)) != 0)
var encoding = context.Request.Headers["Content-Encoding"];
if (string.IsNullOrEmpty(encoding))
encoding = context.Request.ContentEncoding.EncodingName;

if (encoding.Equals("gzip"))
{
using (GZipStream decomp = new GZipStream(context.Request.InputStream, CompressionMode.Decompress))
{
decomp.CopyTo(file);
}
}
else
{
file.Write(buffer, 0, bytesRead);
context.Request.InputStream.CopyTo(file);
}
}

Expand Down

0 comments on commit 39d760f

Please sign in to comment.