Categorygithub.com/projectdiscovery/retryablehttp-go
modulepackage
1.0.105
Repository: https://github.com/projectdiscovery/retryablehttp-go.git
Documentation: pkg.go.dev

# README

retryablehttp

Heavily inspired from https://github.com/hashicorp/go-retryablehttp.

Usage

Example of using retryablehttp in Go Code is available in examples folder Examples of using Nuclei From Go Code to run templates on targets are provided in the examples folder.

url encoding and parsing issues

retryablehttp.Request by default handles some url encoding and parameters issues. since http.Request internally uses url.Parse() to parse url specified in request it creates some inconsistencies for below urls and other non-RFC compilant urls

// below urls are either normalized or returns error when used in `http.NewRequest()`
https://scanme.sh/%invalid
https://scanme.sh/w%0d%2e/
scanme.sh/with/path?some'param=`'+OR+ORDER+BY+1--

All above mentioned cases are handled internally in retryablehttp.

Note

It is not recommended to update url.URL instance of Request once a new request is created (ex req.URL.Path = xyz) due to internal logic of urls. In any case if it is not possible to follow above point due to some reason helper methods are available to reflect such changes

  • Request.Update() commits any changes made to query parameters (ex: Request.URL.Query().Add(x,y))

# Packages

Package buggyhttp is a webserver affected by any kind of network issues.
No description provided by the author

# Functions

Check recoverable errors.
DefaultBackoff provides a default callback for Client.Backoff which will perform exponential backoff based on the attempt number and limited by the provided minimum and maximum durations.
DefaultClient returns a new http.Client with similar default values to http.Client, but with a non-shared Transport, idle connections disabled, and keepalives disabled.
DefaultHostSprayingTransport returns a new http.Transport with similar default values to http.DefaultTransport, but with idle connections and keepalives disabled.
DefaultPooledClient returns a new http.Client with similar default values to http.Client, but with a shared Transport.
DefaultRetryPolicy provides a default callback for Client.CheckRetry, which will retry on connection errors and server errors.
DefaultReusePooledTransport returns a new http.Transport with similar default values to http.DefaultTransport.
Discard is an helper function that discards the response body and closes the underlying connection.
ExponentialJitterBackoff provides a callback for Client.Backoff which will perform en exponential backoff based on the attempt number and with jitter to prevent a thundering herd.
FromRequest wraps an http.Request in a retryablehttp.Request.
FromRequestWithTrace wraps an http.Request in a retryablehttp.Request with trace enabled.
FullJitterBackoff implements capped exponential backoff with jitter.
Get issues a GET to the specified URL.
Head issues a HEAD to the specified URL.
HostSprayRetryPolicy provides a callback for Client.CheckRetry, which will retry on connection errors and server errors.
LinearJitterBackoff provides a callback for Client.Backoff which will perform linear backoff based on the attempt number and with jitter to prevent a thundering herd.
NewClient creates a new Client with default settings.
NewRequest creates a new wrapped request.
NewRequest creates a new wrapped request.
NewRequestWithContext creates a new wrapped request with context.
NewRequest creates a new wrapped request with given context.
NewWithHTTPClient creates a new Client with custom http client Deprecated: Use options.HttpClient.
PassthroughErrorHandler is an ErrorHandler that directly passes through the values from the net/http library for the final request.
Post
Post issues a POST to the specified URL.
PostForm issues a POST to the specified URL, with data's keys and values.

# Constants

No description provided by the author
No description provided by the author

# Variables

DefaultHTTPClient is the http client with DefaultOptionsSingle options.
DefaultOptionsSingle contains the default options for host bruteforce scenarios where lots of requests need to be sent to a single host.
DefaultOptionsSpraying contains the default options for host spraying scenarios where lots of requests need to be sent to different hosts.
DisableZTLSFallback disables use of ztls when there is error in tls handshake can also be disabled by setting DISABLE_ZTLS_FALLBACK env variable to true.
When True .

# Structs

Auth specific information.
Client is used to make HTTP requests.
Metrics contains the metrics about each request.
Options contains configuration options for the client.
Request wraps the metadata needed to create HTTP requests.
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
Backoff specifies a policy for how long to wait between retries.
CheckRetry specifies a policy for handling retries.
No description provided by the author
ErrorHandler is called if retries are expired, containing the last status from the http library.
RequestLogHook allows a function to run before each retry.
ResponseLogHook is like RequestLogHook, but allows running a function on each HTTP response.