Commit 5be33684 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 238e32b9
...@@ -135,10 +135,10 @@ func verifyDownloadAccess(w http.ResponseWriter, u *upstream, project string) (A ...@@ -135,10 +135,10 @@ func verifyDownloadAccess(w http.ResponseWriter, u *upstream, project string) (A
auth, ok := authCache[project] auth, ok := authCache[project]
if ok { if ok {
auth.Nhit++ auth.Nhit++
log.Printf("authReply for %v cached ago: %v (hits: %v)", //log.Printf("authReply for %v cached ago: %v (hits: %v)",
project, // project,
time.Since(time.Unix(auth.Tauth, 0)), // time.Since(time.Unix(auth.Tauth, 0)),
auth.Nhit) // auth.Nhit)
return auth.AuthReply, nil return auth.AuthReply, nil
} }
...@@ -246,7 +246,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) { ...@@ -246,7 +246,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) {
for i := len(refpathv); i > 0; i-- { for i := len(refpathv); i > 0; i-- {
ref := strings.Join(refpathv[:i], "/") ref := strings.Join(refpathv[:i], "/")
path := strings.Join(refpathv[i:], "/") path := strings.Join(refpathv[i:], "/")
log.Printf("Trying %v %v", ref, path) //log.Printf("Trying %v %v", ref, path)
_, err := fmt.Fprintf(queryStdin, "%s:%s\n", ref, path) _, err := fmt.Fprintf(queryStdin, "%s:%s\n", ref, path)
if err != nil { if err != nil {
fail500(w, "git cat-file --batch; write", err) fail500(w, "git cat-file --batch; write", err)
...@@ -259,7 +259,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) { ...@@ -259,7 +259,7 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) {
return return
} }
log.Printf("<- %s", reply) //log.Printf("<- %s", reply)
// <object> SP missing LF // <object> SP missing LF
if strings.HasSuffix(reply, " missing\n") { if strings.HasSuffix(reply, " missing\n") {
...@@ -290,6 +290,15 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) { ...@@ -290,6 +290,15 @@ func emitBlob(w http.ResponseWriter, repopath string, refpath string) {
} }
// Blob found - start writing response // Blob found - start writing response
w.Header().Set("Content-Disposition", "inline")
w.Header().Set("Content-Transfer-Encoding", "binary")
w.Header().Set("Content-Length", fmt.Sprintf("%d", size))
w.Header().Set("X-Content-Type-Options", "nosniff")
//w.Header().Set("Content-Type", "...") TODO image/jpeg...
w.Header().Set("Cache-Control", "private") // Rails sets this for IE compatibility
w.Header().Set("ETag", fmt.Sprintf(`"%s"`, sha1))
//setRawHeaders(...) // TODO //setRawHeaders(...) // TODO
w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just return w.WriteHeader(200) // Don't bother with HTTP 500 from this point on, just return
// XXX better use queryStdout instead of queryReader, but we could be // XXX better use queryStdout instead of queryReader, but we could be
......
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