Path: blob/master/pkg/httpclientutil/httpclientutil_windows.go
2613 views
// SPDX-FileCopyrightText: Copyright The Lima Authors1// SPDX-License-Identifier: Apache-2.023package httpclientutil45import (6"context"7"net"8"net/http"9"os"10)1112// NewHTTPClientWithSocketPath creates a client.13// socketPath is a path to the UNIX socket, without unix:// prefix.14func NewHTTPClientWithSocketPath(socketPath string) (*http.Client, error) {15// Use Lstat on windows, see: https://github.com/adrg/xdg/pull/1416if _, err := os.Lstat(socketPath); err != nil {17return nil, err18}19hc := &http.Client{20Transport: &http.Transport{21DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {22var d net.Dialer23return d.DialContext(ctx, "unix", socketPath)24},25},26}27return hc, nil28}293031