diff -r dd479b99dcd3 src/pkg/net/textproto/reader.go --- a/src/pkg/net/textproto/reader.go Wed Jul 20 08:39:24 2011 +1000 +++ b/src/pkg/net/textproto/reader.go Tue Jul 19 16:26:32 2011 -0700 @@ -33,22 +33,25 @@ // ReadLine reads a single line from r, // eliding the final \n or \r\n from the returned string. func (r *Reader) ReadLine() (string, os.Error) { - line, err := r.ReadLineBytes() + line, err := r.readLineSlice() return string(line), err } // ReadLineBytes is like ReadLine but returns a []byte instead of a string. func (r *Reader) ReadLineBytes() ([]byte, os.Error) { + line, err := r.readLineSlice() + if err != nil { + return line, err + } + buf := make([]byte, len(line)) + copy(buf, line) + return buf, err +} + +func (r *Reader) readLineSlice() ([]byte, os.Error) { r.closeDot() - line, err := r.R.ReadBytes('\n') - n := len(line) - if n > 0 && line[n-1] == '\n' { - n-- - if n > 0 && line[n-1] == '\r' { - n-- - } - } - return line[0:n], err + line, _, err := r.R.ReadLine() + return line, err } // ReadContinuedLine reads a possibly continued line from r,