httpx

package
v0.0.353 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 21 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisallowIPPrivateAddresses added in v0.0.334

func DisallowIPPrivateAddresses(ipOrHostnameOrURL string) error

DisallowIPPrivateAddresses returns nil for a domain (with NS lookup), IP, or IPv6 address if it does not resolve to a private IP subnet. This is a first level of defense against SSRF attacks by disallowing any domain or IP to resolve to a private network range.

Please keep in mind that validations for domains is valid only when looking up. A malicious actor could easily update the DSN record post validation to point to an internal IP

func DisallowPrivateIPAddressesWhenSet added in v0.0.334

func DisallowPrivateIPAddressesWhenSet(ipOrHostnameOrURL string) error

DisallowPrivateIPAddressesWhenSet is a wrapper for DisallowIPPrivateAddresses which returns valid when ipOrHostnameOrURL is empty.

func GetResponseMeta added in v0.0.302

func GetResponseMeta(w http.ResponseWriter) (status, size int)

func HasContentType added in v0.0.81

func HasContentType(r *http.Request, mimetypes ...string) bool

HasContentType determines whether the request `content-type` includes a server-acceptable mime-type

Failure should yield an HTTP 415 (`http.StatusUnsupportedMediaType`)

func MustNewRequest added in v0.0.83

func MustNewRequest(method, url string, body io.Reader, contentType string) *http.Request

MustNewRequest returns a new *http.Request or fatals.

func NewChanHandler added in v0.0.297

func NewChanHandler(buf int) (http.Handler, chan<- http.HandlerFunc)

NewChanHandler returns a new handler and corresponding channel for sending handler funcs. Useful for testing. The argument buf specifies the channel capacity, so pass 0 for a sync handler.

func NewRequestForm added in v0.0.83

func NewRequestForm(method, url string, data url.Values) (*http.Request, error)

NewRequestForm returns a new POST Form *http.Request.

func NewRequestJSON added in v0.0.83

func NewRequestJSON(method, url string, data interface{}) (*http.Request, error)

NewRequestJSON returns a new JSON *http.Request.

func NewResilientClient added in v0.0.204

func NewResilientClient(opts ...ResilientOptions) *retryablehttp.Client

NewResilientClient creates a new ResilientClient.

Types

type CompressionRequestReader added in v0.0.110

type CompressionRequestReader struct {
	ErrHandler func(w http.ResponseWriter, r *http.Request, err error)
}

func NewCompressionRequestReader added in v0.0.110

func NewCompressionRequestReader(eh func(w http.ResponseWriter, r *http.Request, err error)) *CompressionRequestReader

func (*CompressionRequestReader) ServeHTTP added in v0.0.110

type NoInternalIPRoundTripper added in v0.0.334

type NoInternalIPRoundTripper struct {
	http.RoundTripper
}

NoInternalIPRoundTripper is a RoundTripper that disallows internal IP addresses.

func (NoInternalIPRoundTripper) RoundTrip added in v0.0.334

func (n NoInternalIPRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

type ResilientOptions added in v0.0.204

type ResilientOptions func(o *resilientOptions)

ResilientOptions is a set of options for the ResilientClient.

func ResilientClientDisallowInternalIPs added in v0.0.334

func ResilientClientDisallowInternalIPs() ResilientOptions

ResilientClientDisallowInternalIPs disallows internal IPs from being used.

func ResilientClientWithClient added in v0.0.204

func ResilientClientWithClient(c *http.Client) ResilientOptions

ResilientClientWithClient sets the underlying http client to use.

func ResilientClientWithConnectionTimeout added in v0.0.207

func ResilientClientWithConnectionTimeout(connTimeout time.Duration) ResilientOptions

ResilientClientWithConnectionTimeout sets the connection timeout for the client.

func ResilientClientWithLogger added in v0.0.204

func ResilientClientWithLogger(l *logrusx.Logger) ResilientOptions

ResilientClientWithLogger sets the logger to be used by the client.

func ResilientClientWithMaxRetry added in v0.0.204

func ResilientClientWithMaxRetry(retryMax int) ResilientOptions

ResilientClientWithMaxRetry sets the maximum number of retries.

func ResilientClientWithMaxRetryWait added in v0.0.204

func ResilientClientWithMaxRetryWait(retryWaitMax time.Duration) ResilientOptions

ResilientClientWithMaxRetryWait sets the maximum wait time for a retry.

func ResilientClientWithMinxRetryWait added in v0.0.204

func ResilientClientWithMinxRetryWait(retryWaitMin time.Duration) ResilientOptions

ResilientClientWithMinxRetryWait sets the minimum wait time between retries.

func ResilientClientWithTracer added in v0.0.337

func ResilientClientWithTracer(tracer opentracing.Tracer) ResilientOptions

ResilientClientWithTracer wraps the http clients transport with a tracing instrumentation

Jump to

Keyboard shortcuts

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