diff options
Diffstat (limited to 'plumbing/transport/http')
-rw-r--r-- | plumbing/transport/http/common.go | 16 | ||||
-rw-r--r-- | plumbing/transport/http/common_test.go | 6 | ||||
-rw-r--r-- | plumbing/transport/http/receive_pack.go | 4 | ||||
-rw-r--r-- | plumbing/transport/http/upload_pack.go | 5 | ||||
-rw-r--r-- | plumbing/transport/http/upload_pack_test.go | 4 |
5 files changed, 17 insertions, 18 deletions
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go index 6b40d42..95103f7 100644 --- a/plumbing/transport/http/common.go +++ b/plumbing/transport/http/common.go @@ -39,7 +39,7 @@ func advertisedReferences(s *session, serviceName string) (*packp.AdvRefs, error } s.applyAuthToRequest(req) - applyHeadersToRequest(req, nil, s.endpoint.Host(), serviceName) + applyHeadersToRequest(req, nil, s.endpoint.Host, serviceName) res, err := s.client.Do(req) if err != nil { return nil, err @@ -90,13 +90,13 @@ func NewClient(c *http.Client) transport.Transport { } } -func (c *client) NewUploadPackSession(ep transport.Endpoint, auth transport.AuthMethod) ( +func (c *client) NewUploadPackSession(ep *transport.Endpoint, auth transport.AuthMethod) ( transport.UploadPackSession, error) { return newUploadPackSession(c.c, ep, auth) } -func (c *client) NewReceivePackSession(ep transport.Endpoint, auth transport.AuthMethod) ( +func (c *client) NewReceivePackSession(ep *transport.Endpoint, auth transport.AuthMethod) ( transport.ReceivePackSession, error) { return newReceivePackSession(c.c, ep, auth) @@ -105,11 +105,11 @@ func (c *client) NewReceivePackSession(ep transport.Endpoint, auth transport.Aut type session struct { auth AuthMethod client *http.Client - endpoint transport.Endpoint + endpoint *transport.Endpoint advRefs *packp.AdvRefs } -func newSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (*session, error) { +func newSession(c *http.Client, ep *transport.Endpoint, auth transport.AuthMethod) (*session, error) { s := &session{ auth: basicAuthFromEndpoint(ep), client: c, @@ -145,13 +145,13 @@ type AuthMethod interface { setAuth(r *http.Request) } -func basicAuthFromEndpoint(ep transport.Endpoint) *BasicAuth { - u := ep.User() +func basicAuthFromEndpoint(ep *transport.Endpoint) *BasicAuth { + u := ep.User if u == "" { return nil } - return NewBasicAuth(u, ep.Password()) + return NewBasicAuth(u, ep.Password) } // BasicAuth represent a HTTP basic auth diff --git a/plumbing/transport/http/common_test.go b/plumbing/transport/http/common_test.go index 8dcc903..bd1bec3 100644 --- a/plumbing/transport/http/common_test.go +++ b/plumbing/transport/http/common_test.go @@ -24,7 +24,7 @@ import ( func Test(t *testing.T) { TestingT(t) } type ClientSuite struct { - Endpoint transport.Endpoint + Endpoint *transport.Endpoint EmptyAuth transport.AuthMethod } @@ -143,7 +143,7 @@ func (s *BaseSuite) SetUpTest(c *C) { }() } -func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) transport.Endpoint { +func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *transport.Endpoint { fs := f.DotGit() err := fixtures.EnsureIsBare(fs) @@ -156,7 +156,7 @@ func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) tr return s.newEndpoint(c, name) } -func (s *BaseSuite) newEndpoint(c *C, name string) transport.Endpoint { +func (s *BaseSuite) newEndpoint(c *C, name string) *transport.Endpoint { ep, err := transport.NewEndpoint(fmt.Sprintf("http://localhost:%d/%s", s.port, name)) c.Assert(err, IsNil) diff --git a/plumbing/transport/http/receive_pack.go b/plumbing/transport/http/receive_pack.go index d2dfeb7..e5cae28 100644 --- a/plumbing/transport/http/receive_pack.go +++ b/plumbing/transport/http/receive_pack.go @@ -19,7 +19,7 @@ type rpSession struct { *session } -func newReceivePackSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) { +func newReceivePackSession(c *http.Client, ep *transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) { s, err := newSession(c, ep, auth) return &rpSession{s}, err } @@ -89,7 +89,7 @@ func (s *rpSession) doRequest( return nil, plumbing.NewPermanentError(err) } - applyHeadersToRequest(req, content, s.endpoint.Host(), transport.ReceivePackServiceName) + applyHeadersToRequest(req, content, s.endpoint.Host, transport.ReceivePackServiceName) s.applyAuthToRequest(req) res, err := s.client.Do(req.WithContext(ctx)) diff --git a/plumbing/transport/http/upload_pack.go b/plumbing/transport/http/upload_pack.go index c5ac325..85a57a5 100644 --- a/plumbing/transport/http/upload_pack.go +++ b/plumbing/transport/http/upload_pack.go @@ -19,9 +19,8 @@ type upSession struct { *session } -func newUploadPackSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (transport.UploadPackSession, error) { +func newUploadPackSession(c *http.Client, ep *transport.Endpoint, auth transport.AuthMethod) (transport.UploadPackSession, error) { s, err := newSession(c, ep, auth) - return &upSession{s}, err } @@ -88,7 +87,7 @@ func (s *upSession) doRequest( return nil, plumbing.NewPermanentError(err) } - applyHeadersToRequest(req, content, s.endpoint.Host(), transport.UploadPackServiceName) + applyHeadersToRequest(req, content, s.endpoint.Host, transport.UploadPackServiceName) s.applyAuthToRequest(req) res, err := s.client.Do(req.WithContext(ctx)) diff --git a/plumbing/transport/http/upload_pack_test.go b/plumbing/transport/http/upload_pack_test.go index 1785c40..6c90386 100644 --- a/plumbing/transport/http/upload_pack_test.go +++ b/plumbing/transport/http/upload_pack_test.go @@ -57,7 +57,7 @@ func (s *UploadPackSuite) TestuploadPackRequestToReader(c *C) { ) } -func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) transport.Endpoint { +func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *transport.Endpoint { fs := f.DotGit() err := fixtures.EnsureIsBare(fs) @@ -70,7 +70,7 @@ func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name stri return s.newEndpoint(c, name) } -func (s *UploadPackSuite) newEndpoint(c *C, name string) transport.Endpoint { +func (s *UploadPackSuite) newEndpoint(c *C, name string) *transport.Endpoint { ep, err := transport.NewEndpoint(fmt.Sprintf("http://localhost:%d/%s", s.port, name)) c.Assert(err, IsNil) |