Commit 9ed9b81e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9dedc0ce
...@@ -60,7 +60,7 @@ type AuthCacheKey struct { ...@@ -60,7 +60,7 @@ type AuthCacheKey struct {
// Authorization reply cache // Authorization reply cache
// {} AuthCacheKey -> *AuthCacheEntry // {} AuthCacheKey -> *AuthCacheEntry
type AuthCache struct { type AuthCache struct {
u *upstream // for which upstream we cache auth u *upstream // for which upstream we cache auth
mu sync.RWMutex // guards .cached mu sync.RWMutex // guards .cached
cached map[AuthCacheKey]*AuthCacheEntry cached map[AuthCacheKey]*AuthCacheEntry
...@@ -174,7 +174,7 @@ func (c *AuthCache) askAuthBackend(key AuthCacheKey) AuthReply { ...@@ -174,7 +174,7 @@ func (c *AuthCache) askAuthBackend(key AuthCacheKey) AuthReply {
panic(err) panic(err)
} }
header := make(http.Header) header := make(http.Header)
for k,v := range hv { for k, v := range hv {
header[k] = v header[k] = v
} }
...@@ -194,17 +194,17 @@ func askAuthBackend(u *upstream, project, query string, header *http.Header) Aut ...@@ -194,17 +194,17 @@ func askAuthBackend(u *upstream, project, query string, header *http.Header) Aut
// side this supports only basic auth, not private token. // side this supports only basic auth, not private token.
// - that's why we auth backend to authenticate as if it was request to // - that's why we auth backend to authenticate as if it was request to
// get repo archive and propagate request query and header. // get repo archive and propagate request query and header.
// url := project+".git/info/refs?service=git-upload-pack" // url := project + ".git/info/refs?service=git-upload-pack"
url := project+"/repository/archive.zip" url := project + "/repository/archive.zip"
if query != "" { if query != "" {
url += "?"+query url += "?" + query
} }
reqDownloadAccess, err := http.NewRequest("GET", url, nil) reqDownloadAccess, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
fail500(authReply.RawReply, fmt.Errorf("GET git-upload-pack: %v", err)) fail500(authReply.RawReply, fmt.Errorf("GET git-upload-pack: %v", err))
return authReply return authReply
} }
for k,v := range *header { for k, v := range *header {
reqDownloadAccess.Header[k] = v reqDownloadAccess.Header[k] = v
} }
......
...@@ -466,7 +466,7 @@ func download(t *testing.T, url string, h http.Header) (*http.Response, []byte) ...@@ -466,7 +466,7 @@ func download(t *testing.T, url string, h http.Header) (*http.Response, []byte)
t.Fatal(err) t.Fatal(err)
} }
// copy header to request // copy header to request
for k,v := range h { for k, v := range h {
req.Header[k] = v req.Header[k] = v
} }
client := &http.Client{} client := &http.Client{}
...@@ -484,9 +484,9 @@ func download(t *testing.T, url string, h http.Header) (*http.Response, []byte) ...@@ -484,9 +484,9 @@ func download(t *testing.T, url string, h http.Header) (*http.Response, []byte)
// Context for downloading & verifying paths under URL prefix // Context for downloading & verifying paths under URL prefix
type DownloadContext struct { type DownloadContext struct {
t *testing.T t *testing.T
urlPrefix string urlPrefix string
Header http.Header Header http.Header
} }
func DownloadContextNew(t *testing.T, urlPrefix string) *DownloadContext { func DownloadContextNew(t *testing.T, urlPrefix string) *DownloadContext {
...@@ -495,7 +495,7 @@ func DownloadContextNew(t *testing.T, urlPrefix string) *DownloadContext { ...@@ -495,7 +495,7 @@ func DownloadContextNew(t *testing.T, urlPrefix string) *DownloadContext {
} }
func (dl DownloadContext) downloadRaw(path string) (*http.Response, []byte) { func (dl DownloadContext) downloadRaw(path string) (*http.Response, []byte) {
return download(dl.t, dl.urlPrefix + path, dl.Header) return download(dl.t, dl.urlPrefix+path, dl.Header)
} }
// download `path` and expect content sha1 to be `expectSha1` // download `path` and expect content sha1 to be `expectSha1`
......
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