httpclient

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(proxyConfig *config.ProxyConfig, timeout time.Duration) (*http.Client, error)

NewHTTPClient creates a standard http.Client with proxy support

func NewRestyClient

func NewRestyClient(proxyConfig *config.ProxyConfig, timeout time.Duration, retries int) (*resty.Client, error)

NewRestyClient creates a resty.Client with proxy support

func NewRestyClientNoProxy

func NewRestyClientNoProxy(timeout time.Duration, retries int) *resty.Client

NewRestyClientNoProxy creates a resty.Client that explicitly bypasses environment proxy variables by using a no-proxy transport.

func NewTransport

func NewTransport(proxyConfig *config.ProxyConfig) (*http.Transport, error)

NewTransport creates an http.Transport with optional proxy support

func SanitizeProxyURL

func SanitizeProxyURL(proxyURL string) string

SanitizeProxyURL removes credentials from proxy URL for safe logging

Types

type FlareSolverr

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

FlareSolverr represents the FlareSolverr client

func GetFlareSolverrFromClient

func GetFlareSolverrFromClient(client *resty.Client) (*FlareSolverr, bool)

GetFlareSolverrFromClient extracts FlareSolverr instance from resty client context Note: This is a helper for scrapers that need to access FlareSolverr The FlareSolverr instance is typically stored separately and passed to scrapers

func NewFlareSolverr

func NewFlareSolverr(cfg *config.FlareSolverrConfig) (*FlareSolverr, error)

NewFlareSolverr creates a new FlareSolverr client

func NewRestyClientWithFlareSolverr

func NewRestyClientWithFlareSolverr(proxyConfig *config.ProxyConfig, timeout time.Duration, retries int) (*resty.Client, *FlareSolverr, error)

NewRestyClientWithFlareSolverr creates a resty.Client with optional FlareSolverr support

func (*FlareSolverr) CreateSession

func (fs *FlareSolverr) CreateSession() (string, error)

CreateSession creates a new FlareSolverr session for cookie persistence

func (*FlareSolverr) DestroySession

func (fs *FlareSolverr) DestroySession(sessionID string) error

DestroySession destroys a FlareSolverr session

func (*FlareSolverr) ResolveURL

func (fs *FlareSolverr) ResolveURL(targetURL string) (string, []http.Cookie, error)

ResolveURL resolves a URL through FlareSolverr, returning HTML content and cookies

func (*FlareSolverr) ResolveURLWithSession

func (fs *FlareSolverr) ResolveURLWithSession(targetURL, sessionID string) (string, []http.Cookie, error)

ResolveURLWithSession resolves a URL using a specific session

type FlareSolverrProxy

type FlareSolverrProxy struct {
	URL      string `json:"url"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

FlareSolverrProxy represents a per-request proxy configuration passed to FlareSolverr. This is used for the target URL request made by FlareSolverr, not for calls to FlareSolverr itself.

type FlareSolverrRequest

type FlareSolverrRequest struct {
	Cmd               string             `json:"cmd"`                           // "request.get" or "sessions.create"
	URL               string             `json:"url"`                           // Target URL
	MaxTimeout        int                `json:"maxTimeout"`                    // Timeout in milliseconds (FlareSolverr expects ms)
	Session           string             `json:"session"`                       // Optional: reuse existing session
	SessionTTLMinutes int                `json:"session_ttl_minutes,omitempty"` // Optional: rotate existing session when older than TTL
	Proxy             *FlareSolverrProxy `json:"proxy,omitempty"`               // Optional: proxy for target URL request
}

FlareSolverrRequest represents a request to FlareSolverr

type FlareSolverrResponse

type FlareSolverrResponse struct {
	Status   string `json:"status"`
	Message  string `json:"message"`
	Solution struct {
		Response string `json:"response"`
		Cookies  []struct {
			Name  string `json:"name"`
			Value string `json:"value"`
		} `json:"cookies"`
		UserAgent string `json:"userAgent"`
	} `json:"solution"`
	Session string `json:"session"`
}

FlareSolverrResponse represents a FlareSolverr response

type FlareSolverrSession

type FlareSolverrSession struct {
	Token   string
	Created time.Time
	URLs    []string
}

FlareSolverrSession represents a FlareSolverr session

type HTTPClient

type HTTPClient interface {
	// Do executes an HTTP request and returns the response
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient defines the interface for HTTP operations This allows for easy mocking in tests

Jump to

Keyboard shortcuts

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