Skip to content
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

Writing to http.ResponseWriter closes request.Body #4637

Closed
cskr opened this issue Jan 9, 2013 · 1 comment
Closed

Writing to http.ResponseWriter closes request.Body #4637

cskr opened this issue Jan 9, 2013 · 1 comment
Milestone

Comments

@cskr
Copy link

cskr commented Jan 9, 2013

http://play.golang.org/p/oUJ95CP-Gv

What is the expected output?

Request body must be copied to  response.

What do you see instead?

io.Copy() fails with "http: invalid Read on closed Body".

Which operating system are you using?

Ubuntu 12.10

Which version are you using?  (run 'go version')

go version devel +1399878c6731 Tue Jan 08 15:03:30 2013 -0800 linux/amd64

Reading complete request body into a buffer before beginning to write works. Copying to
os.Stdout works too.
@bradfitz
Copy link
Contributor

bradfitz commented Jan 9, 2013

Comment 1:

This is by design.  HTTP doesn't guarantee you can write a response before reading the
request.  Some servers will do it and some clients will do it, but not all, so we
intentionally disallow it, to prevent surprises.  It's easier for us to relax this
restriction in the future if we discover we're wrong (spec references and comprehensive
testing of all major clients & servers welcome!) than it is for us to allow it now and
then take it away.

Status changed to WorkingAsIntended.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants