package pop3 import ( "bytes" "fmt" ) // Command only writes; it does not read a reply. func (framed *Framed) Command(keyword Keyword, arguments ...string) error { buf := bytes.NewBuffer(make([]byte, 0, MaximumPhysicalLineLength)) buf.WriteString(string(keyword)) for _, argument := range arguments { // Cf. RFC 1939 3. if framed.Strict && (len(argument) > 40 || !IsASCIIWord(argument)) { return fmt.Errorf("%w: invalid command argument: %q", ErrSyntax, argument) } buf.WriteByte(SP) buf.WriteString(argument) } buf.WriteString(CRLF) if framed.Strict && buf.Len() > MaximumPhysicalLineLength { // TODO is this restriction there? return fmt.Errorf("%w: command line too long (> %d octets)", ErrProtocol, MaximumPhysicalLineLength) } _, err := framed.transport.Write(buf.Bytes()) return err }