diff options
author | Santiago M. Mola <santi@mola.io> | 2016-11-25 09:25:49 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-11-25 09:25:49 +0100 |
commit | 9e34f68d980de57631c588aaa910c9ea95ed7c2e (patch) | |
tree | b1bd9f867b757ca46ada2f349d122723dde3529c /plumbing/transport/http/common.go | |
parent | 8966c042795509ed17730e50d352ad69901c3da8 (diff) | |
download | go-git-9e34f68d980de57631c588aaa910c9ea95ed7c2e.tar.gz |
plumbing/transport: add common tests and fixes. (#136)
* plumbing/transport: add common tests and fixes.
* add common test suite for different transport implementations.
* fix different behaviour on error handling for ssh and http.
fixes issue #123.
* support detecting unexisting repositories with SSH + GitHub/Bitbucket
(apparently, there is no standard for all SSH servers).
* remove ssh.NewClient (only DefaultClient makes sense at the moment).
* make ssh.Client and http.Client private.
* utils/ioutil: utilities to work with io interfaces.
* * transport: test actual objects fetched, not just packfile size.
* * fix doc typo.
* * improve UploadPackRequest.IsEmpty
Diffstat (limited to 'plumbing/transport/http/common.go')
-rw-r--r-- | plumbing/transport/http/common.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go index 038c469..a1b085b 100644 --- a/plumbing/transport/http/common.go +++ b/plumbing/transport/http/common.go @@ -9,33 +9,38 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/transport" ) -type Client struct { +type client struct { c *http.Client } +// DefaultClient is the default HTTP client, which uses `http.DefaultClient`. var DefaultClient = NewClient(nil) // NewClient creates a new client with a custom net/http client. // See `InstallProtocol` to install and override default http client. // Unless a properly initialized client is given, it will fall back into // `http.DefaultClient`. +// +// Note that for HTTP client cannot distinguist between private repositories and +// unexistent repositories on GitHub. So it returns `ErrAuthorizationRequired` +// for both. func NewClient(c *http.Client) transport.Client { if c == nil { - return &Client{http.DefaultClient} + return &client{http.DefaultClient} } - return &Client{ + return &client{ c: c, } } -func (c *Client) NewFetchPackSession(ep transport.Endpoint) ( +func (c *client) NewFetchPackSession(ep transport.Endpoint) ( transport.FetchPackSession, error) { return newFetchPackSession(c.c, ep), nil } -func (c *Client) NewSendPackSession(ep transport.Endpoint) ( +func (c *client) NewSendPackSession(ep transport.Endpoint) ( transport.SendPackSession, error) { return newSendPackSession(c.c, ep), nil |