Documentation ¶
Index ¶
- Constants
- Variables
- func DefineStatusLine(status int, statusText string)
- func GetBuffer() *[]byte
- func GetStatusLine(status int) []byte
- func ParseContentLength(src []byte) (int64, error)
- func ParseHeaderLine(src []byte) (name []byte, value []byte)
- func ParseHeaders(dst *Request, src []byte) (next []byte, err error)
- func ParseRequest(dst *Request, r io.Reader) (next []byte, err error)
- func ParseRequestLine(dst *Request, src []byte) (next []byte, err error)
- func PutBodyReader(r *BodyReader)
- func PutBuffer(b *[]byte)
- func PutRequest(r *Request)
- func PutResponse(r *Response)
- type BodyReader
- type FastDateServer
- type Header
- type HijackReader
- type Method
- type Query
- type Request
- type RequestReader
- type Response
- func (r *Response) Flush() error
- func (r *Response) Reset()
- func (r *Response) Write(b []byte) (int, error)
- func (r *Response) WriteHeader(status int) error
- func (r *Response) WriteInt(i int) (int, error)
- func (r *Response) WriteInt64(i int64) (int, error)
- func (r *Response) WriteStatusLine(status int) error
- func (r *Response) WriteString(b string) (int, error)
- func (r *Response) WriteUint(u uint) (int, error)
- func (r *Response) WriteUint64(u uint64) (int, error)
- func (r *Response) WriteUint64Hex(u uint64) (int, error)
- type Status
- type URI
Constants ¶
View Source
const BufferPoolSize = 4096
Variables ¶
View Source
var BodyReaderPool = &sync.Pool{ New: func() any { return &BodyReader{} }, }
View Source
var ContentLengthHeader = []byte("Content-Length")
View Source
var DateServerHeaderFunc = func() []byte { return DefaultFastDateServer.GetDate() }
View Source
var DefaultFastDateServer = NewFastDateServer("h1")
View Source
var ErrBufferTooSmall = errors.New("buffer too small")
View Source
var ErrInvalidMethod = errors.New("invalid method")
View Source
var ErrInvalidURI = errors.New("invalid uri")
View Source
var ErrInvalidVersion = errors.New("invalid version")
View Source
var ErrKeyNotFound = errors.New("key not found")
View Source
var ErrRequestHeaderTooLarge = errors.New("request header too large")
Functions ¶
func DefineStatusLine ¶ added in v1.2.0
func GetStatusLine ¶
func ParseContentLength ¶
func ParseHeaderLine ¶
func ParseRequest ¶
Do not use this function in production code. This function is only for testing purpose.
func PutBodyReader ¶
func PutBodyReader(r *BodyReader)
func PutRequest ¶
func PutRequest(r *Request)
func PutResponse ¶
func PutResponse(r *Response)
Types ¶
type BodyReader ¶
type BodyReader struct { Upstream *RequestReader Limit int Index int }
func GetBodyReader ¶
func GetBodyReader() *BodyReader
func (*BodyReader) Close ¶
func (r *BodyReader) Close() error
type FastDateServer ¶
type FastDateServer struct {
// contains filtered or unexported fields
}
func NewFastDateServer ¶
func NewFastDateServer(serverName string) *FastDateServer
func (*FastDateServer) GetDate ¶
func (fds *FastDateServer) GetDate() []byte
func (*FastDateServer) Start ¶
func (fds *FastDateServer) Start()
func (*FastDateServer) Stop ¶
func (fds *FastDateServer) Stop()
type HijackReader ¶
type HijackReader struct {
Upstream *RequestReader
}
type Method ¶
type Method uint8
const ( MethodInvalid Method = iota MethodGET MethodHEAD MethodPOST MethodPUT MethodDELETE MethodCONNECT MethodOPTIONS MethodTRACE MethodPATCH MethodBREW // HTCPCP/1.0 (https://datatracker.ietf.org/doc/html/rfc2324) )
type Query ¶
func ParseRawQuery ¶
type Request ¶
type Request struct { // Request line Method Method RawURI []byte Version []byte // Headers Headers []Header // Parsed URI URI URI ContentLength int64 }
func GetRequest ¶
func GetRequest() *Request
type RequestReader ¶
func (*RequestReader) Body ¶
func (r *RequestReader) Body() *BodyReader
func (*RequestReader) Fill ¶
func (r *RequestReader) Fill() (n int, err error)
func (*RequestReader) Hijack ¶
func (r *RequestReader) Hijack() HijackReader
func (*RequestReader) Next ¶
func (r *RequestReader) Next() (remaining int, err error)
func (*RequestReader) Remaining ¶
func (r *RequestReader) Remaining() int
func (*RequestReader) Reset ¶
func (r *RequestReader) Reset()
type Response ¶
type Response struct { // Standard Hop-by-Hop response headers. ContentLength int // contains filtered or unexported fields }
func GetResponse ¶
func (*Response) WriteHeader ¶
func (*Response) WriteStatusLine ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.