http

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect added in v0.1.0

func Connect(addr string, isHttps bool, timeout int) *net.Conn

Types

type HeaderKV

type HeaderKV struct {
	Key   []byte
	Value []byte
}

type Request

type Request struct {
	Method   string
	Metadata []string

	RequestLine []byte
	Headers     []*HeaderKV
	Body        []byte
	// contains filtered or unexported fields
}

func (*Request) AddHeader

func (r *Request) AddHeader(key string, value string)

AddHeader add a header key value

func (*Request) CalculateContentLength

func (r *Request) CalculateContentLength()

CalculateContentLength calculate body and set right Content-Length header, remove unnecessary content-length.

func (*Request) Dump

func (r *Request) Dump() string

func (*Request) GetHeader

func (r *Request) GetHeader(key string) (value string)

GetHeader get the first key value

func (*Request) GetHeaders

func (r *Request) GetHeaders(key string) (values []string)

GetHeaders get all key's value

func (*Request) Len

func (r *Request) Len() int

Len implements the Request buffer length method.

func (*Request) Parse

func (r *Request) Parse(b []byte) (int, error)

Parse implements the Request Parse method.

func (*Request) Read

func (r *Request) Read(b []byte) (int, error)

Read implements the Request Read method.

func (*Request) ReadFile

func (r *Request) ReadFile(file string) error

func (*Request) ReadFileFromFS added in v0.1.0

func (r *Request) ReadFileFromFS(fs embed.FS, file string) error

func (*Request) ReadFrom

func (r *Request) ReadFrom(in io.Reader) (int64, error)

ReadFrom implements the Request ReadFrom method.

func (*Request) SetHeader

func (r *Request) SetHeader(key string, value string)

SetHeader set the header key with value

func (*Request) SetHost

func (r *Request) SetHost(host string)

SetHost set Host header to the target host, remove unnecessary hosts.

func (*Request) String

func (r *Request) String() string

String implements the Request String method.

func (*Request) Write

func (r *Request) Write(b []byte) (int, error)

Read implements the Request Read method.

func (*Request) WriteTo

func (r *Request) WriteTo(w io.Writer) (int64, error)

WriteTo implements the Request WriteTo method.

type Response

type Response struct {
	Version string

	StatusCode []byte
	Reason     []byte
	StatusLine []byte
	Headers    []*HeaderKV
	Body       []byte
	// contains filtered or unexported fields
}

func (*Response) Close

func (r *Response) Close() error

Close implements the Response Read method.

func (*Response) GetStatusCode

func (r *Response) GetStatusCode() int

func (*Response) Len

func (r *Response) Len() int

Len implements the Response buffer length method.

func (*Response) Parse

func (r *Response) Parse(b []byte) (int, error)

Parse implements the Response Parse method.

func (*Response) Read

func (r *Response) Read(b []byte) (int, error)

Read implements the Response Read method.

func (*Response) ReadConn

func (r *Response) ReadConn(conn net.Conn) (err error)

func (*Response) ReadFrom

func (r *Response) ReadFrom(in io.Reader) (int64, error)

ReadFrom implements the Response ReadFrom method.

func (*Response) String

func (r *Response) String() string

String implements the Response String method.

func (*Response) Write

func (r *Response) Write(b []byte) (int, error)

Read implements the Response Read method.

func (*Response) WriteTo

func (r *Response) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements the Response WriteTo method.

Jump to

Keyboard shortcuts

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