1
0
mirror of https://github.com/golang/go synced 2024-10-03 06:21:21 -06:00

net/http: fix text for ErrBodyReadAfterClose

Can happen in both request and response.
Also use it in one place that wasn't.

Fixes #3997.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6903057
This commit is contained in:
Russ Cox 2012-12-10 01:42:10 -05:00
parent 033e915481
commit 4f3dd833e3
2 changed files with 4 additions and 4 deletions

View File

@ -302,7 +302,7 @@ type expectContinueReader struct {
func (ecr *expectContinueReader) Read(p []byte) (n int, err error) {
if ecr.closed {
return 0, errors.New("http: Read after Close on request Body")
return 0, ErrBodyReadAfterClose
}
if !ecr.resp.wroteContinue && !ecr.resp.conn.hijacked() {
ecr.resp.wroteContinue = true

View File

@ -534,11 +534,11 @@ type body struct {
res *response // response writer for server requests, else nil
}
// ErrBodyReadAfterClose is returned when reading a Request Body after
// the body has been closed. This typically happens when the body is
// ErrBodyReadAfterClose is returned when reading a Request or Response
// Body after the body has been closed. This typically happens when the body is
// read after an HTTP Handler calls WriteHeader or Write on its
// ResponseWriter.
var ErrBodyReadAfterClose = errors.New("http: invalid Read on closed request Body")
var ErrBodyReadAfterClose = errors.New("http: invalid Read on closed Body")
func (b *body) Read(p []byte) (n int, err error) {
if b.closed {