1
0
mirror of https://github.com/golang/go synced 2024-11-26 03:37:57 -07:00

Fix the chunked encoding - terminate the chunk with CRLF.

R=rsc
APPROVED=r
DELTA=11  (10 added, 0 deleted, 1 changed)
OCL=27723
CL=27879
This commit is contained in:
Stephen Ma 2009-04-27 00:38:04 -07:00
parent f4b92c8624
commit eb5eea9a8f

View 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() {