nbhttp

package module
v0.0.0-...-3aa8f38 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 11 Imported by: 0

README

nbhttp - non-blocking http

MIT licensed

Less Is More 😄

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCRLF .
	ErrInvalidCRLF = errors.New("invalid cr/lf at the end of line")

	// ErrInvalidHTTPVersion .
	ErrInvalidHTTPVersion = errors.New("invalid HTTP version")

	// ErrInvalidHTTPStatusCode .
	ErrInvalidHTTPStatusCode = errors.New("invalid HTTP status code")
	// ErrInvalidHTTPStatus .
	ErrInvalidHTTPStatus = errors.New("invalid HTTP status")

	// ErrInvalidMethod .
	ErrInvalidMethod = errors.New("invalid HTTP method")

	// ErrInvalidRequestURI .
	ErrInvalidRequestURI = errors.New("invalid URL")

	// ErrInvalidHost .
	ErrInvalidHost = errors.New("invalid host")

	// ErrInvalidPort .
	ErrInvalidPort = errors.New("invalid port")

	// ErrInvalidPath .
	ErrInvalidPath = errors.New("invalid path")

	// ErrInvalidQueryString .
	ErrInvalidQueryString = errors.New("invalid query string")

	// ErrInvalidFragment .
	ErrInvalidFragment = errors.New("invalid fragment")

	// ErrCRExpected .
	ErrCRExpected = errors.New("CR character expected")

	// ErrLFExpected .
	ErrLFExpected = errors.New("LF character expected")

	// ErrInvalidCharInHeader .
	ErrInvalidCharInHeader = errors.New("invalid character in header")

	// ErrUnexpectedContentLength .
	ErrUnexpectedContentLength = errors.New("unexpected content-length header")

	// ErrInvalidContentLength .
	ErrInvalidContentLength = errors.New("invalid ContentLength")

	// ErrInvalidChunkSize .
	ErrInvalidChunkSize = errors.New("invalid chunk size")

	// ErrTrailerExpected .
	ErrTrailerExpected = errors.New("trailer expected")
)

Functions

This section is empty.

Types

type BodyReader

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

BodyReader .

func (*BodyReader) Close

func (br *BodyReader) Close() error

Close implements io. Closer

func (*BodyReader) Read

func (br *BodyReader) Read(p []byte) (int, error)

Read implements io.Reader

type ClientProcessor

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

ClientProcessor .

func (*ClientProcessor) HandleMessage

func (p *ClientProcessor) HandleMessage(handler func(*http.Response))

HandleMessage .

func (*ClientProcessor) OnBody

func (p *ClientProcessor) OnBody(data []byte)

OnBody .

func (*ClientProcessor) OnComplete

func (p *ClientProcessor) OnComplete(conn net.Conn)

OnComplete .

func (*ClientProcessor) OnContentLength

func (p *ClientProcessor) OnContentLength(contentLength int)

OnContentLength .

func (*ClientProcessor) OnHeader

func (p *ClientProcessor) OnHeader(key, value string)

OnHeader .

func (*ClientProcessor) OnMethod

func (p *ClientProcessor) OnMethod(method string)

OnMethod .

func (*ClientProcessor) OnProto

func (p *ClientProcessor) OnProto(proto string) error

OnProto .

func (*ClientProcessor) OnStatus

func (p *ClientProcessor) OnStatus(code int, status string)

OnStatus .

func (*ClientProcessor) OnTrailerHeader

func (p *ClientProcessor) OnTrailerHeader(key, value string)

OnTrailerHeader .

func (*ClientProcessor) OnURL

func (p *ClientProcessor) OnURL(uri string) error

OnURL .

func (*ClientProcessor) WriteTo

func (p *ClientProcessor) WriteTo(w io.Writer, data []byte) (int, error)

WriteTo .

type EmptyProcessor

type EmptyProcessor struct{}

EmptyProcessor .

func (*EmptyProcessor) HandleMessage

func (p *EmptyProcessor) HandleMessage(handler http.Handler)

HandleMessage .

func (*EmptyProcessor) OnBody

func (p *EmptyProcessor) OnBody(data []byte)

OnBody .

func (*EmptyProcessor) OnComplete

func (p *EmptyProcessor) OnComplete(conn net.Conn)

OnComplete .

func (*EmptyProcessor) OnContentLength

func (p *EmptyProcessor) OnContentLength(contentLength int)

OnContentLength .

func (*EmptyProcessor) OnHeader

func (p *EmptyProcessor) OnHeader(key, value string)

OnHeader .

func (*EmptyProcessor) OnMethod

func (p *EmptyProcessor) OnMethod(method string)

OnMethod .

func (*EmptyProcessor) OnProto

func (p *EmptyProcessor) OnProto(proto string) error

OnProto .

func (*EmptyProcessor) OnStatus

func (p *EmptyProcessor) OnStatus(code int, status string)

OnStatus .

func (*EmptyProcessor) OnTrailerHeader

func (p *EmptyProcessor) OnTrailerHeader(key, value string)

OnTrailerHeader .

func (*EmptyProcessor) OnURL

func (p *EmptyProcessor) OnURL(uri string) error

OnURL .

func (*EmptyProcessor) WriteTo

func (p *EmptyProcessor) WriteTo(w io.Writer, data []byte) (int, error)

WriteTo .

type Parser

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

Parser .

func NewParser

func NewParser(conn net.Conn, processor Processor, isClient bool, maxReadSize int) *Parser

NewParser .

func (*Parser) Read

func (p *Parser) Read(data []byte) error

Read .

func (*Parser) Session

func (p *Parser) Session() interface{}

Session returns user session

func (*Parser) SetSession

func (p *Parser) SetSession(session interface{})

SetSession sets user session

type Processor

type Processor interface {
	OnMethod(method string)
	OnURL(uri string) error
	OnProto(proto string) error
	OnStatus(code int, status string)
	OnHeader(key, value string)
	OnContentLength(contentLength int)
	OnBody([]byte)
	OnTrailerHeader(key, value string)
	OnComplete(conn net.Conn)
	WriteTo(w io.Writer, data []byte) (int, error)
}

Processor .

func NewClientProcessor

func NewClientProcessor(handler func(*http.Response)) Processor

NewClientProcessor .

func NewEmptyProcessor

func NewEmptyProcessor() Processor

NewEmptyProcessor .

func NewServerProcessor

func NewServerProcessor(handler http.Handler) Processor

NewServerProcessor .

type Response

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

Response represents the server side of an HTTP response. todo:

func (*Response) Header

func (response *Response) Header() http.Header

Header .

func (*Response) Write

func (response *Response) Write(data []byte) (int, error)

Write .

func (*Response) WriteHeader

func (response *Response) WriteHeader(statusCode int)

WriteHeader .

type ServerProcessor

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

ServerProcessor .

func (*ServerProcessor) HandleMessage

func (p *ServerProcessor) HandleMessage(handler http.Handler)

HandleMessage .

func (*ServerProcessor) OnBody

func (p *ServerProcessor) OnBody(data []byte)

OnBody .

func (*ServerProcessor) OnComplete

func (p *ServerProcessor) OnComplete(conn net.Conn)

OnComplete .

func (*ServerProcessor) OnContentLength

func (p *ServerProcessor) OnContentLength(contentLength int)

OnContentLength .

func (*ServerProcessor) OnHeader

func (p *ServerProcessor) OnHeader(key, value string)

OnHeader .

func (*ServerProcessor) OnMethod

func (p *ServerProcessor) OnMethod(method string)

OnMethod .

func (*ServerProcessor) OnProto

func (p *ServerProcessor) OnProto(proto string) error

OnProto .

func (*ServerProcessor) OnStatus

func (p *ServerProcessor) OnStatus(code int, status string)

OnStatus .

func (*ServerProcessor) OnTrailerHeader

func (p *ServerProcessor) OnTrailerHeader(key, value string)

OnTrailerHeader .

func (*ServerProcessor) OnURL

func (p *ServerProcessor) OnURL(uri string) error

OnURL .

func (*ServerProcessor) WriteTo

func (p *ServerProcessor) WriteTo(w io.Writer, data []byte) (int, error)

WriteTo .

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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