-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: inconsistent results using os/exec in handler #5660
Labels
Milestone
Comments
I can reproduce on a Mac. If I either buffer the input or buffer the output, it passes. (See attached x.go) It only produces inconsistent results if it streams in and streams out, which the net/http package (nor HTTP, really) permits. But in this case, the md5 binary shouldn't produce any output until its input's EOF, so I think this should work. I suspected maybe that the exec package's io.Copy to the rw from its internal os.Pipe was causing a 0-byte write or something which forced the HTTP package to shut down its input, but that doesn't appear to be the case. Labels changed: added suggested. Owner changed to @bradfitz. Attachments:
|
The problem is os/exec's io.Copy(ResponseWriter, os.Pipe) and finding that the ResponseWriter implements io.ReaderFrom. The net/http (*response).ReadFrom immediately then calls WriteHeader and flushes any buffered writes, in prep to do a sendfile. func (w *response) ReadFrom(src io.Reader) (n int64, err error) { if !w.wroteHeader { w.WriteHeader(StatusOK) } ... w.w.Flush() // get rid of any previous writes w.cw.flush() // make sure Header is written; flush data to rwc Writing the Header & sending it to the client causes the request.Body to be closed (which md5 is still reading from). |
Frowned-upon patch at https://golang.org/cl/12632043/ |
This issue was closed by revision de04bf2. Status changed to Fixed. |
gopherbot
added
fixed
Suggested
Issues that may be good for new contributors looking for work to do.
labels
Aug 8, 2013
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
by cgmurray:
Attachments:
The text was updated successfully, but these errors were encountered: