http

package
v0.0.0-...-b765225 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CRLF is the line ending in HTTP header
	CRLF = "\r\n"

	// ENDING is the double line ending between HTTP header and body.
	ENDING = CRLF + CRLF
)

Variables

View Source
var (
	ErrHeaderToLong = newError("Header too long.")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Settings for authenticating requests. If not set, client side will not send authenication header, and server side will bypass authentication.
	Request *RequestConfig `protobuf:"bytes,1,opt,name=request" json:"request,omitempty"`
	// Settings for authenticating responses. If not set, client side will bypass authentication, and server side will not send authentication header.
	Response *ResponseConfig `protobuf:"bytes,2,opt,name=response" json:"response,omitempty"`
}

func (*Config) Descriptor

func (*Config) Descriptor() ([]byte, []int)

func (*Config) GetRequest

func (m *Config) GetRequest() *RequestConfig

func (*Config) GetResponse

func (m *Config) GetResponse() *ResponseConfig

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (m *Config) Reset()

func (*Config) String

func (m *Config) String() string
type Header struct {
	// "Accept", "Cookie", etc
	Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
	// Each entry must be valid in one piece. Random entry will be chosen if multiple entries present.
	Value []string `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"`
}

func (*Header) Descriptor

func (*Header) Descriptor() ([]byte, []int)

func (*Header) GetName

func (m *Header) GetName() string

func (*Header) GetValue

func (m *Header) GetValue() []string

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) Reset

func (m *Header) Reset()

func (*Header) String

func (m *Header) String() string

type HeaderReader

type HeaderReader struct {
}

func (*HeaderReader) Read

func (*HeaderReader) Read(reader io.Reader) (*buf.Buffer, error)

type HeaderWriter

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

func NewHeaderWriter

func NewHeaderWriter(header *buf.Buffer) *HeaderWriter

func (*HeaderWriter) Write

func (w *HeaderWriter) Write(writer io.Writer) error

type HttpAuthenticator

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

func NewHttpAuthenticator

func NewHttpAuthenticator(ctx context.Context, config *Config) (HttpAuthenticator, error)

func (HttpAuthenticator) Client

func (a HttpAuthenticator) Client(conn net.Conn) net.Conn

func (HttpAuthenticator) GetClientWriter

func (a HttpAuthenticator) GetClientWriter() *HeaderWriter

func (HttpAuthenticator) GetServerWriter

func (a HttpAuthenticator) GetServerWriter() *HeaderWriter

func (HttpAuthenticator) Server

func (a HttpAuthenticator) Server(conn net.Conn) net.Conn

type HttpConn

type HttpConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewHttpConn

func NewHttpConn(conn net.Conn, reader Reader, writer Writer, errorWriter Writer) *HttpConn

func (*HttpConn) Close

func (c *HttpConn) Close() error

Close implements net.Conn.Close().

func (*HttpConn) Read

func (c *HttpConn) Read(b []byte) (int, error)

func (*HttpConn) Write

func (c *HttpConn) Write(b []byte) (int, error)

Write implements io.Writer.

type Method

type Method struct {
	Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}

HTTP method. Default value "GET".

func (*Method) Descriptor

func (*Method) Descriptor() ([]byte, []int)

func (*Method) GetValue

func (m *Method) GetValue() string

func (*Method) ProtoMessage

func (*Method) ProtoMessage()

func (*Method) Reset

func (m *Method) Reset()

func (*Method) String

func (m *Method) String() string

type NoOpReader

type NoOpReader struct{}

func (NoOpReader) Read

func (NoOpReader) Read(io.Reader) (*buf.Buffer, error)

type NoOpWriter

type NoOpWriter struct{}

func (NoOpWriter) Write

func (NoOpWriter) Write(io.Writer) error

type Reader

type Reader interface {
	Read(io.Reader) (*buf.Buffer, error)
}

type RequestConfig

type RequestConfig struct {
	// Full HTTP version like "1.1".
	Version *Version `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
	// GET, POST, CONNECT etc
	Method *Method `protobuf:"bytes,2,opt,name=method" json:"method,omitempty"`
	// URI like "/login.php"
	Uri    []string  `protobuf:"bytes,3,rep,name=uri" json:"uri,omitempty"`
	Header []*Header `protobuf:"bytes,4,rep,name=header" json:"header,omitempty"`
}

func (*RequestConfig) Descriptor

func (*RequestConfig) Descriptor() ([]byte, []int)

func (*RequestConfig) GetFullVersion

func (v *RequestConfig) GetFullVersion() string

func (*RequestConfig) GetHeader

func (m *RequestConfig) GetHeader() []*Header

func (*RequestConfig) GetMethod

func (m *RequestConfig) GetMethod() *Method

func (*RequestConfig) GetMethodValue

func (v *RequestConfig) GetMethodValue() string

func (*RequestConfig) GetUri

func (m *RequestConfig) GetUri() []string

func (*RequestConfig) GetVersion

func (m *RequestConfig) GetVersion() *Version

func (*RequestConfig) GetVersionValue

func (v *RequestConfig) GetVersionValue() string

func (*RequestConfig) PickHeaders

func (v *RequestConfig) PickHeaders() []string

func (*RequestConfig) PickUri

func (v *RequestConfig) PickUri() string

func (*RequestConfig) ProtoMessage

func (*RequestConfig) ProtoMessage()

func (*RequestConfig) Reset

func (m *RequestConfig) Reset()

func (*RequestConfig) String

func (m *RequestConfig) String() string

type ResponseConfig

type ResponseConfig struct {
	Version *Version  `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
	Status  *Status   `protobuf:"bytes,2,opt,name=status" json:"status,omitempty"`
	Header  []*Header `protobuf:"bytes,3,rep,name=header" json:"header,omitempty"`
}

func (*ResponseConfig) Descriptor

func (*ResponseConfig) Descriptor() ([]byte, []int)

func (*ResponseConfig) GetFullVersion

func (v *ResponseConfig) GetFullVersion() string

func (*ResponseConfig) GetHeader

func (m *ResponseConfig) GetHeader() []*Header

func (*ResponseConfig) GetStatus

func (m *ResponseConfig) GetStatus() *Status

func (*ResponseConfig) GetStatusValue

func (v *ResponseConfig) GetStatusValue() *Status

func (*ResponseConfig) GetVersion

func (m *ResponseConfig) GetVersion() *Version

func (*ResponseConfig) GetVersionValue

func (v *ResponseConfig) GetVersionValue() string

func (*ResponseConfig) HasHeader

func (v *ResponseConfig) HasHeader(header string) bool

func (*ResponseConfig) PickHeaders

func (v *ResponseConfig) PickHeaders() []string

func (*ResponseConfig) ProtoMessage

func (*ResponseConfig) ProtoMessage()

func (*ResponseConfig) Reset

func (m *ResponseConfig) Reset()

func (*ResponseConfig) String

func (m *ResponseConfig) String() string

type Status

type Status struct {
	// Status code. Default "200".
	Code string `protobuf:"bytes,1,opt,name=code" json:"code,omitempty"`
	// Statue reason. Default "OK".
	Reason string `protobuf:"bytes,2,opt,name=reason" json:"reason,omitempty"`
}

func (*Status) Descriptor

func (*Status) Descriptor() ([]byte, []int)

func (*Status) GetCode

func (m *Status) GetCode() string

func (*Status) GetReason

func (m *Status) GetReason() string

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) Reset

func (m *Status) Reset()

func (*Status) String

func (m *Status) String() string

type Version

type Version struct {
	Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}

HTTP version. Default value "1.1".

func (*Version) Descriptor

func (*Version) Descriptor() ([]byte, []int)

func (*Version) GetValue

func (m *Version) GetValue() string

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) Reset

func (m *Version) Reset()

func (*Version) String

func (m *Version) String() string

type Writer

type Writer interface {
	Write(io.Writer) error
}

Jump to

Keyboard shortcuts

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