blob: 386cf0dbbdecb12396e9c2c3e6d5d3c36ab5a552 [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// +build !windows
2
3package sockets
4
5import (
6 "fmt"
7 "net"
8 "net/http"
9 "syscall"
10 "time"
11)
12
13const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path)
14
15func configureUnixTransport(tr *http.Transport, proto, addr string) error {
16 if len(addr) > maxUnixSocketPathSize {
17 return fmt.Errorf("Unix socket path %q is too long", addr)
18 }
19 // No need for compression in local communications.
20 tr.DisableCompression = true
21 tr.Dial = func(_, _ string) (net.Conn, error) {
22 return net.DialTimeout(proto, addr, defaultTimeout)
23 }
24 return nil
25}
26
27func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
28 return ErrProtocolNotAvailable
29}
30
31// DialPipe connects to a Windows named pipe.
32// This is not supported on other OSes.
33func DialPipe(_ string, _ time.Duration) (net.Conn, error) {
34 return nil, syscall.EAFNOSUPPORT
35}