Documentation
¶
Overview ¶
Package textproto implements generic support for text-based request/response protocols in the style of HTTP, NNTP, and SMTP.
The package provides:
Error, which represents a numeric error response from a server.
Pipeline, to manage pipelined requests and responses in a client.
Reader, to read numeric response code lines, key: value headers, lines wrapped with leading spaces on continuation lines, and whole text blocks ending with a dot on a line by itself.
Writer, to write dot-encoded text blocks.
Conn, a convenient packaging of Reader, Writer, and Pipeline for use with a single network connection.
Index ¶
- func CanonicalMIMEHeaderKey(s string) string
- func TrimBytes(b []byte) []byte
- func TrimString(s string) string
- type Conn
- type Error
- type MIMEHeader
- type Pipeline
- type ProtocolError
- type Reader
- func (r *Reader) DotReader() io.Reader
- func (r *Reader) ReadCodeLine(expectCode int) (code int, message string, err error)
- func (r *Reader) ReadContinuedLine() (string, error)
- func (r *Reader) ReadContinuedLineBytes() ([]byte, error)
- func (r *Reader) ReadDotBytes() ([]byte, error)
- func (r *Reader) ReadDotLines() ([]string, error)
- func (r *Reader) ReadLine() (string, error)
- func (r *Reader) ReadLineBytes() ([]byte, error)
- func (r *Reader) ReadMIMEHeader() (MIMEHeader, error)
- func (r *Reader) ReadResponse(expectCode int) (code int, message string, err error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalMIMEHeaderKey ¶
CanonicalMIMEHeaderKey returns the canonical format of the MIME header key s. The canonicalization converts the first letter and any letter following a hyphen to upper case; the rest are converted to lowercase. For example, the canonical key for "accept-encoding" is "Accept-Encoding". MIME header keys are assumed to be ASCII only. If s contains a space or invalid header field bytes, it is returned without modifications.
func TrimString ¶ added in go1.1
func TrimString(s string)