...

Package http

import "sigs.k8s.io/release-utils/http"
Overview
Index
Subdirectories

Overview ▾

func GetURLResponse

func GetURLResponse(url string, trim bool) (string, error)

GetURLResponse returns the HTTP response for the provided URL if the request succeeds

type Agent

Agent is an http agent

type Agent struct {
    AgentImplementation
    // contains filtered or unexported fields
}

func NewAgent

func NewAgent() *Agent

NewAgent return a new agent with default options

func (*Agent) Client

func (a *Agent) Client() *http.Client

Client return an net/http client preconfigured with the agent options

func (*Agent) Get

func (a *Agent) Get(url string) (content []byte, err error)

Get returns the body a a GET request

func (*Agent) GetRequest

func (a *Agent) GetRequest(url string) (response *http.Response, err error)

GetRequest sends a GET request to a URL and returns the request and response

func (*Agent) Post

func (a *Agent) Post(url string, postData []byte) (content []byte, err error)

Post returns the body of a POST request

func (*Agent) PostRequest

func (a *Agent) PostRequest(url string, postData []byte) (response *http.Response, err error)

PostRequest sends the postData in a POST request to a URL and returns the request object

func (*Agent) SetImplementation

func (a *Agent) SetImplementation(impl AgentImplementation)

SetImplementation sets the agent implementation

func (*Agent) WithFailOnHTTPError

func (a *Agent) WithFailOnHTTPError(flag bool) *Agent

WithFailOnHTTPError determines if the agent fails on HTTP errors (HTTP status not in 200s)

func (*Agent) WithRetries

func (a *Agent) WithRetries(retries uint) *Agent

WithRetries sets the number of times we'll attempt to fetch the URL

func (*Agent) WithTimeout

func (a *Agent) WithTimeout(timeout time.Duration) *Agent

WithTimeout sets the agent timeout

type AgentImplementation

AgentImplementation is the actual implementation of the http calls

type AgentImplementation interface {
    SendPostRequest(*http.Client, string, []byte, string) (*http.Response, error)
    SendGetRequest(*http.Client, string) (*http.Response, error)
}

Subdirectories

Name Synopsis
..
httpfakes Code generated by counterfeiter.