All Projects → projectdiscovery → retryablehttp-go

projectdiscovery / retryablehttp-go

Licence: MPL-2.0 license
Package retryablehttp provides a familiar HTTP client interface with automatic retries and exponential backoff

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

retryablehttp

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

Usage

package main

import (
	"fmt"
	"io/ioutil"

	"github.com/projectdiscovery/retryablehttp-go"
)

func main() {
	opts := retryablehttp.DefaultOptionsSpraying
	// opts := retryablehttp.DefaultOptionsSingle // use single options for single host
	client := retryablehttp.NewClient(opts)
	resp, err := client.Get("https://example.com")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	data, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Data: %v\n", string(data))
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].