Commit 548ed041 authored by Kirill Smelkov's avatar Kirill Smelkov

X

parent 0d0bd209
Pipeline #11 failed with stage
/*
In this file we handle 'git archive' downloads
NOTE
*/
package main
......
// NOTE
package main
import (
......
/*
Handler for raw blob downloads
*/
package main
import (
"net/http"
)
/*
Cache-Control: private
ETag: "4c10677531b44f555ebbdaff24a9b2d6"
X-Content-Type-Options: nosniff
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Type: text/plain; charset=utf-8
*/
func blobPreAuthorizeHandler(handleFunc serviceHandleFunc) serviceHandleFunc {
func (w http.ResponseWriter, r *gitRequest) {
reqCheckDownload, err := http.newRequest("GET", requestBlob.Path /*TODO strip after repo*/ + '/git-upload-pack', nil)
if err != nil {
fail500(w, "GET git-upload-pack")
return
}
requestBlob := r.Request
r.Request = reqCheckDownload
}
}
func handleGetBlobRaw(w http.ResponseWriter, r *gitRequest) {
blobCmd := gitCommand(""/*XXX GL_ID*/, "git", "--git-dir="+r.RepoPath, "cat-file", "blob", ...)
blobStdout, err := blobCmd.StdoutPipe()
if err != nil {
fail500(w, "handleGetBlobRaw", err)
return
}
defer blobStdout.Close()
if err:= blobCmd.Start(); err != nil {
fail500(w, "handleGetBlobRaw", err)
return
}
defer cleanUpProcessGroup(blobCmd) // XXX do we need to cleanup whole group
//setRawHeaders(...)
w.WriteHeader(200) // XXX too early
if _, err := io.Copy(w, blobStdout); err != nil {
logContext("io.Copy", err)
return
}
if err := blobCmd.Wait(); err != nil {
logContext("wait")
return
}
}
......@@ -74,6 +74,7 @@ var gitServices = [...]gitService{
gitService{"GET", regexp.MustCompile(`/repository/archive.tar\z`), repoPreAuthorizeHandler(handleGetArchive)},
gitService{"GET", regexp.MustCompile(`/repository/archive.tar.gz\z`), repoPreAuthorizeHandler(handleGetArchive)},
gitService{"GET", regexp.MustCompile(`/repository/archive.tar.bz2\z`), repoPreAuthorizeHandler(handleGetArchive)},
gitService("GET", regexp.MustCompile(`/raw/.+\z`, blobPreAuthorizeHandler(handleGetRawBlob)},
gitService{"GET", regexp.MustCompile(`/uploads/`), handleSendFile},
// Git LFS
......
......@@ -13,6 +13,7 @@ import (
"os"
)
// NOTE
func handleSendFile(w http.ResponseWriter, r *gitRequest) {
upRequest, err := r.u.newUpstreamRequest(r.Request, r.Body, "")
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment