fix(plugin): CloseIdleConnections silent no-op when tokenTransport wraps HTTP transport
tokenTransport now delegates CloseIdleConnections to the underlying *http.Transport so http.Client.CloseIdleConnections() works through the wrapper. Three plugin Close() methods updated to unwrap via HTTPClientTransport before calling CloseIdleConnections. RoundTrip now short-circuits when caller already set Authorization, avoiding an unnecessary req.Clone allocation on the pass-through path.
This commit is contained in:
+2
-4
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-gost/core/chain"
|
||||
@@ -121,9 +120,8 @@ func (p *httpPlugin) Close() error {
|
||||
if p.client == nil {
|
||||
return nil
|
||||
}
|
||||
p.client.CloseIdleConnections()
|
||||
if tr, ok := p.client.Transport.(io.Closer); ok {
|
||||
return tr.Close()
|
||||
if tr := plugin.HTTPClientTransport(p.client); tr != nil {
|
||||
tr.CloseIdleConnections()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user