net/http: return appropriate errors from ReadRequest

Fixes #3298

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5783080
This commit is contained in:
Brad Fitzpatrick 2012-03-12 10:42:25 -07:00
parent da8efae9fe
commit e8deb3f828
3 changed files with 24 additions and 3 deletions

View file

@ -455,11 +455,13 @@ func ReadRequest(b *bufio.Reader) (req *Request, err error) {
// First line: GET /index.html HTTP/1.0
var s string
if s, err = tp.ReadLine(); err != nil {
return nil, err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
return nil, err
}
}()
var f []string
if f = strings.SplitN(s, " ", 3); len(f) < 3 {