From 7e4d5eafae5b0f56c539ac8a04c88b9f07d9823c Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 20 May 2015 10:09:37 -0700 Subject: [PATCH] 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 (github: dmcgowan) --- docs/client/transport/http_reader.go | 11 ++++++++--- docs/client/transport/session.go | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/client/transport/http_reader.go b/docs/client/transport/http_reader.go index d10d37e06..e351bdfe3 100644 --- a/docs/client/transport/http_reader.go +++ b/docs/client/transport/http_reader.go @@ -9,14 +9,19 @@ import ( "io/ioutil" "net/http" "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 // request. When seeking and starting a read from a non-zero 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{ client: client, url: url, diff --git a/docs/client/transport/session.go b/docs/client/transport/session.go index 670be1ba8..5086c0211 100644 --- a/docs/client/transport/session.go +++ b/docs/client/transport/session.go @@ -14,7 +14,12 @@ import ( // AuthenticationHandler is an interface for authorizing a request from // params from a "WWW-Authenicate" header for a single scheme. type AuthenticationHandler interface { + // Scheme returns the scheme as expected from the "WWW-Authenicate" header. 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 }