Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverse_proxy: Close idle connections on module unload
Matthew Holt committed
Sep 14, 2019 at 18:10 UTC
db4c73dd58b496f2c0c49a38f6c8b5f525456e3e
1 file changed
+11
-2
modules/caddyhttp/reverseproxy/httptransport.go
+11
-2
@@ -123,6 +123,14 @@ func (h HTTPTransport) RoundTrip(req *http.Request) (*http.Response, error) {
123
return h.RoundTripper.RoundTrip(req)
124
}
125
126
+// Cleanup implements caddy.CleanerUpper and closes any idle connections.
127
+func (h HTTPTransport) Cleanup() error {
128
+ if ht, ok := h.RoundTripper.(*http.Transport); ok {
129
+ ht.CloseIdleConnections()
130
+ }
131
+ return nil
132
+}
133
+
134
// TLSConfig holds configuration related to the
135
// TLS configuration for the transport/client.
136
type TLSConfig struct {
@@ -203,6 +211,7 @@ type KeepAlive struct {
211
212
// Interface guards
213
var (
206
- _ caddy.Provisioner = (*HTTPTransport)(nil)
207
- _ http.RoundTripper = (*HTTPTransport)(nil)
214
+ _ caddy.Provisioner = (*HTTPTransport)(nil)
215
+ _ http.RoundTripper = (*HTTPTransport)(nil)
216
+ _ caddy.CleanerUpper = (*HTTPTransport)(nil)
217
)