ihttp

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: GPL-3.0 Imports: 14 Imported by: 3 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	ProxyClient proxyclient.Dial
}

type Request

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

func BuildRequest

func BuildRequest(ctx context.Context, clientType int, base, path, host, method string) (*Request, error)

func BuildRequestWithBody

func BuildRequestWithBody(ctx context.Context, clientType int, base, path, host, method string, body []byte) (*Request, error)

func (*Request) Host

func (r *Request) Host() string

func (*Request) SetHeader

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

func (*Request) SetHeaders added in v1.2.0

func (r *Request) SetHeaders(header http.Header, RandomUA bool)

func (*Request) URI

func (r *Request) URI() string

type RequestConfig

type RequestConfig struct {
	Method          string
	Headers         http.Header
	Host            string
	Path            string
	Body            []byte
	RawQuery        string
	RandomUserAgent bool
}

RequestConfig 封装HTTP请求相关的配置参数

func (*RequestConfig) Build

func (rc *RequestConfig) Build(ctx context.Context, clientType int, base, path, host string) (*Request, error)

Build 根据配置构建Request对象

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