]> Cypherpunks repositories - gostls13.git/commitdiff
http: fixes for sniffing
authorRuss Cox <rsc@golang.org>
Fri, 15 Jul 2011 16:07:37 +0000 (12:07 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 15 Jul 2011 16:07:37 +0000 (12:07 -0400)
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4753044

src/pkg/http/server.go

index d71a24959a57de5dd917383f8b58bb20f0e2be5d..ca9ab64742512a3c59a3f4cb32cbb51766a6a45d 100644 (file)
@@ -131,7 +131,7 @@ func (r *response) ReadFrom(src io.Reader) (n int64, err os.Error) {
        // WriteHeader if it hasn't been called yet, and WriteHeader
        // is what sets r.chunking.
        r.Flush()
-       if !r.chunking && r.bodyAllowed() {
+       if !r.chunking && r.bodyAllowed() && !r.needSniff {
                if rf, ok := r.conn.rwc.(io.ReaderFrom); ok {
                        n, err = rf.ReadFrom(src)
                        r.written += n
@@ -367,8 +367,8 @@ func (w *response) sniff() {
 
        if w.chunking && len(data) > 0 {
                fmt.Fprintf(w.conn.buf, "%x\r\n", len(data))
-               w.conn.buf.Write(data)
        }
+       w.conn.buf.Write(data)
 }
 
 // bodyAllowed returns true if a Write is allowed for this response type.