ihttp

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Auto = iota
	FAST
	STANDARD
)

Variables

View Source
var (
	DefaultMaxBodySize int64 = 1024 * 100 // 100k
)

Functions

func CheckBodySize added in v0.9.6

func CheckBodySize(size int64) bool

Types

type Client

type Client struct {
	Config *ClientConfig
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *Request) (*Response, error)

func (*Client) FastDo

func (c *Client) FastDo(ctx context.Context, req *fasthttp.Request) (*fasthttp.Response, error)

func (*Client) StandardDo

func (c *Client) StandardDo(ctx context.Context, req *http.Request) (*http.Response, error)

func (*Client) TransToCheck

func (c *Client) TransToCheck()

type ClientConfig

type ClientConfig struct {
	Type      int
	Timeout   time.Duration
	Thread    int
	ProxyAddr string
}

type Request

type Request struct {
	StandardRequest *http.Request
	FastRequest     *fasthttp.Request
	ClientType      int
}

func BuildHostRequest

func BuildHostRequest(clientType int, base, host string) (*Request, error)

func BuildPathRequest

func BuildPathRequest(clientType int, base, path string) (*Request, error)

func (*Request) Host

func (r *Request) Host() string

func (*Request) SetHeader

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

func (*Request) SetHeaders

func (r *Request) SetHeaders(header map[string]string)

func (*Request) URI

func (r *Request) URI() string

type Response

type Response struct {
	StandardResponse *http.Response
	FastResponse     *fasthttp.Response
	ClientType       int
}

func (*Response) Body

func (r *Response) Body() []byte

func (*Response) ContentLength

func (r *Response) ContentLength() int64

func (*Response) ContentType

func (r *Response) ContentType() string

func (*Response) GetHeader

func (r *Response) GetHeader(key string) string

func (*Response) Header

func (r *Response) Header() []byte

func (*Response) StatusCode

func (r *Response) StatusCode() int

Jump to

Keyboard shortcuts

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