|
@@ -62,7 +62,7 @@ func HTTPContexter() macaron.Handler {
|
|
|
|
|
|
isPull := c.Query("service") == "git-upload-pack" ||
|
|
|
strings.HasSuffix(c.Req.URL.Path, "git-upload-pack") ||
|
|
|
- c.Req.Method == "GET" || c.Req.Method == "HEAD"
|
|
|
+ c.Req.Method == "GET"
|
|
|
|
|
|
owner, err := db.GetUserByName(ownerName)
|
|
|
if err != nil {
|
|
@@ -325,11 +325,6 @@ func getTextFile(h serviceHandler) {
|
|
|
h.sendFile("text/plain")
|
|
|
}
|
|
|
|
|
|
-func getBinaryFile(h serviceHandler) {
|
|
|
- h.setHeaderNoCache()
|
|
|
- h.sendFile("application/octet-stream")
|
|
|
-}
|
|
|
-
|
|
|
func getInfoPacks(h serviceHandler) {
|
|
|
h.setHeaderCacheForever()
|
|
|
h.sendFile("text/plain; charset=utf-8")
|
|
@@ -366,12 +361,6 @@ var routes = []struct {
|
|
|
{regexp.MustCompile("(.*?)/objects/[0-9a-f]{2}/[0-9a-f]{38}$"), "GET", getLooseObject},
|
|
|
{regexp.MustCompile("(.*?)/objects/pack/pack-[0-9a-f]{40}\\.pack$"), "GET", getPackFile},
|
|
|
{regexp.MustCompile("(.*?)/objects/pack/pack-[0-9a-f]{40}\\.idx$"), "GET", getIdxFile},
|
|
|
- // files neeeded for git-annex access to the repository over http
|
|
|
- {regexp.MustCompile("(.*?)/config$"), "GET", getTextFile},
|
|
|
- // TODO: we probably just need to provide some getBinaryFile
|
|
|
- // Note: code below treats HEAD (used by git annex drop to sense presence)
|
|
|
- // as "GET" for the purpose of allowing or not the route
|
|
|
- {regexp.MustCompile("(.*?)/annex/objects/.*/.*-s[0-9]*--.*"), "GET", getBinaryFile},
|
|
|
}
|
|
|
|
|
|
func getGitRepoPath(dir string) (string, error) {
|
|
@@ -388,14 +377,8 @@ func getGitRepoPath(dir string) (string, error) {
|
|
|
}
|
|
|
|
|
|
func HTTP(c *HTTPContext) {
|
|
|
- var reqPath string
|
|
|
for _, route := range routes {
|
|
|
- // Annex keys are case sensitive, so they must not be lower cased
|
|
|
- if strings.Contains(c.Req.URL.Path, "/annex/objects/") {
|
|
|
- reqPath = c.Req.URL.Path
|
|
|
- } else {
|
|
|
- reqPath = strings.ToLower(c.Req.URL.Path)
|
|
|
- }
|
|
|
+ reqPath := strings.ToLower(c.Req.URL.Path)
|
|
|
m := route.reg.FindStringSubmatch(reqPath)
|
|
|
if m == nil {
|
|
|
continue
|
|
@@ -409,10 +392,7 @@ func HTTP(c *HTTPContext) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- req_method := c.Req.Method
|
|
|
- // Treat HEAD (used by e.g. git annex drop) as GET
|
|
|
- if req_method == "HEAD" { req_method = "GET" }
|
|
|
- if route.method != req_method {
|
|
|
+ if route.method != c.Req.Method {
|
|
|
c.NotFound()
|
|
|
return
|
|
|
}
|