diff options
| author | Rob Pike <r@golang.org> | 2009-04-17 00:08:24 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2009-04-17 00:08:24 -0700 |
| commit | aaf63f8d06cda8308eb7c47ebc1f2cf2c1c91d02 (patch) | |
| tree | c20f34ec6f9dea967a511f65b239c5e8637fec8f /src/lib/http | |
| parent | 3ea8d854a3a0b7f812d8590d4d1c3c2671288b60 (diff) | |
| download | go-aaf63f8d06cda8308eb7c47ebc1f2cf2c1c91d02.tar.xz | |
Step 1 of the Big Error Shift: make os.Error an interface and replace *os.Errors with os.Errors.
lib/template updated to use new setup; its clients also updated.
Step 2 will make os's error support internally much cleaner.
R=rsc
OCL=27586
CL=27586
Diffstat (limited to 'src/lib/http')
| -rw-r--r-- | src/lib/http/request.go | 8 | ||||
| -rw-r--r-- | src/lib/http/server.go | 12 | ||||
| -rw-r--r-- | src/lib/http/url.go | 8 | ||||
| -rw-r--r-- | src/lib/http/url_test.go | 4 |
4 files changed, 16 insertions, 16 deletions
diff --git a/src/lib/http/request.go b/src/lib/http/request.go index a2720ff01b..59592add53 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.BufRead) (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.BufRead) (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.BufRead) (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.BufRead) (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 267e9e41e4..3595a515dc 100644 --- a/src/lib/http/server.go +++ b/src/lib/http/server.go @@ -56,7 +56,7 @@ type Conn struct { } // Create new connection from rwc. -func newConn(rwc io.ReadWriteClose, raddr string, handler Handler) (c *Conn, err *os.Error) { +func newConn(rwc io.ReadWriteClose, raddr string, handler Handler) (c *Conn, err os.Error) { c = new(Conn); c.RemoteAddr = raddr; c.handler = handler; @@ -70,7 +70,7 @@ func newConn(rwc io.ReadWriteClose, raddr string, handler Handler) (c *Conn, err func (c *Conn) SetHeader(hdr, val string) // Read next request from connection. -func (c *Conn) readRequest() (req *Request, err *os.Error) { +func (c *Conn) readRequest() (req *Request, err os.Error) { if c.hijacked { return nil, ErrHijacked } @@ -156,7 +156,7 @@ func (c *Conn) WriteHeader(code int) { // Write writes the data to the connection as part of an HTTP reply. // If WriteHeader has not yet been called, Write calls WriteHeader(http.StatusOK) // before writing the data. -func (c *Conn) Write(data []byte) (n int, err *os.Error) { +func (c *Conn) Write(data []byte) (n int, err os.Error) { if c.hijacked { log.Stderr("http: Conn.Write on hijacked connection"); return 0, ErrHijacked @@ -228,7 +228,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.ReadWriteClose, buf *bufio.BufReadWrite, err *os.Error) { +func (c *Conn) Hijack() (rwc io.ReadWriteClose, buf *bufio.BufReadWrite, err os.Error) { if c.hijacked { return nil, nil, ErrHijacked; } @@ -448,7 +448,7 @@ func Handle(pattern string, handler Handler) { // creating a new service thread for each. The service threads // read requests and then call handler to reply to them. // Handler is typically nil, in which case the DefaultServeMux is used. -func Serve(l net.Listener, handler Handler) *os.Error { +func Serve(l net.Listener, handler Handler) os.Error { if handler == nil { handler = DefaultServeMux; } @@ -492,7 +492,7 @@ func Serve(l net.Listener, handler Handler) *os.Error { // panic("ListenAndServe: ", err.String()) // } // } -func ListenAndServe(addr string, handler Handler) *os.Error { +func ListenAndServe(addr string, handler Handler) os.Error { l, e := net.Listen("tcp", addr); if e != nil { return e diff --git a/src/lib/http/url.go b/src/lib/http/url.go index d92a3baa62..62699c13d7 100644 --- a/src/lib/http/url.go +++ b/src/lib/http/url.go @@ -45,7 +45,7 @@ func unhex(c byte) byte { // converting %AB into the byte 0xAB. // It returns a BadURL error if any % is not followed // by two hexadecimal digits. -func URLUnescape(s string) (string, *os.Error) { +func URLUnescape(s string) (string, os.Error) { // Count %, check that they're well-formed. n := 0; for i := 0; i < len(s); { @@ -98,7 +98,7 @@ type URL struct { // Maybe rawurl is of the form scheme:path. // (Scheme must be [a-zA-Z][a-zA-Z0-9+-.]*) // If so, return scheme, path; else return "", rawurl. -func getscheme(rawurl string) (scheme, path string, err *os.Error) { +func getscheme(rawurl string) (scheme, path string, err os.Error) { for i := 0; i < len(rawurl); i++ { c := rawurl[i]; switch { @@ -139,7 +139,7 @@ func split(s string, c byte, cutc bool) (string, string) { // ParseURL parses rawurl into a URL structure. // The string rawurl is assumed not to have a #fragment suffix. // (Web browsers strip #fragment before sending the URL to a web server.) -func ParseURL(rawurl string) (url *URL, err *os.Error) { +func ParseURL(rawurl string) (url *URL, err os.Error) { if rawurl == "" { return nil, BadURL } @@ -184,7 +184,7 @@ func ParseURL(rawurl string) (url *URL, err *os.Error) { } // ParseURLReference is like ParseURL but allows a trailing #fragment. -func ParseURLReference(rawurlref string) (url *URL, err *os.Error) { +func ParseURLReference(rawurlref string) (url *URL, err os.Error) { // Cut off #frag. rawurl, frag := split(rawurlref, '#', true); if url, err = ParseURL(rawurl); err != nil { diff --git a/src/lib/http/url_test.go b/src/lib/http/url_test.go index 50263f69ae..f5a7069aea 100644 --- a/src/lib/http/url_test.go +++ b/src/lib/http/url_test.go @@ -126,7 +126,7 @@ func ufmt(u *URL) string { u.Host, u.Path, u.Query, u.Fragment); } -func DoTest(t *testing.T, parse func(string) (*URL, *os.Error), name string, tests []URLTest) { +func DoTest(t *testing.T, parse func(string) (*URL, os.Error), name string, tests []URLTest) { for i, tt := range tests { u, err := parse(tt.in); if err != nil { @@ -150,7 +150,7 @@ func TestParseURLReference(t *testing.T) { DoTest(t, ParseURLReference, "ParseURLReference", urlfragtests); } -func DoTestString(t *testing.T, parse func(string) (*URL, *os.Error), name string, tests []URLTest) { +func DoTestString(t *testing.T, parse func(string) (*URL, os.Error), name string, tests []URLTest) { for i, tt := range tests { u, err := parse(tt.in); if err != nil { |
