aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-06-02 10:26:09 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2011-06-02 10:26:09 -0700
commit4d15577783aaf5d6c3b53850d44b38b1bef305bc (patch)
tree95fcebd58b873a1fb07565b4b5032e8fc167189a /src/pkg/http
parent69cb8fef43aba1d133d093c4617c5711c1b5a20b (diff)
downloadgo-4d15577783aaf5d6c3b53850d44b38b1bef305bc.tar.xz
exec: add Cmd methods StdinPipe, StdoutPipe, StderrPipe
It gets annoying to do this in caller code otherwise, especially having to remember to Close one side. R=rsc CC=golang-dev https://golang.org/cl/4517134
Diffstat (limited to 'src/pkg/http')
-rw-r--r--src/pkg/http/cgi/host.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/pkg/http/cgi/host.go b/src/pkg/http/cgi/host.go
index c283191ef2..7ab3f9247a 100644
--- a/src/pkg/http/cgi/host.go
+++ b/src/pkg/http/cgi/host.go
@@ -161,30 +161,27 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
h.printf("CGI error: %v", err)
}
- stdoutRead, stdoutWrite, err := os.Pipe()
- if err != nil {
- internalError(err)
- return
- }
-
cmd := &exec.Cmd{
Path: pathBase,
Args: append([]string{h.Path}, h.Args...),
Dir: cwd,
Env: env,
- Stdout: stdoutWrite,
Stderr: os.Stderr, // for now
}
if req.ContentLength != 0 {
cmd.Stdin = req.Body
}
+ stdoutRead, err := cmd.StdoutPipe()
+ if err != nil {
+ internalError(err)
+ return
+ }
err = cmd.Start()
if err != nil {
internalError(err)
return
}
- stdoutWrite.Close()
defer cmd.Wait()
linebody, _ := bufio.NewReaderSize(stdoutRead, 1024)