http

package
v0.22.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = NewHttp(HttpDefaultConfig) // this won't be proxied
View Source
var HttpDefaultConfig = NewConfig(&HttpDefaultRateLimit, &HttpDefaultTlsVerification, &emptyStr)
View Source
var HttpDefaultRateLimit = 60
View Source
var HttpDefaultTlsVerification = true

Functions

func CreateProxiedDialer

func CreateProxiedDialer(proxyURL string) (fasthttp.DialFunc, error)

CreateDialer returns a dialer function based on the given proxy URL and type. returns non proxied dialer if empty string is passed.

func GetResponseHeaders

func GetResponseHeaders(resp *http.Response) map[string]string

func NewThrottledTransport

func NewThrottledTransport(limitPeriod time.Duration, requestCount int, transportWrap http.RoundTripper) http.RoundTripper

NewThrottledTransport wraps the provided transport with a rate limiter

func SetRequestBody

func SetRequestBody(body interface{}, req *http.Request) error

Types

type Config

type Config struct {
	HttpClient        *fasthttp.Client
	RequestsPerSecond *int
}

func NewConfig

func NewConfig(requestsPerSecond *int, skipTlsVerification *bool, proxy *string) *Config

type CustomClient

type CustomClient struct {
	Requests  []*client.Request
	Responses []*client.ConcurrentResponse
	Client    *http.Client
}

func NewConfigHttp2

func NewConfigHttp2(requestsPerSecond *int, skipTlsVerification *bool, proxy *string) *CustomClient

func (*CustomClient) Do

func (c *CustomClient) Do(uri string, method string, queryParams any, headers any, reqBody any) (*client.Response, error)

type Http

type Http struct {
	Requests  []*client.Request
	Responses []*client.ConcurrentResponse
	Config    *Config
	Client    *client.RateLimitedClient
}

func NewHttp

func NewHttp(config *Config) *Http

type ThrottledTransport

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

func (*ThrottledTransport) RoundTrip

func (c *ThrottledTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip method implements the rate limiting logic for HTTP requests

Jump to

Keyboard shortcuts

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