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
e122950d
Commit
e122950d
authored
Jan 15, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put buffering method in helper package
parent
6ba53d9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
24 deletions
+35
-24
internal/git/upload-pack.go
internal/git/upload-pack.go
+2
-24
internal/helper/tempfile.go
internal/helper/tempfile.go
+33
-0
No files found.
internal/git/upload-pack.go
View file @
e122950d
...
@@ -6,7 +6,6 @@ import (
...
@@ -6,7 +6,6 @@ import (
"io"
"io"
"io/ioutil"
"io/ioutil"
"net/http"
"net/http"
"os"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
...
@@ -26,10 +25,10 @@ func handleUploadPack(w *GitHttpResponseWriter, r *http.Request, a *api.Response
...
@@ -26,10 +25,10 @@ func handleUploadPack(w *GitHttpResponseWriter, r *http.Request, a *api.Response
// We must drain the request body before writing the response, to avoid
// We must drain the request body before writing the response, to avoid
// upsetting NGINX.
// upsetting NGINX.
remainder
,
err
:=
bufferIn
Tempfile
(
r
.
Body
)
remainder
,
err
:=
helper
.
ReadAll
Tempfile
(
r
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
)
fail500
(
w
)
return
writtenIn
,
fmt
.
Errorf
(
"
bufferIn
Tempfile: %v"
,
err
)
return
writtenIn
,
fmt
.
Errorf
(
"
ReadAll
Tempfile: %v"
,
err
)
}
}
defer
remainder
.
Close
()
defer
remainder
.
Close
()
...
@@ -83,24 +82,3 @@ func handleUploadPack(w *GitHttpResponseWriter, r *http.Request, a *api.Response
...
@@ -83,24 +82,3 @@ func handleUploadPack(w *GitHttpResponseWriter, r *http.Request, a *api.Response
func
fail500
(
w
http
.
ResponseWriter
)
{
func
fail500
(
w
http
.
ResponseWriter
)
{
helper
.
Fail500
(
w
,
nil
,
nil
)
helper
.
Fail500
(
w
,
nil
,
nil
)
}
}
func
bufferInTempfile
(
r
io
.
Reader
)
(
io
.
ReadCloser
,
error
)
{
buffer
,
err
:=
ioutil
.
TempFile
(
""
,
"gitlab-workhorse-git-request-body"
)
if
err
!=
nil
{
return
nil
,
err
}
if
err
:=
os
.
Remove
(
buffer
.
Name
());
err
!=
nil
{
return
nil
,
err
}
if
_
,
err
:=
io
.
Copy
(
buffer
,
r
);
err
!=
nil
{
return
nil
,
err
}
if
_
,
err
:=
buffer
.
Seek
(
0
,
0
);
err
!=
nil
{
return
nil
,
err
}
return
buffer
,
nil
}
internal/helper/tempfile.go
0 → 100644
View file @
e122950d
package
helper
import
(
"io"
"io/ioutil"
"os"
)
func
ReadAllTempfile
(
r
io
.
Reader
)
(
_
io
.
ReadCloser
,
err
error
)
{
tempfile
,
err
:=
ioutil
.
TempFile
(
""
,
"gitlab-workhorse-read-all-tempfile"
)
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
if
err
!=
nil
{
tempfile
.
Close
()
}
}()
if
err
:=
os
.
Remove
(
tempfile
.
Name
());
err
!=
nil
{
return
nil
,
err
}
if
_
,
err
:=
io
.
Copy
(
tempfile
,
r
);
err
!=
nil
{
return
nil
,
err
}
if
_
,
err
:=
tempfile
.
Seek
(
0
,
0
);
err
!=
nil
{
return
nil
,
err
}
return
tempfile
,
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