aboutsummaryrefslogtreecommitdiffstats
path: root/routers/repo/http.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-06-27 23:12:55 -0400
committerUnknown <joe2010xtmf@163.com>2014-06-27 23:12:55 -0400
commit57ac15aa20a24583cf0799fd46d2c36816d28692 (patch)
treed11be8f47c00a712fda17b879c6faf810234ce52 /routers/repo/http.go
parent1d55ecd29ce261cd3adf78649a44aaa30e4fd468 (diff)
parent7dbeee94e3ebec0a91efa6cba613e30fd387ffb4 (diff)
downloadgitea-57ac15aa20a24583cf0799fd46d2c36816d28692.tar.gz
gitea-57ac15aa20a24583cf0799fd46d2c36816d28692.zip
Merge branch 'master' of github.com:gogits/gogs into dev
Diffstat (limited to 'routers/repo/http.go')
-rw-r--r--routers/repo/http.go28
1 files changed, 7 insertions, 21 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 981266d548..7b89e9b05a 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -7,7 +7,6 @@ package repo
import (
"bytes"
"fmt"
- "io"
"io/ioutil"
"net/http"
"os"
@@ -193,7 +192,6 @@ var routes = []route{
// Request handling function
func HttpBackend(config *Config) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- //log.GitLogger.Printf("%s %s %s %s", r.RemoteAddr, r.Method, r.URL.Path, r.Proto)
for _, route := range routes {
if m := route.cr.FindStringSubmatch(r.URL.Path); m != nil {
if route.method != r.Method {
@@ -215,13 +213,13 @@ func HttpBackend(config *Config) http.HandlerFunc {
return
}
}
+
renderNotFound(w)
return
}
}
// Actual command handling functions
-
func serviceUploadPack(hr handler) {
serviceRpc("upload-pack", hr)
}
@@ -239,36 +237,24 @@ func serviceRpc(rpc string, hr handler) {
return
}
- input, _ := ioutil.ReadAll(r.Body)
-
w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", rpc))
w.WriteHeader(http.StatusOK)
+ input, _ := ioutil.ReadAll(r.Body)
+ br := bytes.NewReader(input)
+
args := []string{rpc, "--stateless-rpc", dir}
cmd := exec.Command(hr.Config.GitBinPath, args...)
cmd.Dir = dir
- in, err := cmd.StdinPipe()
- if err != nil {
- log.GitLogger.Error(err.Error())
- return
- }
-
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- log.GitLogger.Error(err.Error())
- return
- }
+ cmd.Stdout = w
+ cmd.Stdin = br
- err = cmd.Start()
+ err := cmd.Run()
if err != nil {
log.GitLogger.Error(err.Error())
return
}
- in.Write(input)
- io.Copy(w, stdout)
- cmd.Wait()
-
if hr.Config.OnSucceed != nil {
hr.Config.OnSucceed(rpc, input)
}