Documentation ¶
Index ¶
Constants ¶
const ( LastModified = "X-Dragonfly-Last-Modified" IfModifiedSince = "X-Dragonfly-If-Modified-Since" ETag = "X-Dragonfly-ETag" IfNoneMatch = "X-Dragonfly-If-None-Match" Range = "X-Dragonfly-Range" // startIndex-endIndex )
const LastModifiedLayout = "Mon, 02 Jan 2006 15:04:05 GMT"
Variables ¶
This section is empty.
Functions ¶
func CanonicalHeaderKey ¶
Types ¶
type ExpireInfo ¶
type Header ¶
A Header represents the key-value pairs in a Dragonfly source header.
The keys should be in canonical form, as returned by CanonicalHeaderKey.
func (Header) Add ¶
Add adds the key, value pair to the header. It appends to any existing values associated with key. The key is case insensitive; it is canonicalized by CanonicalHeaderKey.
func (Header) Del ¶
Del deletes the values associated with key. The key is case insensitive; it is canonicalized by CanonicalHeaderKey.
func (Header) Get ¶
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "". It is case insensitive; textproto.CanonicalMIMEHeaderKey is used to canonicalize the provided key. To use non-canonical keys, access the map directly.
func (Header) Set ¶
Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key. The key is case insensitive; it is canonicalized by textproto.CanonicalMIMEHeaderKey. To use non-canonical keys, assign to the map directly.
type Request ¶
func NewRequest ¶
func NewRequestWithContext ¶
func NewRequestWithHeader ¶
func (*Request) Clone ¶
Clone returns a deep copy of r with its context changed to ctx. The provided ctx must be non-nil.
For an outgoing client request, the context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body.
func (*Request) Context ¶
Context returns the request's context. To change the context, use WithContext.
The returned context is always non-nil; it defaults to the background context.
For outgoing client requests, the context controls cancellation.
For incoming server requests, the context is canceled when the client's connection closes, the request is canceled (with HTTP/2), or when the ServeHTTP method returns.
func (*Request) WithContext ¶
WithContext returns a shallow copy of r with its context changed to ctx. The provided ctx must be non-nil.
For outgoing client request, the context controls the entire lifetime of a request and its response: obtaining a connection, sending the request, and reading the response headers and body.
To create a new request with a context, use NewRequestWithContext. To change the context of a request, such as an incoming request you want to modify before sending back out, use Request.Clone. Between those two uses, it's rare to need WithContext.
type ResourceClient ¶
type ResourceClient interface { // GetContentLength get length of resource content // return source.UnknownSourceFileLen if response status is not StatusOK and StatusPartialContent GetContentLength(request *Request) (int64, error) // IsSupportRange checks if resource supports breakpoint continuation // return false if response status is not StatusPartialContent IsSupportRange(request *Request) (bool, error) // IsExpired checks if a resource received or stored is the same. // return false and non-nil err to prevent the source from exploding if // fails to get the result, it is considered that the source has not expired IsExpired(request *Request, info *ExpireInfo) (bool, error) // Download downloads from source Download(request *Request) (io.ReadCloser, error) // DownloadWithExpireInfo download from source with expireInfo DownloadWithExpireInfo(request *Request) (io.ReadCloser, *ExpireInfo, error) // GetLastModified gets last modified timestamp milliseconds of resource GetLastModified(request *Request) (int64, error) }
ResourceClient defines the API interface to interact with source.