Documentation
¶
Index ¶
- func NormalizeURL(url string) string
- func SplitLines(data []byte) []string
- type Config
- type HTTPClientManager
- func (h *HTTPClientManager) EnableKeepAlives(maxConnsPerHost int)
- func (h *HTTPClientManager) Get(url string) (string, error)
- func (h *HTTPClientManager) GetPartialWithContext(ctx context.Context, url string, maxBytes int) (string, error)
- func (h *HTTPClientManager) GetStatusAndBody(ctx context.Context, url string) (int, string, error)
- func (h *HTTPClientManager) GetWithContext(ctx context.Context, url string) (string, error)
- func (h *HTTPClientManager) HeadWithContext(ctx context.Context, url string) (int, error)
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeURL ¶
func SplitLines ¶
Types ¶
type Config ¶ added in v0.10.13
type Config struct {
Headers []string
Proxy string
RateLimit int // Requests per second (0 = unlimited)
MaxRedirects int // Maximum redirects to follow (0 = disable, -1 = default: 10)
ExternalClient *stdhttp.Client // External HTTP client (optional, for connection pooling)
}
Config contains HTTP-related configuration for making requests.
type HTTPClientManager ¶
type HTTPClientManager struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClientFromExternal ¶ added in v0.10.10
func NewHTTPClientFromExternal(externalClient *http.Client, headers []string, rps int) *HTTPClientManager
NewHTTPClientFromExternal wraps an external http.Client (e.g., from a connection pool). This allows reusing an existing client instead of creating a new one. The external client is used as-is; headers and rate limiting are still applied.
func (*HTTPClientManager) EnableKeepAlives ¶ added in v0.10.13
func (h *HTTPClientManager) EnableKeepAlives(maxConnsPerHost int)
EnableKeepAlives enables HTTP connection reuse. Use this when making many requests to the same host (e.g. bruteforce scanning).
func (*HTTPClientManager) GetPartialWithContext ¶ added in v0.11.0
func (h *HTTPClientManager) GetPartialWithContext(ctx context.Context, url string, maxBytes int) (string, error)
GetPartialWithContext sends a GET request and reads at most maxBytes of the response body. Useful for fetching just the header portion of large files (e.g. CSS theme version).
func (*HTTPClientManager) GetStatusAndBody ¶ added in v0.10.14
GetStatusAndBody sends a GET request and returns both the status code and body. Unlike GetWithContext, it does not treat non-2xx responses as errors.
func (*HTTPClientManager) GetWithContext ¶ added in v0.10.0
func (*HTTPClientManager) HeadWithContext ¶ added in v0.10.13
HeadWithContext sends a HEAD request and returns the HTTP status code. No body is read. Useful for fast existence checks (e.g. 403 vs 404).
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a token bucket rate limiter.
func NewRateLimiter ¶
func NewRateLimiter(rps int) *RateLimiter
NewRateLimiter creates a new rate limiter with the specified requests per second. If rps is 0 or negative, returns nil (no rate limiting).
func (*RateLimiter) Wait ¶
func (rl *RateLimiter) Wait()
Wait blocks until a token is available. If the rate limiter is nil (disabled), returns immediately.