Documentation
¶
Overview ¶
Package pktline implements Git's pkt-line framing as specified by gitprotocol-common(5) and the protocol v2 special packets of gitprotocol-v2(5): flush-pkt "0000", delim-pkt "0001" and response-end-pkt "0002".
The reader is bounded: a packet longer than MaxPacket (65520 bytes, header included) is refused before any payload is read or allocated, and so is any length field that is not four lowercase hexadecimal digits or that falls on the unassigned values 0003.
Index ¶
Constants ¶
const ( // MaxPacket is the largest pkt-line, length header included. MaxPacket = 65520 // MaxData is the largest payload of a data pkt-line. MaxData = MaxPacket - 4 // MaxSidebandData is the largest payload that fits in a pkt-line that // also carries a one-byte side-band stream code. MaxSidebandData = MaxData - 1 )
Variables ¶
var ( ErrBadLength = errors.New("pktline: length field is not four lowercase hex digits") ErrReserved = errors.New("pktline: reserved length 0003") ErrTooLong = errors.New("pktline: packet exceeds 65520 bytes") ErrDataTooBig = errors.New("pktline: payload exceeds 65516 bytes") )
Refusals. All are wrapped with %w by the reader and writer.
Functions ¶
Types ¶
type Packet ¶
Packet is one decoded packet. Data aliases the reader's buffer and is valid until the next call to Read.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decodes pkt-lines from an io.Reader.
func NewReader ¶
NewReader returns a Reader. r should be buffered by the caller if it is expensive to read from in small pieces.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer encodes pkt-lines.
func (*Writer) Err ¶
Err returns the first write error, if any. Once set, every later write returns it without touching the underlying writer.