diff options
| author | Rob Pike <r@golang.org> | 2009-05-08 11:52:39 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2009-05-08 11:52:39 -0700 |
| commit | 01712ae7d3694d28a68032723fd11d94d891b441 (patch) | |
| tree | d0843410366b2f44c86a0f50f8c83d3bfb423a14 /src/lib/http | |
| parent | c8b47c6fceeb249ab9e6f39503615ebe2ea205ce (diff) | |
| download | go-01712ae7d3694d28a68032723fd11d94d891b441.tar.xz | |
embeddability: change bufio.BufRead to bufio.Reader etc.
R=rsc
DELTA=112 (0 added, 4 deleted, 108 changed)
OCL=28537
CL=28543
Diffstat (limited to 'src/lib/http')
| -rw-r--r-- | src/lib/http/request.go | 8 | ||||
| -rw-r--r-- | src/lib/http/server.go | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/http/request.go b/src/lib/http/request.go index 59592add53..3edaa4207f 100644 --- a/src/lib/http/request.go +++ b/src/lib/http/request.go @@ -100,7 +100,7 @@ func (r *Request) ProtoAtLeast(major, minor int) bool { // Give up if the line exceeds maxLineLength. // The returned bytes are a pointer into storage in // the bufio, so they are only valid until the next bufio read. -func readLineBytes(b *bufio.BufRead) (p []byte, err os.Error) { +func readLineBytes(b *bufio.Reader) (p []byte, err os.Error) { if p, err = b.ReadLineSlice('\n'); err != nil { return nil, err } @@ -119,7 +119,7 @@ func readLineBytes(b *bufio.BufRead) (p []byte, err os.Error) { } // readLineBytes, but convert the bytes into a string. -func readLine(b *bufio.BufRead) (s string, err os.Error) { +func readLine(b *bufio.Reader) (s string, err os.Error) { p, e := readLineBytes(b); if e != nil { return "", e @@ -131,7 +131,7 @@ func readLine(b *bufio.BufRead) (s string, err os.Error) { // A key/value has the form Key: Value\r\n // and the Value can continue on multiple lines if each continuation line // starts with a space. -func readKeyValue(b *bufio.BufRead) (key, value string, err os.Error) { +func readKeyValue(b *bufio.Reader) (key, value string, err os.Error) { line, e := readLineBytes(b); if e != nil { return "", "", e @@ -266,7 +266,7 @@ func CanonicalHeaderKey(s string) string { } // ReadRequest reads and parses a request from b. -func ReadRequest(b *bufio.BufRead) (req *Request, err os.Error) { +func ReadRequest(b *bufio.Reader) (req *Request, err os.Error) { req = new(Request); // First line: GET /index.html HTTP/1.0 diff --git a/src/lib/http/server.go b/src/lib/http/server.go index 5769ced7ee..438c0d915b 100644 --- a/src/lib/http/server.go +++ b/src/lib/http/server.go @@ -44,7 +44,7 @@ type Conn struct { Req *Request; // current HTTP request rwc io.ReadWriteCloser; // i/o connection - buf *bufio.BufReadWrite; // buffered rwc + buf *bufio.ReadWriter; // buffered rwc handler Handler; // request handler hijacked bool; // connection has been hijacked by handler @@ -61,9 +61,9 @@ func newConn(rwc io.ReadWriteCloser, raddr string, handler Handler) (c *Conn, er c.RemoteAddr = raddr; c.handler = handler; c.rwc = rwc; - br := bufio.NewBufRead(rwc); - bw := bufio.NewBufWrite(rwc); - c.buf = bufio.NewBufReadWrite(br, bw); + br := bufio.NewReader(rwc); + bw := bufio.NewWriter(rwc); + c.buf = bufio.NewReadWriter(br, bw); return c, nil } @@ -74,7 +74,7 @@ func (c *Conn) readRequest() (req *Request, err os.Error) { if c.hijacked { return nil, ErrHijacked } - if req, err = ReadRequest(c.buf.BufRead); err != nil { + if req, err = ReadRequest(c.buf.Reader); err != nil { return nil, err } @@ -238,7 +238,7 @@ func (c *Conn) serve() { // will not do anything else with the connection. // It becomes the caller's responsibility to manage // and close the connection. -func (c *Conn) Hijack() (rwc io.ReadWriteCloser, buf *bufio.BufReadWrite, err os.Error) { +func (c *Conn) Hijack() (rwc io.ReadWriteCloser, buf *bufio.ReadWriter, err os.Error) { if c.hijacked { return nil, nil, ErrHijacked; } |
