Ejemplo n.º 1
0
        public override void ExecuteResult(ControllerContext context)
        {
            var response = context.HttpContext.Response;
            var request  = context.HttpContext.Request;

            response.ContentType = this.contentType;
            response.AddHeader("Content-disposition", "attachment");
            response.Buffer       = false;
            response.BufferOutput = false;

            using (var git = GitUtilities.StartGetBlob(this.repoPath, this.tree, this.path))
            {
                var writeBuffer = new char[4194304];
                int writeCount;
                while ((writeCount = git.StandardOutput.ReadBlock(writeBuffer, 0, writeBuffer.Length)) > 0)
                {
                    var bytes = GitUtilities.DefaultEncoding.GetBytes(writeBuffer, 0, writeCount);
                    response.BinaryWrite(bytes);
                }

                git.WaitForExit();
            }
        }