issue #315 unix socket fastcgi

This commit is contained in:
Adam D. Ruppe 2022-01-11 16:19:42 -05:00
parent db81fdca67
commit 6d0d562315
1 changed files with 12 additions and 1 deletions

13
cgi.d
View File

@ -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);