forked from TrueCloudLab/distribution
Update transport package to sever distribution dependency
The transport package no longer requires importing distribution for the ReadSeekCloser, instead declares its own. Added comments on the Authenication handler in session. Added todo on http seek reader to highlight its lack of belonging to the client transport. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
572ff64d21
commit
c7f7747368
2 changed files with 13 additions and 3 deletions
|
@ -9,14 +9,19 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/docker/distribution"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ReadSeekCloser combines io.ReadSeeker with io.Closer.
|
||||||
|
type ReadSeekCloser interface {
|
||||||
|
io.ReadSeeker
|
||||||
|
io.Closer
|
||||||
|
}
|
||||||
|
|
||||||
// NewHTTPReadSeeker handles reading from an HTTP endpoint using a GET
|
// NewHTTPReadSeeker handles reading from an HTTP endpoint using a GET
|
||||||
// request. When seeking and starting a read from a non-zero offset
|
// request. When seeking and starting a read from a non-zero offset
|
||||||
// the a "Range" header will be added which sets the offset.
|
// the a "Range" header will be added which sets the offset.
|
||||||
func NewHTTPReadSeeker(client *http.Client, url string, size int64) distribution.ReadSeekCloser {
|
// TODO(dmcgowan): Move this into a separate utility package
|
||||||
|
func NewHTTPReadSeeker(client *http.Client, url string, size int64) ReadSeekCloser {
|
||||||
return &httpReadSeeker{
|
return &httpReadSeeker{
|
||||||
client: client,
|
client: client,
|
||||||
url: url,
|
url: url,
|
||||||
|
|
|
@ -14,7 +14,12 @@ import (
|
||||||
// AuthenticationHandler is an interface for authorizing a request from
|
// AuthenticationHandler is an interface for authorizing a request from
|
||||||
// params from a "WWW-Authenicate" header for a single scheme.
|
// params from a "WWW-Authenicate" header for a single scheme.
|
||||||
type AuthenticationHandler interface {
|
type AuthenticationHandler interface {
|
||||||
|
// Scheme returns the scheme as expected from the "WWW-Authenicate" header.
|
||||||
Scheme() string
|
Scheme() string
|
||||||
|
|
||||||
|
// AuthorizeRequest adds the authorization header to a request (if needed)
|
||||||
|
// using the parameters from "WWW-Authenticate" method. The parameters
|
||||||
|
// values depend on the scheme.
|
||||||
AuthorizeRequest(req *http.Request, params map[string]string) error
|
AuthorizeRequest(req *http.Request, params map[string]string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue