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
e783a3d0
Commit
e783a3d0
authored
Dec 17, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up handling of the Temp-Path header
parent
b4037dcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
artifacts.go
artifacts.go
+1
-1
uploads.go
uploads.go
+4
-1
uploads_test.go
uploads_test.go
+2
-2
No files found.
artifacts.go
View file @
e783a3d0
...
...
@@ -7,7 +7,7 @@ import (
func
(
u
*
upstream
)
artifactsAuthorizeHandler
(
h
handleFunc
)
handleFunc
{
return
u
.
preAuthorizeHandler
(
func
(
w
http
.
ResponseWriter
,
r
*
gitRequest
)
{
req
:=
r
.
Request
req
.
Header
.
Set
(
"Gitlab-Workhorse-Temp-Path"
,
r
.
TempPath
)
req
.
Header
.
Set
(
tempPathHeader
,
r
.
TempPath
)
h
(
w
,
req
)
},
"/authorize"
)
}
uploads.go
View file @
e783a3d0
...
...
@@ -11,6 +11,8 @@ import (
"os"
)
const
tempPathHeader
=
"Gitlab-Workhorse-Temp-Path"
func
rewriteFormFilesFromMultipart
(
r
*
http
.
Request
,
writer
*
multipart
.
Writer
,
tempPath
string
)
(
cleanup
func
(),
err
error
)
{
// Create multipart reader
reader
,
err
:=
r
.
MultipartReader
()
...
...
@@ -84,11 +86,12 @@ func rewriteFormFilesFromMultipart(r *http.Request, writer *multipart.Writer, te
}
func
(
u
*
upstream
)
handleFileUploads
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
tempPath
:=
r
.
Header
.
Get
(
"Gitlab-Workhorse-Temp-Path"
)
tempPath
:=
r
.
Header
.
Get
(
tempPathHeader
)
if
tempPath
==
""
{
fail500
(
w
,
errors
.
New
(
"handleFileUploads: TempPath empty"
))
return
}
r
.
Header
.
Del
(
tempPathHeader
)
var
body
bytes
.
Buffer
writer
:=
multipart
.
NewWriter
(
&
body
)
...
...
uploads_test.go
View file @
e783a3d0
...
...
@@ -50,7 +50,7 @@ func TestUploadHandlerForwardingRawData(t *testing.T) {
response
:=
httptest
.
NewRecorder
()
httpRequest
.
Header
.
Set
(
"Gitlab-Workhorse-Temp-Path"
,
tempPath
)
httpRequest
.
Header
.
Set
(
tempPathHeader
,
tempPath
)
u
:=
newUpstream
(
ts
.
URL
,
nil
)
u
.
handleFileUploads
(
response
,
httpRequest
)
...
...
@@ -124,7 +124,7 @@ func TestUploadHandlerRewritingMultiPartData(t *testing.T) {
httpRequest
.
Body
=
ioutil
.
NopCloser
(
&
buffer
)
httpRequest
.
ContentLength
=
int64
(
buffer
.
Len
())
httpRequest
.
Header
.
Set
(
"Content-Type"
,
writer
.
FormDataContentType
())
httpRequest
.
Header
.
Set
(
"Gitlab-Workhorse-Temp-Path"
,
tempPath
)
httpRequest
.
Header
.
Set
(
tempPathHeader
,
tempPath
)
response
:=
httptest
.
NewRecorder
()
u
:=
newUpstream
(
ts
.
URL
,
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