Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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-ce
Commits
de73d152
Commit
de73d152
authored
Feb 09, 2022
by
Jacob Vosmaer
Committed by
Patrick Bajao
Feb 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workhorse: rename HandleFileUploads to InterceptMultipartFiles
parent
2c63e7c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
workhorse/internal/artifacts/artifacts_upload.go
workhorse/internal/artifacts/artifacts_upload.go
+1
-1
workhorse/internal/upload/accelerate.go
workhorse/internal/upload/accelerate.go
+1
-1
workhorse/internal/upload/uploads.go
workhorse/internal/upload/uploads.go
+1
-1
workhorse/internal/upload/uploads_test.go
workhorse/internal/upload/uploads_test.go
+9
-9
No files found.
workhorse/internal/artifacts/artifacts_upload.go
View file @
de73d152
...
...
@@ -162,6 +162,6 @@ func UploadArtifacts(myAPI *api.API, h http.Handler, p upload.Preparer) http.Han
format
:=
r
.
URL
.
Query
()
.
Get
(
ArtifactFormatKey
)
mg
:=
&
artifactsUploadProcessor
{
opts
:
opts
,
format
:
format
,
SavedFileTracker
:
upload
.
SavedFileTracker
{
Request
:
r
}}
upload
.
HandleFileUpload
s
(
w
,
r
,
h
,
a
,
mg
,
opts
)
upload
.
InterceptMultipartFile
s
(
w
,
r
,
h
,
a
,
mg
,
opts
)
},
"/authorize"
)
}
workhorse/internal/upload/accelerate.go
View file @
de73d152
...
...
@@ -27,6 +27,6 @@ func Accelerate(rails PreAuthorizer, h http.Handler, p Preparer) http.Handler {
return
}
HandleFileUpload
s
(
w
,
r
,
h
,
a
,
s
,
opts
)
InterceptMultipartFile
s
(
w
,
r
,
h
,
a
,
s
,
opts
)
},
"/authorize"
)
}
workhorse/internal/upload/uploads.go
View file @
de73d152
...
...
@@ -24,7 +24,7 @@ type MultipartFormProcessor interface {
Count
()
int
}
func
HandleFileUpload
s
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
h
http
.
Handler
,
preauth
*
api
.
Response
,
filter
MultipartFormProcessor
,
opts
*
filestore
.
SaveFileOpts
)
{
func
InterceptMultipartFile
s
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
h
http
.
Handler
,
preauth
*
api
.
Response
,
filter
MultipartFormProcessor
,
opts
*
filestore
.
SaveFileOpts
)
{
var
body
bytes
.
Buffer
writer
:=
multipart
.
NewWriter
(
&
body
)
defer
writer
.
Close
()
...
...
workhorse/internal/upload/uploads_test.go
View file @
de73d152
...
...
@@ -78,7 +78,7 @@ func TestUploadHandlerForwardingRawData(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
nil
,
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
nil
,
opts
)
require
.
Equal
(
t
,
202
,
response
.
Code
)
require
.
Equal
(
t
,
"RESPONSE"
,
response
.
Body
.
String
(),
"response body"
)
...
...
@@ -149,7 +149,7 @@ func TestUploadHandlerRewritingMultiPartData(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
require
.
Equal
(
t
,
202
,
response
.
Code
)
cancel
()
// this will trigger an async cleanup
...
...
@@ -218,7 +218,7 @@ func TestUploadHandlerDetectingInjectedMultiPartData(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
require
.
Equal
(
t
,
test
.
response
,
response
.
Code
)
cancel
()
// this will trigger an async cleanup
...
...
@@ -248,7 +248,7 @@ func TestUploadProcessingField(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
require
.
Equal
(
t
,
500
,
response
.
Code
)
}
...
...
@@ -279,7 +279,7 @@ func TestUploadingMultipleFiles(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
require
.
Equal
(
t
,
400
,
response
.
Code
)
require
.
Equal
(
t
,
"upload request contains more than 10 files
\n
"
,
response
.
Body
.
String
())
...
...
@@ -335,7 +335,7 @@ func TestUploadProcessingFile(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
require
.
Equal
(
t
,
200
,
response
.
Code
)
})
...
...
@@ -381,7 +381,7 @@ func TestInvalidFileNames(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
SavedFileTracker
{
Request
:
httpRequest
},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
nilHandler
,
apiResponse
,
&
SavedFileTracker
{
Request
:
httpRequest
},
opts
)
require
.
Equal
(
t
,
testCase
.
code
,
response
.
Code
)
require
.
Equal
(
t
,
testCase
.
expectedPrefix
,
opts
.
TempFilePrefix
)
}
...
...
@@ -447,7 +447,7 @@ func TestContentDispositionRewrite(t *testing.T) {
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
customHandler
,
apiResponse
,
&
SavedFileTracker
{
Request
:
httpRequest
},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
customHandler
,
apiResponse
,
&
SavedFileTracker
{
Request
:
httpRequest
},
opts
)
upstreamRequest
,
err
:=
http
.
ReadRequest
(
bufio
.
NewReader
(
&
upstreamRequestBuffer
))
require
.
NoError
(
t
,
err
)
...
...
@@ -570,7 +570,7 @@ func runUploadTest(t *testing.T, image []byte, filename string, httpCode int, ts
opts
,
_
,
err
:=
preparer
.
Prepare
(
apiResponse
)
require
.
NoError
(
t
,
err
)
HandleFileUpload
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
InterceptMultipartFile
s
(
response
,
httpRequest
,
handler
,
apiResponse
,
&
testFormProcessor
{},
opts
)
require
.
Equal
(
t
,
httpCode
,
response
.
Code
)
}
...
...
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