зеркало из https://github.com/golang/build.git
vcs-test/vcweb: fix various extraction issues for serving modules with authentication
• The /auth subdirectory wasn't downloading content from GCS. • The zip extraction logic was failing for zip files that do not contain explicit directory entries. • The invocation of http.FileServer wasn't trimming the /auth prefix, so rejections would work correctly but successful authentication would return 404s instead of serving the file. Updates golang/go#26232 Change-Id: I3a72d7dfca62435c53f4bc7efaebae3900f2c175 Reviewed-on: https://go-review.googlesource.com/c/build/+/170880 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
Родитель
d6a8c27467
Коммит
00823ba386
|
@ -113,5 +113,5 @@ func (h *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
http.FileServer(h.dir).ServeHTTP(w, r)
|
http.StripPrefix("/auth/", http.FileServer(h.dir)).ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -119,10 +118,11 @@ func loadFS(dir1, dir2 string, force bool) {
|
||||||
check(os.MkdirAll(tmp, 0777))
|
check(os.MkdirAll(tmp, 0777))
|
||||||
|
|
||||||
for _, f := range zr.File {
|
for _, f := range zr.File {
|
||||||
if strings.HasSuffix(f.Name, "/") {
|
if f.FileInfo().IsDir() {
|
||||||
check(os.MkdirAll(filepath.Join(tmp, f.Name), 0777))
|
check(os.MkdirAll(filepath.Join(tmp, f.Name), 0777))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
check(os.MkdirAll(filepath.Join(tmp, filepath.Dir(f.Name)), 0777))
|
||||||
w, err := os.Create(filepath.Join(tmp, f.Name))
|
w, err := os.Create(filepath.Join(tmp, f.Name))
|
||||||
check(err)
|
check(err)
|
||||||
r, err := f.Open()
|
r, err := f.Open()
|
||||||
|
|
|
@ -42,6 +42,7 @@ func usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var isLoadDir = map[string]bool{
|
var isLoadDir = map[string]bool{
|
||||||
|
"auth": true,
|
||||||
"go": true,
|
"go": true,
|
||||||
"git": true,
|
"git": true,
|
||||||
"hg": true,
|
"hg": true,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче