From b7dc5b6431d97be2f5a6a10e38b4db92d6fd708b Mon Sep 17 00:00:00 2001 From: Arthur Sengileyev Date: Sat, 31 Aug 2024 16:42:15 +0300 Subject: [PATCH] Allow Unix socket transport on Windows platform Implementation is the same as for Unix like systems, but is using MAX_PATH value of Windows platform for sanity check. Signed-off-by: Arthur Sengileyev --- sockets/sockets_windows.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sockets/sockets_windows.go b/sockets/sockets_windows.go index 7acafc5a2..c08613e4e 100644 --- a/sockets/sockets_windows.go +++ b/sockets/sockets_windows.go @@ -2,6 +2,7 @@ package sockets import ( "context" + "fmt" "net" "net/http" "time" @@ -10,7 +11,18 @@ import ( ) func configureUnixTransport(tr *http.Transport, proto, addr string) error { - return ErrProtocolNotAvailable + if len(addr) > 260 { + return fmt.Errorf("unix socket path %q is too long", addr) + } + // No need for compression in local communications. + tr.DisableCompression = true + dialer := &net.Dialer{ + Timeout: defaultTimeout, + } + tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) { + return dialer.DialContext(ctx, proto, addr) + } + return nil } func configureNpipeTransport(tr *http.Transport, proto, addr string) error {