Skip to content

Commit

Permalink
support optional http keep-alive
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Gongaware committed Jun 17, 2021
1 parent b938713 commit 53bc862
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion soap/soap.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ type options struct {
timeout time.Duration
contimeout time.Duration
tlshshaketimeout time.Duration
keepalive bool
httpHeaders map[string]string
}

var defaultOptions = options{
keepalive: true,
timeout: time.Duration(30 * time.Second),
contimeout: time.Duration(90 * time.Second),
tlshshaketimeout: time.Duration(15 * time.Second),
Expand Down Expand Up @@ -197,6 +199,13 @@ func WithTimeout(t time.Duration) Option {
}
}

// WithKeepalive is an Option to set global HTTP headers for all requests
func WithKeepalive(keepalive bool) Option {
return func(o *options) {
o.keepalive = keepalive
}
}

// WithHTTPHeaders is an Option to set global HTTP headers for all requests
func WithHTTPHeaders(headers map[string]string) Option {
return func(o *options) {
Expand Down Expand Up @@ -283,7 +292,8 @@ func (s *Client) Call(ctx context.Context, soapAction string, request, response
req.Header.Set(k, v)
}
}
req.Close = true

req.Close = !s.opts.keepalive

res, err := s.HClient.Do(req)
if err != nil {
Expand Down

0 comments on commit 53bc862

Please sign in to comment.