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
04e1a814
Commit
04e1a814
authored
Oct 08, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle archive headers in separate function
parent
19ccbb62
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
githandler.go
githandler.go
+13
-9
No files found.
githandler.go
View file @
04e1a814
...
...
@@ -208,18 +208,10 @@ func handleGetInfoRefs(env gitEnv, _ string, repoPath string, w http.ResponseWri
func
handleGetArchive
(
env
gitEnv
,
format
string
,
repoPath
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
archiveFilename
:=
path
.
Base
(
env
.
ArchivePath
)
w
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
`attachment; filename="%s"`
,
archiveFilename
))
if
format
==
"zip"
{
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/zip"
)
}
else
{
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/octet-stream"
)
}
w
.
Header
()
.
Add
(
"Content-Transfer-Encoding"
,
"binary"
)
w
.
Header
()
.
Add
(
"Cache-Control"
,
"private"
)
if
cachedArchive
,
err
:=
os
.
Open
(
env
.
ArchivePath
);
err
==
nil
{
defer
cachedArchive
.
Close
()
log
.
Printf
(
"Serving cached file %q"
,
env
.
ArchivePath
)
setArchiveHeaders
(
w
,
format
,
archiveFilename
)
http
.
ServeContent
(
w
,
r
,
""
,
time
.
Unix
(
0
,
0
),
cachedArchive
)
return
}
...
...
@@ -291,6 +283,7 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
}
// Start writing the response
setArchiveHeaders
(
w
,
format
,
archiveFilename
)
w
.
WriteHeader
(
200
)
// Don't bother with HTTP 500 from this point on, just return
if
_
,
err
:=
io
.
Copy
(
w
,
io
.
TeeReader
(
stdout
,
tempFile
));
err
!=
nil
{
logContext
(
"handleGetArchive read from subprocess"
,
err
)
...
...
@@ -318,6 +311,17 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
}
}
func
setArchiveHeaders
(
w
http
.
ResponseWriter
,
format
string
,
archiveFilename
string
)
{
w
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
`attachment; filename="%s"`
,
archiveFilename
))
if
format
==
"zip"
{
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/zip"
)
}
else
{
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/octet-stream"
)
}
w
.
Header
()
.
Add
(
"Content-Transfer-Encoding"
,
"binary"
)
w
.
Header
()
.
Add
(
"Cache-Control"
,
"private"
)
}
func
handlePostRPC
(
env
gitEnv
,
rpc
string
,
repoPath
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
body
io
.
ReadCloser
var
err
error
...
...
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