Skip to content

Commit

Permalink
Merge pull request #90 from agrimmer/master
Browse files Browse the repository at this point in the history
Use Client of Transport instead of DefaultClient in httpDo
  • Loading branch information
n3wscott authored Mar 21, 2019
2 parents 5118a97 + c452121 commit dd2323e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/cloudevents/transport/http/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (t *Transport) obsSend(ctx context.Context, event cloudevents.Event) (*clou
req.Body = ioutil.NopCloser(bytes.NewBuffer(m.Body))
req.ContentLength = int64(len(m.Body))
req.Close = true
return httpDo(ctx, &req, func(resp *http.Response, err error) (*cloudevents.Event, error) {
return httpDo(ctx, t.Client, &req, func(resp *http.Response, err error) (*cloudevents.Event, error) {
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -263,12 +263,12 @@ type eventError struct {
err error
}

func httpDo(ctx context.Context, req *http.Request, fn func(*http.Response, error) (*cloudevents.Event, error)) (*cloudevents.Event, error) {
func httpDo(ctx context.Context, client *http.Client, req *http.Request, fn func(*http.Response, error) (*cloudevents.Event, error)) (*cloudevents.Event, error) {
// Run the HTTP request in a goroutine and pass the response to fn.
c := make(chan eventError, 1)
req = req.WithContext(ctx)
go func() {
event, err := fn(http.DefaultClient.Do(req))
event, err := fn(client.Do(req))
c <- eventError{event: event, err: err}
}()
select {
Expand Down

0 comments on commit dd2323e

Please sign in to comment.