Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateHeaders ¶
func GenerateMobileAgent ¶
func GenerateMobileAgent() string
func GeneratePcAgent ¶
func GeneratePcAgent() string
Types ¶
type Response ¶
type Session ¶
func CreateSession ¶
func (*Session) SendReq ¶
func (session *Session) SendReq(url, method string, timeout time.Duration, dataStr ...string) *Response
SendReq sends an HTTP request without retry logic. This function allows specifying the HTTP method, timeout duration, and optional request body data.
Parameters: - url: The target URL for the request. - method: The HTTP method to use (e.g., GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE). - timeout: The maximum duration for the request context (e.g., 30 * time.Second). - dataStr: (Optional) A string to be sent as the request body, if provided.
Returns: A pointer to a Response struct containing the result of the request, including any errors.
func (*Session) SendReqWithRetry ¶ added in v1.1.0
func (session *Session) SendReqWithRetry(url, method string, timeout time.Duration, retryCount int, retryDelay time.Duration, dataStr ...string) *Response
SendReqWithRetry sends an HTTP request with retry logic. This function allows specifying the HTTP method, timeout duration, number of retries, delay between retries, and optional request body data.
Parameters: - url: The target URL for the request. - method: The HTTP method to use (e.g., GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE). - timeout: The maximum duration for the one request context (e.g., 30 * time.Second). - retryCount: The number of retry attempts if the request fails. - retryDelay: The duration to wait between retries (e.g., 2 * time.Second). - dataStr: (Optional) A string to be sent as the request body, if provided.
Returns: A pointer to a Response struct containing the result of the request, including any errors.