httpclient

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CF_ACCESS_DENIED_TITLES = []string{
	"Access denied",
	"Attention Required! | Cloudflare",
}

"Access denied", "Attention Required! | Cloudflare"

View Source
var CF_CHALLENGE_TITLES = []string{
	"Just a moment...",
	"DDoS-Guard",
}

"Just a moment...", "DDoS-Guard"

Functions

func CloseHost

func CloseHost(urlStr string)

func FetchJson

func FetchJson(url string, v any, useFlareSolverr bool) error

func FetchUrl

func FetchUrl(url string, header http.Header, useFlareSolverr bool) (*azuretls.Response, error)

func HttpRequest

func HttpRequest(req *azuretls.Request, useFlareSolverr bool) (
	res *azuretls.Response, err error)

func Init

func Init()

func IsLocalUrl

func IsLocalUrl(urlObj *url.URL) bool

func PostAndFetchJson

func PostAndFetchJson(url string, reqBody any, resBody any, useFlareSolverr bool) (err error)

func SaveUrl

func SaveUrl(fileUrl string, filename string, addext bool, useFlareSolverr bool) (
	createdfile string, ext string, err error)

If addext is true, the ext of fileUrl will be appended to filename. The ext of fileUrl is guessed from response content-type and / or fileUrl path. Return created filename and ext of fileUrl.

Types

type FlaresolverrApiRequest

type FlaresolverrApiRequest struct {
	Cmd               string `json:"cmd,omitempty"`
	Url               string `json:"url,omitempty"`
	MaxTimeout        int    `json:"maxTimeout,omitempty"`
	ReturnOnlyCookies bool   `json:"returnOnlyCookies,omitempty"`
}

type FlaresolverrApiResponse

type FlaresolverrApiResponse struct {
	Status   string            `json:"status,omitempty"`  // "ok"
	Message  string            `json:"message,omitempty"` // "Challenge solved!"
	Solution *FlaresolverrData `json:"solution,omitempty"`
}

type FlaresolverrApiResponseCookie

type FlaresolverrApiResponseCookie struct {
	Name    string
	Value   string
	Domain  string
	Path    string
	Expires int64
}

type FlaresolverrData

type FlaresolverrData struct {
	Url       string                           `json:"url,omitempty"`
	Headers   map[string]string                `json:"headers,omitempty"`
	Status    int                              `json:"status,omitempty"`
	UserAgent string                           `json:"userAgent,omitempty"`
	Response  string                           `json:"response,omitempty"`
	Cookies   []*FlaresolverrApiResponseCookie `json:"cookies,omitempty"`
}

"solution" field in flaresolverr API response

type FlaresolverrReq

type FlaresolverrReq struct {
	Client       *azuretls.Session
	Req          *azuretls.Request
	Flaresolverr string
}

Jump to

Keyboard shortcuts

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