Documentation ¶
Index ¶
- Variables
- type AllowedSource
- type HTTPLoader
- type Option
- func WithAccept(contentType string) Option
- func WithAllowedSourceRegexps(patterns ...string) Option
- func WithAllowedSources(hosts ...string) Option
- func WithBaseURL(baseURL string) Option
- func WithBlockLinkLocalNetworks(enabled bool) Option
- func WithBlockLoopbackNetworks(enabled bool) Option
- func WithBlockNetworks(networks ...*net.IPNet) Option
- func WithBlockPrivateNetworks(enabled bool) Option
- func WithDefaultScheme(scheme string) Option
- func WithForwardClientHeaders(enabled bool) Option
- func WithForwardHeaders(headers ...string) Option
- func WithInsecureSkipVerifyTransport(enabled bool) Option
- func WithMaxAllowedSize(maxAllowedSize int) Option
- func WithOverrideHeader(name, value string) Option
- func WithOverrideResponseHeaders(headers ...string) Option
- func WithProxyTransport(proxyURLs, hosts string) Option
- func WithTransport(transport http.RoundTripper) Option
- func WithUserAgent(userAgent string) Option
Constants ¶
This section is empty.
Variables ¶
ErrUnauthorizedRequest unauthorized request error
Functions ¶
This section is empty.
Types ¶
type AllowedSource ¶ added in v1.4.5
AllowedSource represents a source the HTTPLoader is allowed to load from. It supports host glob patterns such as *.google.com and a full URL regex.
func NewHostPatternAllowedSource ¶ added in v1.4.5
func NewHostPatternAllowedSource(pattern string) AllowedSource
NewHostPatternAllowedSource creates a new AllowedSource from the host glob pattern
func NewRegexpAllowedSource ¶ added in v1.4.5
func NewRegexpAllowedSource(pattern string) (AllowedSource, error)
NewRegexpAllowedSource creates a new AllowedSource from the regex pattern
type HTTPLoader ¶
type HTTPLoader struct { // The Transport used to request images, default http.DefaultTransport. Transport http.RoundTripper // ForwardHeaders copy request headers to image request headers ForwardHeaders []string // OverrideHeaders override image request headers OverrideHeaders map[string]string // OverrideResponseHeaders override image response header from HTTP Loader response OverrideResponseHeaders []string // AllowedSources list of sources allowed to load from AllowedSources []AllowedSource // Accept set request Accept and validate response Content-Type header Accept string // MaxAllowedSize maximum bytes allowed for image MaxAllowedSize int // DefaultScheme default image URL scheme DefaultScheme string // UserAgent default user agent for image request. // Can be overridden by ForwardHeaders and OverrideHeaders UserAgent string // BlockLoopbackNetworks rejects HTTP connections to loopback network IP addresses. BlockLoopbackNetworks bool // BlockPrivateNetworks rejects HTTP connections to private network IP addresses. BlockPrivateNetworks bool // BlockLinkLocalNetworks rejects HTTP connections to link local IP addresses. BlockLinkLocalNetworks bool // BlockNetworks rejects HTTP connections to a configurable list of networks. BlockNetworks []*net.IPNet // BaseURL base URL for HTTP loader BaseURL *url.URL // contains filtered or unexported fields }
HTTPLoader HTTP Loader implements imagor.Loader interface
func (*HTTPLoader) DialControl ¶ added in v1.2.4
DialControl implements a net.Dialer.Control function which is automatically used with the default http.Transport. If the transport is replaced using the WithTransport option it is up to that transport if the control function is used or not.
type Option ¶
type Option func(h *HTTPLoader)
Option HTTPLoader option
func WithAccept ¶ added in v0.7.5
WithAccept with accepted content type option
func WithAllowedSourceRegexps ¶ added in v1.4.5
func WithAllowedSources ¶
WithAllowedSources with allowed source hosts option. Accept csv wth glob pattern e.g. *.google.com,*.github.com
func WithBaseURL ¶ added in v1.4.1
WithBaseURL with base URL option for valid URL string
func WithBlockLinkLocalNetworks ¶ added in v1.2.4
WithBlockLinkLocalNetworks with option to reject HTTP connections to link local IP addresses
func WithBlockLoopbackNetworks ¶ added in v1.2.4
WithBlockLoopbackNetworks with option to reject HTTP connections to loopback network IP addresses
func WithBlockNetworks ¶ added in v1.2.4
WithBlockNetworks with option to reject HTTP connections to a configurable list of networks
func WithBlockPrivateNetworks ¶ added in v1.2.4
WithBlockPrivateNetworks with option to reject HTTP connections to private network IP addresses
func WithDefaultScheme ¶
WithDefaultScheme with default URL scheme option https or http, if not specified
func WithForwardClientHeaders ¶ added in v0.8.15
WithForwardClientHeaders with forward browser request headers option
func WithForwardHeaders ¶
WithForwardHeaders with forward selected request headers option
func WithInsecureSkipVerifyTransport ¶
WithInsecureSkipVerifyTransport with insecure HTTPs option
func WithMaxAllowedSize ¶
WithMaxAllowedSize with maximum allowed size option
func WithOverrideHeader ¶
WithOverrideHeader with override request header with name value pair option
func WithOverrideResponseHeaders ¶ added in v1.4.11
WithOverrideResponseHeaders with override selected response headers option
func WithProxyTransport ¶ added in v0.7.3
WithProxyTransport with random proxy rotation option for selected proxy URLs
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option
WithTransport with custom http.RoundTripper transport option
func WithUserAgent ¶
WithUserAgent with custom user agent option