ihttp

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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

func CheckBodySize(size int64) bool

Types

type Client

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

func NewClient

func NewClient(config *ClientConfig) *Client

func (*Client) Do

func (c *Client) Do(req *Request) (*Response, error)

func (*Client) FastDo

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

func (*Client) StandardDo

func (c *Client) StandardDo(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 BuildRequest added in v1.1.1

func BuildRequest(ctx context.Context, clientType int, base, path, host, method 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