net/http: Show more data for unsolicited response

Show more than one character when we recieve a unsolicited
response on an idle HTTP channel. Showing more than one
byte is really useful when you want to debug your program
when you get this message.

Change-Id: I3caf9f06420e7c2a2de3e4eb302c5dab95428fdb
Reviewed-on: https://go-review.googlesource.com/13959
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Erik Dubbelboer 2015-08-27 14:09:15 +08:00 committed by Brad Fitzpatrick
parent e36494e382
commit d33360571f
1 changed files with 2 additions and 2 deletions

View File

@ -925,8 +925,8 @@ func (pc *persistConn) readLoop() {
if !pc.closed {
pc.closeLocked()
if len(pb) > 0 {
log.Printf("Unsolicited response received on idle HTTP channel starting with %q; err=%v",
string(pb), err)
buf, _ := pc.br.Peek(pc.br.Buffered())
log.Printf("Unsolicited response received on idle HTTP channel starting with %q; err=%v", buf, err)
}
}
pc.lk.Unlock()