Skip to content

Commit c515b6a

Browse files
committed
wip
1 parent 1018257 commit c515b6a

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

githttpxfer/githttpxfer.go

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,8 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
292292
cleanUpProcessGroup(cmd)
293293
}()
294294

295-
stdin, err := cmd.StdinPipe()
296-
if err != nil {
297-
ghx.logger.Error("failed to get pipe that will be connected to the command's standard input. ", err.Error())
298-
RenderInternalServerError(res.Writer)
299-
return
300-
}
301-
defer stdin.Close()
302-
303-
stdout, err := cmd.StdoutPipe()
304-
if err != nil {
305-
ghx.logger.Error("failed to get pipe that will be connected to the command's standard output. ", err.Error())
306-
RenderInternalServerError(res.Writer)
307-
return
308-
}
309-
defer stdout.Close()
295+
cmd.Stdin = body
296+
cmd.Stdout = res.Writer
310297

311298
err = cmd.Start()
312299
if err != nil {
@@ -315,24 +302,6 @@ func (ghx *GitHTTPXfer) serviceRPC(ctx Context, rpc string) {
315302
return
316303
}
317304

318-
go func() {
319-
if _, err := io.Copy(stdin, body); err != nil {
320-
ghx.logger.Error("failed to write the request body to standard input. ", err.Error())
321-
RenderInternalServerError(res.Writer)
322-
return
323-
}
324-
// "git-upload-pack" waits for the remaining input and it hangs,
325-
// so must close it after completing the copy request body to standard input.
326-
stdin.Close()
327-
}()
328-
329-
go func() {
330-
if _, err := io.Copy(res.Writer, stdout); err != nil {
331-
ghx.logger.Error("failed to write the standard output to response. ", err.Error())
332-
return
333-
}
334-
}()
335-
336305
if err = cmd.Wait(); err != nil {
337306
ghx.logger.Error("specified command fails to run or doesn't complete successfully. ", err.Error())
338307
}

0 commit comments

Comments
 (0)