sockets_windows.go 666 B

12345678910111213141516171819202122232425262728
  1. package sockets
  2. import (
  3. "context"
  4. "net"
  5. "net/http"
  6. "time"
  7. "github.com/Microsoft/go-winio"
  8. )
  9. func configureUnixTransport(tr *http.Transport, proto, addr string) error {
  10. return ErrProtocolNotAvailable
  11. }
  12. func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
  13. // No need for compression in local communications.
  14. tr.DisableCompression = true
  15. tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
  16. return winio.DialPipeContext(ctx, addr)
  17. }
  18. return nil
  19. }
  20. // DialPipe connects to a Windows named pipe.
  21. func DialPipe(addr string, timeout time.Duration) (net.Conn, error) {
  22. return winio.DialPipe(addr, &timeout)
  23. }