Skip to content

Commit 0b8c1f4

Browse files
authored
Merge pull request #106 from akerouanton/fix-DisableCompression
ConfigureTransport: enable compression for non unix/npipe protos
2 parents 12f72d4 + 2573a15 commit 0b8c1f4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sockets/sockets.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ const defaultTimeout = 10 * time.Second
1313
// ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system.
1414
var ErrProtocolNotAvailable = errors.New("protocol not available")
1515

16-
// ConfigureTransport configures the specified Transport according to the
17-
// specified proto and addr.
18-
// If the proto is unix (using a unix socket to communicate) or npipe the
19-
// compression is disabled.
16+
// ConfigureTransport configures the specified [http.Transport] according to the specified proto
17+
// and addr.
18+
//
19+
// If the proto is unix (using a unix socket to communicate) or npipe the compression is disabled.
20+
// For other protos, compression is enabled. If you want to manually enable/disable compression,
21+
// make sure you do it _after_ any subsequent calls to ConfigureTransport is made against the same
22+
// [http.Transport].
2023
func ConfigureTransport(tr *http.Transport, proto, addr string) error {
2124
switch proto {
2225
case "unix":
@@ -25,6 +28,7 @@ func ConfigureTransport(tr *http.Transport, proto, addr string) error {
2528
return configureNpipeTransport(tr, proto, addr)
2629
default:
2730
tr.Proxy = http.ProxyFromEnvironment
31+
tr.DisableCompression = false
2832
tr.DialContext = (&net.Dialer{
2933
Timeout: defaultTimeout,
3034
}).DialContext

0 commit comments

Comments
 (0)