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
548ed041
Commit
548ed041
authored
Nov 25, 2015
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X
parent
0d0bd209
Pipeline
#11
failed with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
0 deletions
+65
-0
archive.go
archive.go
+1
-0
authorization.go
authorization.go
+1
-0
blob.go
blob.go
+61
-0
upstream.go
upstream.go
+1
-0
xsendfile.go
xsendfile.go
+1
-0
No files found.
archive.go
View file @
548ed041
/*
In this file we handle 'git archive' downloads
NOTE
*/
package
main
...
...
authorization.go
View file @
548ed041
// NOTE
package
main
import
(
...
...
blob.go
0 → 100644
View file @
548ed041
/*
Handler for raw blob downloads
*/
package
main
import
(
"net/http"
)
/*
Cache-Control: private
ETag: "4c10677531b44f555ebbdaff24a9b2d6"
X-Content-Type-Options: nosniff
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Type: text/plain; charset=utf-8
*/
func
blobPreAuthorizeHandler
(
handleFunc
serviceHandleFunc
)
serviceHandleFunc
{
func
(
w
http
.
ResponseWriter
,
r
*
gitRequest
)
{
reqCheckDownload
,
err
:=
http
.
newRequest
(
"GET"
,
requestBlob
.
Path
/*TODO strip after repo*/
+
'
/
git
-
upload
-
pack
'
,
nil
)
if
err
!=
nil
{
fail500
(
w
,
"GET git-upload-pack"
)
return
}
requestBlob
:=
r
.
Request
r
.
Request
=
reqCheckDownload
}
}
func
handleGetBlobRaw
(
w
http
.
ResponseWriter
,
r
*
gitRequest
)
{
blobCmd
:=
gitCommand
(
""
/*XXX GL_ID*/
,
"git"
,
"--git-dir="
+
r
.
RepoPath
,
"cat-file"
,
"blob"
,
...
)
blobStdout
,
err
:=
blobCmd
.
StdoutPipe
()
if
err
!=
nil
{
fail500
(
w
,
"handleGetBlobRaw"
,
err
)
return
}
defer
blobStdout
.
Close
()
if
err
:=
blobCmd
.
Start
();
err
!=
nil
{
fail500
(
w
,
"handleGetBlobRaw"
,
err
)
return
}
defer
cleanUpProcessGroup
(
blobCmd
)
// XXX do we need to cleanup whole group
//setRawHeaders(...)
w
.
WriteHeader
(
200
)
// XXX too early
if
_
,
err
:=
io
.
Copy
(
w
,
blobStdout
);
err
!=
nil
{
logContext
(
"io.Copy"
,
err
)
return
}
if
err
:=
blobCmd
.
Wait
();
err
!=
nil
{
logContext
(
"wait"
)
return
}
}
upstream.go
View file @
548ed041
...
...
@@ -74,6 +74,7 @@ var gitServices = [...]gitService{
gitService
{
"GET"
,
regexp
.
MustCompile
(
`/repository/archive.tar\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
gitService
{
"GET"
,
regexp
.
MustCompile
(
`/repository/archive.tar.gz\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
gitService
{
"GET"
,
regexp
.
MustCompile
(
`/repository/archive.tar.bz2\z`
),
repoPreAuthorizeHandler
(
handleGetArchive
)},
gitService
(
"GET"
,
regexp
.
MustCompile
(
`/raw/.+\z`
,
blobPreAuthorizeHandler
(
handleGetRawBlob
)},
gitService
{
"GET"
,
regexp
.
MustCompile
(
`/uploads/`
),
handleSendFile
},
// Git LFS
...
...
xsendfile.go
View file @
548ed041
...
...
@@ -13,6 +13,7 @@ import (
"os"
)
// NOTE
func
handleSendFile
(
w
http
.
ResponseWriter
,
r
*
gitRequest
)
{
upRequest
,
err
:=
r
.
u
.
newUpstreamRequest
(
r
.
Request
,
r
.
Body
,
""
)
if
err
!=
nil
{
...
...
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