Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
vvatanabe committed Apr 29, 2018
2 parents f38b267 + 0cb59a0 commit 0c458e8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions githttpxfer/githttpxfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,36 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
RenderInternalServerError(res.Writer)
return
}
defer stdin.Close()

stdout, err := cmd.StdoutPipe()
if err != nil {
ghx.logger.Error("failed to get pipe that will be connected to the command's standard output. ", err.Error())
RenderInternalServerError(res.Writer)
return
}
defer stdout.Close()

if err = cmd.Start(); err != nil {
ghx.logger.Error("failed to starts the specified command. ", err.Error())
RenderInternalServerError(res.Writer)
return
}

io.Copy(stdin, body)
stdin.Close()
if _, err := io.Copy(stdin, body); err != nil {
ghx.logger.Error("failed to write the request body to standard input. ", err.Error())
RenderInternalServerError(res.Writer)
return
}

res.SetContentType(fmt.Sprintf("application/x-git-%s-result", rpc))
res.WriteHeader(http.StatusOK)

io.Copy(res.Writer, stdout)
stdout.Close()
if _, err := io.Copy(res.Writer, stdout); err != nil {
ghx.logger.Error("failed to write the standard output to response. ", err.Error())
return
}


if err = cmd.Wait(); err != nil {
ghx.logger.Error("specified command fails to run or doesn't complete successfully. ", err.Error())
Expand Down

0 comments on commit 0c458e8

Please sign in to comment.