]> Cypherpunks repositories - gostls13.git/commitdiff
Fix the chunked encoding - terminate the chunk with CRLF.
authorStephen Ma <stephenm@golang.org>
Mon, 27 Apr 2009 07:38:04 +0000 (00:38 -0700)
committerStephen Ma <stephenm@golang.org>
Mon, 27 Apr 2009 07:38:04 +0000 (00:38 -0700)
R=rsc
APPROVED=r
DELTA=11  (10 added, 0 deleted, 1 changed)
OCL=27723
CL=27879

src/lib/http/server.go

index 3595a515dcb6e8f9440386ac55542835bc08edb9..9b6aa6c414a6b300212b8f3c1c70691c7d7e0f89 100644 (file)
@@ -174,7 +174,17 @@ func (c *Conn) Write(data []byte) (n int, err os.Error) {
        if c.chunking {
                fmt.Fprintf(c.buf, "%x\r\n", len(data));        // TODO(rsc): use strconv not fmt
        }
-       return c.buf.Write(data);
+       n, err = c.buf.Write(data);
+       if err == nil && c.chunking {
+               if n != len(data) {
+                       err = bufio.ShortWrite;
+               }
+               if err == nil {
+                       io.WriteString(c.buf, "\r\n");
+               }
+       }
+
+       return n, err;
 }
 
 func (c *Conn) flush() {