From 6d0d5623158e171bb72202dc518b745ade1ab98a Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Tue, 11 Jan 2022 16:19:42 -0500 Subject: [PATCH] issue #315 unix socket fastcgi --- cgi.d | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cgi.d b/cgi.d index e5dfcbe..a2a7ada 100644 --- a/cgi.d +++ b/cgi.d @@ -4016,7 +4016,18 @@ void serveFastCgi(alias fun, CustomCgi = Cgi, long maxContentLength = defaultMax // if a listening port was specified on the command line, we want to spawn ourself // (needed for nginx without spawn-fcgi, e.g. on Windows) FCGX_Init(); - auto sock = FCGX_OpenSocket(toStringz(params.listeningHost ~ ":" ~ to!string(lp)), 12); + + int sock; + + auto host = params.listeningHost; + if(host.startsWith("unix:")) { + sock = FCGX_OpenSocket(toStringz(params.listeningHosa["unix:".length .. $]), 12); + } else if(host.startsWith("abstract:")) { + sock = FCGX_OpenSocket(toStringz("\0" ~ params.listeningHosa["abstract:".length .. $]), 12); + } else { + sock = FCGX_OpenSocket(toStringz(params.listeningHost ~ ":" ~ to!string(lp)), 12); + } + if(sock < 0) throw new Exception("Couldn't listen on the port"); FCGX_InitRequest(&request, sock, 0);