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.

Static methods

staticinlinecanonicalMIMEHeaderKey(_s:GoString):GoString

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.

See also:

staticinlinedial(_network:GoString, _addr:GoString):{_1:Error, _0:Ref<Conn>}

Dial connects to the given address on the given network using net.Dial and then returns a new Conn for the connection.

See also:

staticinlinenewConn(_conn:ReadWriteCloser):Ref<Conn>

NewConn returns a new Conn using conn for I/O.

See also:

staticinlinenewReader(_r:Ref<Reader>):Ref<Reader>

NewReader returns a new Reader reading from r.

To avoid denial of service attacks, the provided bufio.Reader should be reading from an io.LimitReader or similar Reader to bound the size of responses.

See also:

staticinlinenewWriter(_w:Ref<Writer>):Ref<Writer>

NewWriter returns a new Writer writing to w.

See also:

staticinlinetrimBytes(_b:Slice<GoUInt8>):Slice<GoUInt8>

TrimBytes returns b without leading and trailing ASCII space.

See also:

staticinlinetrimString(_s:GoString):GoString

TrimString returns s without leading and trailing ASCII space.

See also: