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
7808e1cc
Commit
7808e1cc
authored
Jul 27, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an early return in handle_get_info_refs
parent
d9bc0d49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
33 deletions
+32
-33
main.go
main.go
+32
-33
No files found.
main.go
View file @
7808e1cc
...
@@ -149,43 +149,42 @@ func do_auth_request(r *http.Request) (result *http.Response, err error) {
...
@@ -149,43 +149,42 @@ func do_auth_request(r *http.Request) (result *http.Response, err error) {
func
handle_get_info_refs
(
gl_id
string
,
_
string
,
path
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
handle_get_info_refs
(
gl_id
string
,
_
string
,
path
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
switch
rpc
{
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
case
"git-upload-pack"
,
"git-receive-pack"
:
// Prepare our Git subprocess
cmd
:=
exec
.
Command
(
"git"
,
sub_command
(
rpc
),
"--stateless-rpc"
,
"--advertise-refs"
,
path
)
set_cmd_env
(
cmd
,
gl_id
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
fail_500
(
w
,
err
)
return
}
defer
stdout
.
Close
()
if
err
:=
cmd
.
Start
();
err
!=
nil
{
fail_500
(
w
,
err
)
return
}
// Start writing the response
w
.
Header
()
.
Add
(
"Content-Type"
,
fmt
.
Sprintf
(
"application/x-%s-advertisement"
,
rpc
))
header_no_cache
(
w
)
w
.
WriteHeader
(
200
)
// Don't bother with HTTP 500 from this point on, just panic
if
err
:=
pkt_line
(
w
,
fmt
.
Sprintf
(
"# service=%s
\n
"
,
rpc
));
err
!=
nil
{
panic
(
err
)
}
if
err
:=
pkt_flush
(
w
);
err
!=
nil
{
panic
(
err
)
}
if
_
,
err
:=
io
.
Copy
(
w
,
stdout
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
cmd
.
Wait
();
err
!=
nil
{
panic
(
err
)
}
case
""
:
// The 'dumb' Git HTTP protocol is not supported
// The 'dumb' Git HTTP protocol is not supported
http
.
Error
(
w
,
"Not Found"
,
404
)
http
.
Error
(
w
,
"Not Found"
,
404
)
return
return
}
}
// Prepare our Git subprocess
cmd
:=
exec
.
Command
(
"git"
,
sub_command
(
rpc
),
"--stateless-rpc"
,
"--advertise-refs"
,
path
)
set_cmd_env
(
cmd
,
gl_id
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
fail_500
(
w
,
err
)
return
}
defer
stdout
.
Close
()
if
err
:=
cmd
.
Start
();
err
!=
nil
{
fail_500
(
w
,
err
)
return
}
// Start writing the response
w
.
Header
()
.
Add
(
"Content-Type"
,
fmt
.
Sprintf
(
"application/x-%s-advertisement"
,
rpc
))
header_no_cache
(
w
)
w
.
WriteHeader
(
200
)
// Don't bother with HTTP 500 from this point on, just panic
if
err
:=
pkt_line
(
w
,
fmt
.
Sprintf
(
"# service=%s
\n
"
,
rpc
));
err
!=
nil
{
panic
(
err
)
}
if
err
:=
pkt_flush
(
w
);
err
!=
nil
{
panic
(
err
)
}
if
_
,
err
:=
io
.
Copy
(
w
,
stdout
);
err
!=
nil
{
panic
(
err
)
}
if
err
:=
cmd
.
Wait
();
err
!=
nil
{
panic
(
err
)
}
}
}
func
sub_command
(
rpc
string
)
string
{
func
sub_command
(
rpc
string
)
string
{
...
...
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