]> Cypherpunks repositories - gostls13.git/commitdiff
add io.ReadWriteClose and use it in http
authorRuss Cox <rsc@golang.org>
Mon, 20 Oct 2008 19:37:07 +0000 (12:37 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 20 Oct 2008 19:37:07 +0000 (12:37 -0700)
R=r
DELTA=15  (6 added, 7 deleted, 2 changed)
OCL=17447
CL=17461

src/lib/http/conn.go
src/lib/io.go

index e7024ed606c387e0a82c47ee93aa9aa743236448..15c0707f3e027c92b7237f7098d7075ad0bebc5e 100644 (file)
@@ -11,16 +11,9 @@ import (
        "os"
 )
 
-// Read/write/close interface.
-type RWC interface {
-       Read(p *[]byte) (n int, err *os.Error);
-       Write(p *[]byte) (n int, err *os.Error);
-       Close() *os.Error;
-}
-
 // Active HTTP connection (server side).
 export type Conn struct {
-       rwc RWC;
+       rwc io.ReadWriteClose;
        br *bufio.BufRead;
        bw *bufio.BufWrite;
        close bool;
@@ -28,7 +21,7 @@ export type Conn struct {
 }
 
 // Create new connection from rwc.
-export func NewConn(rwc RWC) (c *Conn, err *os.Error) {
+export func NewConn(rwc io.ReadWriteClose) (c *Conn, err *os.Error) {
        c = new(Conn);
        c.rwc = rwc;
        if c.br, err = bufio.NewBufRead(rwc); err != nil {
index 8ab751a022b8e73c84efcb9de7980de193b37f8a..20b7b90292262d15add8a7d5d3c0a2cf838b4958 100644 (file)
@@ -19,6 +19,12 @@ export type ReadWrite interface {
        Write(p *[]byte) (n int, err *os.Error);
 }
 
+export type ReadWriteClose interface {
+       Read(p *[]byte) (n int, err *os.Error);
+       Write(p *[]byte) (n int, err *os.Error);
+       Close() *os.Error;
+}
+
 export func WriteString(w Write, s string) (n int, err *os.Error) {
        b := new([]byte, len(s)+1);
        if !syscall.StringToBytes(b, s) {