httpclient

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyHeader added in v1.0.3

func CopyHeader(dst, src map[string]string) map[string]string

CopyHeader copies the src to dst and return a non-nil dst map.

Types

type OriginClient

type OriginClient struct {
	// contains filtered or unexported fields
}

OriginClient is an implementation of the interface of OriginHTTPClient.

func (*OriginClient) Download

func (client *OriginClient) Download(url string, headers map[string]string, checkCode StatusCodeChecker) (*http.Response, error)

Download downloads the file from the original address

func (*OriginClient) GetContentLength

func (client *OriginClient) GetContentLength(url string, headers map[string]string) (int64, int, error)

GetContentLength sends a head request to get file length.

func (*OriginClient) HTTPWithHeaders

func (client *OriginClient) HTTPWithHeaders(method, url string, headers map[string]string, timeout time.Duration) (*http.Response, error)

HTTPWithHeaders uses host-matched client to request the origin resource.

func (*OriginClient) IsExpired

func (client *OriginClient) IsExpired(url string, headers map[string]string, lastModified int64, eTag string) (bool, error)

IsExpired checks if a resource received or stored is the same.

func (*OriginClient) IsSupportRange

func (client *OriginClient) IsSupportRange(url string, headers map[string]string) (bool, error)

IsSupportRange checks if the source url support partial requests.

func (*OriginClient) RegisterTLSConfig

func (client *OriginClient) RegisterTLSConfig(rawURL string, insecure bool, caBlock []strfmt.Base64)

RegisterTLSConfig saves tls config into map as http client. tlsMap: key->host value->*http.Client

type OriginHTTPClient

type OriginHTTPClient interface {
	RegisterTLSConfig(rawURL string, insecure bool, caBlock []strfmt.Base64)
	GetContentLength(url string, headers map[string]string) (int64, int, error)
	IsSupportRange(url string, headers map[string]string) (bool, error)
	IsExpired(url string, headers map[string]string, lastModified int64, eTag string) (bool, error)
	Download(url string, headers map[string]string, checkCode StatusCodeChecker) (*http.Response, error)
}

OriginHTTPClient supply apis that interact with the source.

func NewOriginClient

func NewOriginClient() OriginHTTPClient

NewOriginClient returns a new OriginClient.

type StatusCodeChecker added in v1.0.1

type StatusCodeChecker func(int) bool

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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