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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
0c1e9930
Commit
0c1e9930
authored
Sep 01, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use accelerated uploads for users/personal snippets
parent
33a5eb7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
internal/upstream/routes.go
internal/upstream/routes.go
+8
-4
upload_test.go
upload_test.go
+10
-12
No files found.
internal/upstream/routes.go
View file @
0c1e9930
...
@@ -44,10 +44,12 @@ type routeOptions struct {
...
@@ -44,10 +44,12 @@ type routeOptions struct {
}
}
const
(
const
(
apiPattern
=
`^/api/`
apiPattern
=
`^/api/`
ciAPIPattern
=
`^/ci/api/`
ciAPIPattern
=
`^/ci/api/`
gitProjectPattern
=
`^/([^/]+/){1,}[^/]+\.git/`
gitProjectPattern
=
`^/([^/]+/){1,}[^/]+\.git/`
projectPattern
=
`^/([^/]+/){1,}[^/]+/`
projectPattern
=
`^/([^/]+/){1,}[^/]+/`
snippetUploadPattern
=
`^/uploads/personal_snippet`
userUploadPattern
=
`^/uploads/user`
)
)
func
compileRegexp
(
regexpStr
string
)
*
regexp
.
Regexp
{
func
compileRegexp
(
regexpStr
string
)
*
regexp
.
Regexp
{
...
@@ -217,6 +219,8 @@ func (u *upstream) configureRoutes() {
...
@@ -217,6 +219,8 @@ func (u *upstream) configureRoutes() {
// Uploads
// Uploads
route
(
"POST"
,
projectPattern
+
`uploads\z`
,
upload
.
Accelerate
(
api
,
proxy
)),
route
(
"POST"
,
projectPattern
+
`uploads\z`
,
upload
.
Accelerate
(
api
,
proxy
)),
route
(
"POST"
,
snippetUploadPattern
,
upload
.
Accelerate
(
api
,
proxy
)),
route
(
"POST"
,
userUploadPattern
,
upload
.
Accelerate
(
api
,
proxy
)),
// For legacy reasons, user uploads are stored under the document root.
// For legacy reasons, user uploads are stored under the document root.
// To prevent anybody who knows/guesses the URL of a user-uploaded file
// To prevent anybody who knows/guesses the URL of a user-uploaded file
...
...
upload_test.go
View file @
0c1e9930
...
@@ -102,10 +102,6 @@ func parseJWT(token *jwt.Token) (interface{}, error) {
...
@@ -102,10 +102,6 @@ func parseJWT(token *jwt.Token) (interface{}, error) {
}
}
func
TestAcceleratedUpload
(
t
*
testing
.
T
)
{
func
TestAcceleratedUpload
(
t
*
testing
.
T
)
{
reqBody
,
contentType
,
err
:=
multipartBodyWithFile
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
ts
:=
uploadTestServer
(
t
,
func
(
r
*
http
.
Request
)
{
ts
:=
uploadTestServer
(
t
,
func
(
r
*
http
.
Request
)
{
jwtToken
,
err
:=
jwt
.
Parse
(
r
.
Header
.
Get
(
upload
.
RewrittenFieldsHeader
),
parseJWT
)
jwtToken
,
err
:=
jwt
.
Parse
(
r
.
Header
.
Get
(
upload
.
RewrittenFieldsHeader
),
parseJWT
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -120,14 +116,16 @@ func TestAcceleratedUpload(t *testing.T) {
...
@@ -120,14 +116,16 @@ func TestAcceleratedUpload(t *testing.T) {
ws
:=
startWorkhorseServer
(
ts
.
URL
)
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
defer
ws
.
Close
()
resource
:=
`/example`
resources
:=
[]
string
{
`/example`
,
`/uploads/personal_snippet`
,
`/uploads/user`
}
resp
,
err
:=
http
.
Post
(
ws
.
URL
+
resource
,
contentType
,
reqBody
)
for
_
,
resource
:=
range
resources
{
if
err
!=
nil
{
reqBody
,
contentType
,
err
:=
multipartBodyWithFile
()
t
.
Error
(
err
)
require
.
NoError
(
t
,
err
)
}
defer
resp
.
Body
.
Close
()
resp
,
err
:=
http
.
Post
(
ws
.
URL
+
resource
,
contentType
,
reqBody
)
if
resp
.
StatusCode
!=
200
{
require
.
NoError
(
t
,
err
)
t
.
Errorf
(
"GET %q: expected 200, got %d"
,
resource
,
resp
.
StatusCode
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
)
resp
.
Body
.
Close
()
}
}
}
}
...
...
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