Skip to content

Commit 5465024

Browse files
committed
Add support for fcgi through unix sockets
1 parent 47ce04e commit 5465024

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

dialer.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ type Dialer interface {
1414
Dial() (net.Conn, error)
1515
}
1616

17-
type TCPDialer struct {
17+
type NetDialer struct {
18+
net string
1819
addr string
1920
}
2021

21-
func (d TCPDialer) Dial() (net.Conn, error) {
22-
return net.Dial("tcp", d.addr)
22+
func (d NetDialer) Dial() (net.Conn, error) {
23+
return net.Dial(d.net, d.addr)
2324
}
2425

2526
// StdinDialer managers an app as a child process, creating a socket and passing it through stdin.
@@ -40,7 +41,7 @@ func (sd *StdinDialer) Dial() (net.Conn, error) {
4041
}
4142

4243
func (sd *StdinDialer) Start() error {
43-
// Create a socket.
44+
// Create a socket.
4445
// We'll use the high-level net API, creating a listener that does all sorts
4546
// of socket stuff, getting its file, and passing that (really just for its FD)
4647
// to the child process.

gofcgisrv.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ type FCGIRequester struct {
4949
MaxRequests int
5050
}
5151

52-
// NewServer creates a server that will attempt to connect to the application at the given address over TCP.
53-
func NewFCGI(applicationAddr string) *FCGIRequester {
52+
// NewServer creates a server that will attempt to connect to the application at the given address
53+
// over the specified network (typically 'tcp' or 'unix')
54+
func NewFCGI(net, applicationAddr string) *FCGIRequester {
5455
s := &FCGIRequester{}
55-
s.dialer = TCPDialer{addr: applicationAddr}
56+
s.dialer = NetDialer{net: net, addr: applicationAddr}
5657
s.MaxConns = 1
5758
s.MaxRequests = 1
5859
s.reqCond = sync.NewCond(&s.reqLock)

py_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestPyServer(t *testing.T) {
4343
defer cmd.Process.Kill()
4444

4545
waitForConn("127.0.0.1:9001", time.Second)
46-
s := NewFCGI("127.0.0.1:9001")
46+
s := NewFCGI("tcp", "127.0.0.1:9001")
4747
testRequester(t, httpTestData{
4848
name: "py fastcgi",
4949
f: s,

server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestFCGI(t *testing.T) {
3737
defer l.Close()
3838

3939
// Now start an http server.
40-
s := NewFCGI(addr)
40+
s := NewFCGI("tcp", addr)
4141
http.Handle("/", s)
4242
server := httptest.NewServer(nil)
4343
defer server.Close()

0 commit comments

Comments
 (0)