pktline

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2018 License: Apache-2.0 Imports: 5 Imported by: 1

README

pktline

Package pktline implements pkt-line format encoding used by Git's transfer protocol. https://github.com/git/git/blob/master/Documentation/technical/protocol-common.txt

import "github.com/euforia/go-git-server/pktline"

Documentation

Overview

Package pktline implements pkt-line format encoding used by Git's transfer protocol. https://github.com/git/git/blob/master/Documentation/technical/protocol-common.txt

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrShortRead   = errors.New("input is too short")
	ErrInputExcess = errors.New("input is too long")
	ErrTooLong     = errors.New("too long payload")
	ErrInvalidLen  = errors.New("invalid length")
)

Errors returned by methods in package pktline.

Functions

func Decode

func Decode(line []byte) (payload []byte, err error)

Decode parses a single pkt-line and returns it's payload. Input longer than a single pkt-line is considered an error.

func Encode

func Encode(payload []byte) ([]byte, error)

Encode returns payload encoded in pkt-line format.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes input in pkt-line format.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder constructs a new pkt-line decoder.

func (*Decoder) Decode

func (d *Decoder) Decode(payload *[]byte) error

Decode reads a single pkt-line and stores its payload. Flush-pkt is causes *payload to be nil.

func (*Decoder) DecodeUntilFlush

func (d *Decoder) DecodeUntilFlush(lines *[][]byte) (err error)

DecodeUntilFlush decodes pkt-line messages until it encounters flush-pkt. The flush-pkt is not included in output. If error is not nil, output contains data that was read before the error occured.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder encodes payloads in pkt-line format.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder constructs a pkt-line encoder.

func (*Encoder) Encode

func (e *Encoder) Encode(payload []byte) error

Encode encodes payload and writes it to encoder output. If payload is nil, writes flush-pkt.

type EncoderDecoder

type EncoderDecoder struct {
	Encoder
	Decoder
}

EncoderDecoder serves as both Encoder and Decoder.

func NewEncoderDecoder

func NewEncoderDecoder(rw io.ReadWriter) *EncoderDecoder

NewEncoderDecoder constructs pkt-line encoder/decoder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL