Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
9ed9b81e
Commit
9ed9b81e
authored
Dec 09, 2015
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9dedc0ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
blob.go
blob.go
+6
-6
main_test.go
main_test.go
+4
-4
No files found.
blob.go
View file @
9ed9b81e
...
@@ -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
}
}
...
...
main_test.go
View file @
9ed9b81e
...
@@ -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`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment