]> Cypherpunks repositories - gostls13.git/commitdiff
Created new Conn.Flush() public method so the fd pipeline can be drained arbitrarily...
authorDavid Titarenco <david.titarenco@gmail.com>
Sat, 14 Nov 2009 02:06:47 +0000 (18:06 -0800)
committerRuss Cox <rsc@golang.org>
Sat, 14 Nov 2009 02:06:47 +0000 (18:06 -0800)
Commented both flush methods so people know what they are looking at.

This is a necessary fix for streaming and long polling HTTP services.
Fixes #93.

R=r, rsc, david.titarenco
https://golang.org/cl/154099

src/pkg/http/server.go

index d4b23a20f9a1e565f796e85224bd9cbc95d72ced..9178d5438c027f65654c73b461626d64b8d44e56 100644 (file)
@@ -238,7 +238,7 @@ func errorKludge(c *Conn, req *Request) {
        }
 }
 
-func (c *Conn) flush() {
+func (c *Conn) finishRequest() {
        if !c.wroteHeader {
                c.WriteHeader(StatusOK)
        }
@@ -251,6 +251,14 @@ func (c *Conn) flush() {
        c.buf.Flush();
 }
 
+// Flush sends any buffered data to the client.
+func (c *Conn) Flush() {
+       if !c.wroteHeader {
+               c.WriteHeader(StatusOK)
+       }
+       c.buf.Flush();
+}
+
 // Close the connection.
 func (c *Conn) close() {
        if c.buf != nil {
@@ -277,7 +285,7 @@ func (c *Conn) serve() {
                if c.hijacked {
                        return
                }
-               c.flush();
+               c.finishRequest();
                if c.closeAfterReply {
                        break
                }