http1

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pending requestState = iota + 1
	HeadersCompleted
	Error
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	*stash.Reader
	// contains filtered or unexported fields
}

func NewBody

func NewBody(
	client tcp.Client, chunkedParser *chunkedbody.Parser, s config.Body,
) *Body

func (*Body) Bytes

func (b *Body) Bytes() ([]byte, error)

func (*Body) Callback

func (b *Body) Callback(cb http.OnBodyCallback) error

func (*Body) Discard

func (b *Body) Discard() (err error)

func (*Body) Init

func (b *Body) Init(request *http.Request)

func (*Body) Retrieve

func (b *Body) Retrieve() ([]byte, error)

func (*Body) String

func (b *Body) String() (string, error)

type Parser

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

Parser is a stream-based http requests parser. It modifies request object by pointer in performance purposes. Decodes query-encoded values by its own, you can see that by presented states ePathDecode1Char, ePathDecode2Char, etc. When headers are parsed, parser returns state HeadersCompleted to notify http server about this, attaching all the pending data as an extra. Body must be processed separately

func NewParser

func NewParser(
	request *http.Request, keyBuff, valBuff, startLineBuff *buffer.Buffer, hdrsCfg config.Headers,
) *Parser

func (*Parser) Parse

func (p *Parser) Parse(data []byte) (state requestState, extra []byte, err error)

type Serializer

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

func NewSerializer

func NewSerializer(
	buff []byte,
	fileBuffSize int,
	defHdrs map[string]string,
	request *http.Request,
	writer Writer,
) *Serializer

func (*Serializer) PreWrite

func (d *Serializer) PreWrite(protocol proto.Proto, response *http.Response)

PreWrite writes the response into the buffer without actually sending it. Usually used for informational responses

func (*Serializer) Write

func (d *Serializer) Write(
	protocol proto.Proto, response *http.Response,
) (err error)

Write writes the response, keeping in mind difference between 1.0 and 1.1 HTTP versions

type Suit

type Suit struct {
	*Parser
	*Serializer
	// contains filtered or unexported fields
}

func Initialize

func Initialize(cfg config.Config, r router.Router, client tcp.Client, req *http.Request) *Suit

Initialize is the same constructor as just New, but consumes fewer arguments.

func New

func New(
	cfg config.Config,
	r router.Router,
	request *http.Request,
	client tcp.Client,
	keyBuff, valBuff, startLineBuff *buffer.Buffer,
	respBuff []byte,
	respFileBuffSize int,
	defaultHeaders map[string]string,
) *Suit

func (*Suit) Serve

func (s *Suit) Serve()

func (*Suit) ServeOnce

func (s *Suit) ServeOnce() bool

type Writer

type Writer interface {
	Write([]byte) error
}

Jump to

Keyboard shortcuts

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