http

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType           = "Content-Type"
	ContentUrlEncodedForm = "application/x-www-form-urlencoded"
	ContentJson           = "application/json"
	ContentPlainText      = "text/plain"
)

Variables

This section is empty.

Functions

func DoHTTPGetProbe

func DoHTTPGetProbe(url *url.URL, headers http.Header, client HTTPInterface) (api.Result, string, error)

DoHTTPGetProbe checks if a GET request to the url succeeds. If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success. If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure. This is exported because some other packages may want to do direct HTTP probes.

func DoHTTPPostProbe

func DoHTTPPostProbe(addr *url.URL, headers http.Header, client HTTPInterface, form url.Values, body string) (api.Result, string, error)

DoHTTPPostProbe checks if a POST request to the url succeeds. If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success. If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure. This is exported because some other packages may want to do direct HTTP probes.

Types

type GetProber

type GetProber interface {
	Probe(url *url.URL, headers http.Header, timeout time.Duration) (api.Result, string, error)
}

GetProber is an interface that defines the Probe function for doing HTTP probe.

func NewGetWithTLSConfig

func NewGetWithTLSConfig(config *tls.Config, followNonLocalRedirects bool) GetProber

NewWithTLSConfig takes tls config as parameter. followNonLocalRedirects configures whether the prober should follow redirects to a different hostname.

If disabled, redirects to other hosts will trigger a warning result.

func NewHttpGet

func NewHttpGet(followNonLocalRedirects bool) GetProber

New creates GetProber that will skip TLS verification while probing. followNonLocalRedirects configures whether the prober should follow redirects to a different hostname.

If disabled, redirects to other hosts will trigger a warning result.

type HTTPInterface

type HTTPInterface interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPInterface is an interface for making HTTP requests, that returns a response and error.

type PostProber

type PostProber interface {
	Probe(url *url.URL, headers http.Header, form url.Values, body string, timeout time.Duration) (api.Result, string, error)
}

PostProber is an interface that defines the Probe function for doing HTTP probe.

func NewHttpPost

func NewHttpPost(followNonLocalRedirects bool) PostProber

New creates PostProber that will skip TLS verification while probing. followNonLocalRedirects configures whether the prober should follow redirects to a different hostname.

If disabled, redirects to other hosts will trigger a warning result.

func NewPostWithTLSConfig

func NewPostWithTLSConfig(config *tls.Config, followNonLocalRedirects bool) PostProber

NewWithTLSConfig takes tls config as parameter. followNonLocalRedirects configures whether the prober should follow redirects to a different hostname.

If disabled, redirects to other hosts will trigger a warning result.

Jump to

Keyboard shortcuts

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