summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-14 18:10:29 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-14 18:10:29 -0600
commitdb4c73dd58b496f2c0c49a38f6c8b5f525456e3e (patch)
tree595040d24d888930f8003ffd6b8dc267f5cfcbe2 /modules
parentf15f0d5839479f8511621b88fa4bdcca3b89cc32 (diff)
reverse_proxy: Close idle connections on module unload
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/reverseproxy/httptransport.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go
index c135ac8..00b58a4 100644
--- a/modules/caddyhttp/reverseproxy/httptransport.go
+++ b/modules/caddyhttp/reverseproxy/httptransport.go
@@ -123,6 +123,14 @@ func (h HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return h.RoundTripper.RoundTrip(req)
}
+// Cleanup implements caddy.CleanerUpper and closes any idle connections.
+func (h HTTPTransport) Cleanup() error {
+ if ht, ok := h.RoundTripper.(*http.Transport); ok {
+ ht.CloseIdleConnections()
+ }
+ return nil
+}
+
// TLSConfig holds configuration related to the
// TLS configuration for the transport/client.
type TLSConfig struct {
@@ -203,6 +211,7 @@ type KeepAlive struct {
// Interface guards
var (
- _ caddy.Provisioner = (*HTTPTransport)(nil)
- _ http.RoundTripper = (*HTTPTransport)(nil)
+ _ caddy.Provisioner = (*HTTPTransport)(nil)
+ _ http.RoundTripper = (*HTTPTransport)(nil)
+ _ caddy.CleanerUpper = (*HTTPTransport)(nil)
)