http

package
v0.0.0-...-0dee3c0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MPL-2.0 Imports: 17 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.")

	ErrHeaderMisMatch = newError("Header Mismatch.")
)
View Source
var File_transport_internet_headers_http_config_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(ctx context.Context, config *Config) (Authenticator, error)

func (Authenticator) Client

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

func (Authenticator) GetClientWriter

func (a Authenticator) GetClientWriter() *HeaderWriter

func (Authenticator) GetServerWriter

func (a Authenticator) GetServerWriter() *HeaderWriter

func (Authenticator) Server

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

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,proto3" 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,proto3" json:"response,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

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

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetRequest

func (x *Config) GetRequest() *RequestConfig

func (*Config) GetResponse

func (x *Config) GetResponse() *ResponseConfig

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type Conn

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

func NewConn

func NewConn(conn net.Conn, reader Reader, writer Writer, errorWriter Writer, errorMismatchWriter Writer, errorTooLongWriter Writer) *Conn

func (*Conn) Close

func (c *Conn) Close() error

Close implements net.Conn.Close().

func (*Conn) Read

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

func (*Conn) Write

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

Write implements io.Writer.

type Header struct {

	// "Accept", "Cookie", etc
	Name string `protobuf:"bytes,1,opt,name=name,proto3" 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,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*Header) Descriptor deprecated

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

Deprecated: Use Header.ProtoReflect.Descriptor instead.

func (*Header) GetName

func (x *Header) GetName() string

func (*Header) GetValue

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

func (*Header) ProtoMessage

func (*Header) ProtoMessage()

func (*Header) ProtoReflect

func (x *Header) ProtoReflect() protoreflect.Message

func (*Header) Reset

func (x *Header) Reset()

func (*Header) String

func (x *Header) String() string

type HeaderReader

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

func (*HeaderReader) ExpectThisRequest

func (h *HeaderReader) ExpectThisRequest(expectedHeader *RequestConfig) *HeaderReader

func (*HeaderReader) Read

func (h *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 Method

type Method struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

HTTP method. Default value "GET".

func (*Method) Descriptor deprecated

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

Deprecated: Use Method.ProtoReflect.Descriptor instead.

func (*Method) GetValue

func (x *Method) GetValue() string

func (*Method) ProtoMessage

func (*Method) ProtoMessage()

func (*Method) ProtoReflect

func (x *Method) ProtoReflect() protoreflect.Message

func (*Method) Reset

func (x *Method) Reset()

func (*Method) String

func (x *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,proto3" json:"version,omitempty"`
	// GET, POST, CONNECT etc
	Method *Method `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
	// URI like "/login.php"
	Uri    []string  `protobuf:"bytes,3,rep,name=uri,proto3" json:"uri,omitempty"`
	Header []*Header `protobuf:"bytes,4,rep,name=header,proto3" json:"header,omitempty"`
	// contains filtered or unexported fields
}

func (*RequestConfig) Descriptor deprecated

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

Deprecated: Use RequestConfig.ProtoReflect.Descriptor instead.

func (*RequestConfig) GetFullVersion

func (v *RequestConfig) GetFullVersion() string

func (*RequestConfig) GetHeader

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

func (*RequestConfig) GetMethod

func (x *RequestConfig) GetMethod() *Method

func (*RequestConfig) GetMethodValue

func (v *RequestConfig) GetMethodValue() string

func (*RequestConfig) GetUri

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

func (*RequestConfig) GetVersion

func (x *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) ProtoReflect

func (x *RequestConfig) ProtoReflect() protoreflect.Message

func (*RequestConfig) Reset

func (x *RequestConfig) Reset()

func (*RequestConfig) String

func (x *RequestConfig) String() string

type ResponseConfig

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

func (*ResponseConfig) Descriptor deprecated

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

Deprecated: Use ResponseConfig.ProtoReflect.Descriptor instead.

func (*ResponseConfig) GetFullVersion

func (v *ResponseConfig) GetFullVersion() string

func (*ResponseConfig) GetHeader

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

func (*ResponseConfig) GetStatus

func (x *ResponseConfig) GetStatus() *Status

func (*ResponseConfig) GetStatusValue

func (v *ResponseConfig) GetStatusValue() *Status

func (*ResponseConfig) GetVersion

func (x *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) ProtoReflect

func (x *ResponseConfig) ProtoReflect() protoreflect.Message

func (*ResponseConfig) Reset

func (x *ResponseConfig) Reset()

func (*ResponseConfig) String

func (x *ResponseConfig) String() string

type Status

type Status struct {

	// Status code. Default "200".
	Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
	// Statue reason. Default "OK".
	Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"`
	// contains filtered or unexported fields
}

func (*Status) Descriptor deprecated

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

Deprecated: Use Status.ProtoReflect.Descriptor instead.

func (*Status) GetCode

func (x *Status) GetCode() string

func (*Status) GetReason

func (x *Status) GetReason() string

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) ProtoReflect

func (x *Status) ProtoReflect() protoreflect.Message

func (*Status) Reset

func (x *Status) Reset()

func (*Status) String

func (x *Status) String() string

type Version

type Version struct {
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

HTTP version. Default value "1.1".

func (*Version) Descriptor deprecated

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

Deprecated: Use Version.ProtoReflect.Descriptor instead.

func (*Version) GetValue

func (x *Version) GetValue() string

func (*Version) ProtoMessage

func (*Version) ProtoMessage()

func (*Version) ProtoReflect

func (x *Version) ProtoReflect() protoreflect.Message

func (*Version) Reset

func (x *Version) Reset()

func (*Version) String

func (x *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