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
a6655446
Commit
a6655446
authored
Feb 01, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use some more constants
parent
a3fc1506
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
internal/senddata/sendfile.go
internal/senddata/sendfile.go
+9
-5
No files found.
internal/senddata/sendfile.go
View file @
a6655446
...
@@ -14,7 +14,10 @@ import (
...
@@ -14,7 +14,10 @@ import (
"strings"
"strings"
)
)
const
sendDataHeader
=
"Gitlab-Workhorse-Send-Data"
const
(
sendDataResponseHeader
=
"Gitlab-Workhorse-Send-Data"
sendFileResponseHeader
=
"X-Sendfile"
)
type
sendFileResponseWriter
struct
{
type
sendFileResponseWriter
struct
{
rw
http
.
ResponseWriter
rw
http
.
ResponseWriter
...
@@ -28,6 +31,7 @@ func NewSendFileResponseWriter(rw http.ResponseWriter, req *http.Request) sendFi
...
@@ -28,6 +31,7 @@ func NewSendFileResponseWriter(rw http.ResponseWriter, req *http.Request) sendFi
rw
:
rw
,
rw
:
rw
,
req
:
req
,
req
:
req
,
}
}
// Advertise to upstream (Rails) that we support X-Sendfile
req
.
Header
.
Set
(
"X-Sendfile-Type"
,
"X-Sendfile"
)
req
.
Header
.
Set
(
"X-Sendfile-Type"
,
"X-Sendfile"
)
return
s
return
s
}
}
...
@@ -57,8 +61,8 @@ func (s *sendFileResponseWriter) WriteHeader(status int) {
...
@@ -57,8 +61,8 @@ func (s *sendFileResponseWriter) WriteHeader(status int) {
return
return
}
}
if
file
:=
s
.
Header
()
.
Get
(
"X-Sendfile"
);
file
!=
""
{
if
file
:=
s
.
Header
()
.
Get
(
sendFileResponseHeader
);
file
!=
""
{
s
.
Header
()
.
Del
(
"X-Sendfile"
)
s
.
Header
()
.
Del
(
sendFileResponseHeader
)
// Mark this connection as hijacked
// Mark this connection as hijacked
s
.
hijacked
=
true
s
.
hijacked
=
true
...
@@ -66,8 +70,8 @@ func (s *sendFileResponseWriter) WriteHeader(status int) {
...
@@ -66,8 +70,8 @@ func (s *sendFileResponseWriter) WriteHeader(status int) {
sendFileFromDisk
(
s
.
rw
,
s
.
req
,
file
)
sendFileFromDisk
(
s
.
rw
,
s
.
req
,
file
)
return
return
}
}
if
sendData
:=
s
.
Header
()
.
Get
(
sendDataHeader
);
strings
.
HasPrefix
(
sendData
,
git
.
SendBlobPrefix
)
{
if
sendData
:=
s
.
Header
()
.
Get
(
sendData
Response
Header
);
strings
.
HasPrefix
(
sendData
,
git
.
SendBlobPrefix
)
{
s
.
Header
()
.
Del
(
sendDataHeader
)
s
.
Header
()
.
Del
(
sendData
Response
Header
)
s
.
hijacked
=
true
s
.
hijacked
=
true
git
.
SendBlob
(
s
.
rw
,
s
.
req
,
sendData
)
git
.
SendBlob
(
s
.
rw
,
s
.
req
,
sendData
)
return
return
...
...
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