Commit 7c7a525d authored by Russ Cox's avatar Russ Cox

add io.ReadWriteClose and use it in http

R=r
DELTA=15  (6 added, 7 deleted, 2 changed)
OCL=17447
CL=17461
parent a6b546fe
...@@ -11,16 +11,9 @@ import ( ...@@ -11,16 +11,9 @@ import (
"os" "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). // Active HTTP connection (server side).
export type Conn struct { export type Conn struct {
rwc RWC; rwc io.ReadWriteClose;
br *bufio.BufRead; br *bufio.BufRead;
bw *bufio.BufWrite; bw *bufio.BufWrite;
close bool; close bool;
...@@ -28,7 +21,7 @@ export type Conn struct { ...@@ -28,7 +21,7 @@ export type Conn struct {
} }
// Create new connection from rwc. // 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 = new(Conn);
c.rwc = rwc; c.rwc = rwc;
if c.br, err = bufio.NewBufRead(rwc); err != nil { if c.br, err = bufio.NewBufRead(rwc); err != nil {
......
...@@ -19,6 +19,12 @@ export type ReadWrite interface { ...@@ -19,6 +19,12 @@ export type ReadWrite interface {
Write(p *[]byte) (n int, err *os.Error); 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) { export func WriteString(w Write, s string) (n int, err *os.Error) {
b := new([]byte, len(s)+1); b := new([]byte, len(s)+1);
if !syscall.StringToBytes(b, s) { if !syscall.StringToBytes(b, s) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment