Commit a79e5928 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d9899658
/*
In this file we handle 'git archive' downloads
NOTE
*/
package main
......
// NOTE
package main
import (
"encoding/json"
"errors"
"io"
"log"
"net/http"
"strings"
)
func preAuthorizeHandler(handleFunc serviceHandleFunc, suffix string) serviceHandleFunc {
return func(w http.ResponseWriter, r *gitRequest) {
//Tstart := time.Now()
//log.Printf("AUTH1")
authReq, err := r.u.newUpstreamRequest(r.Request, nil, suffix)
if err != nil {
fail500(w, "newUpstreamRequest", err)
......@@ -65,19 +61,12 @@ func preAuthorizeHandler(handleFunc serviceHandleFunc, suffix string) serviceHan
}
}
//Tendauth := time.Now()
handleFunc(w, r)
//Tend := time.Now()
//log.Printf("Tauth:\t%s", Tendauth.Sub(Tstart))
//log.Printf("Tauth+handle:\t%s", Tend.Sub(Tstart))
}
}
func repoPreAuthorizeHandler(handleFunc serviceHandleFunc) serviceHandleFunc {
return preAuthorizeHandler(func(w http.ResponseWriter, r *gitRequest) {
log.Printf("AUTH2")
if r.RepoPath == "" {
fail500(w, "repoPreAuthorizeHandler", errors.New("missing authorization response"))
return
......
......@@ -7,14 +7,12 @@ package main
import (
"fmt"
"io"
"log"
"net/http"
"path/filepath"
"strings"
)
func handleGetInfoRefs(w http.ResponseWriter, r *gitRequest) {
log.Printf("HELLO WORLD")
rpc := r.URL.Query().Get("service")
if !(rpc == "git-upload-pack" || rpc == "git-receive-pack") {
// The 'dumb' Git HTTP protocol is not supported
......
......@@ -66,6 +66,7 @@ type gitRequest struct {
// Routing table
var gitServices = [...]gitService{
gitService{"GET", regexp.MustCompile(`/raw/.+\z`), handleGetBlobRaw},
gitService{"GET", regexp.MustCompile(`/info/refs\z`), repoPreAuthorizeHandler(handleGetInfoRefs)},
gitService{"POST", regexp.MustCompile(`/git-upload-pack\z`), repoPreAuthorizeHandler(contentEncodingHandler(handlePostRPC))},
gitService{"POST", regexp.MustCompile(`/git-receive-pack\z`), repoPreAuthorizeHandler(contentEncodingHandler(handlePostRPC))},
......@@ -74,7 +75,6 @@ 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`), handleGetBlobRaw},
gitService{"GET", regexp.MustCompile(`/uploads/`), handleSendFile},
// Git LFS
......
......@@ -13,7 +13,6 @@ 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