diff --git a/config.go b/config.go index 2efa4ce..44895b5 100644 --- a/config.go +++ b/config.go @@ -10,7 +10,6 @@ import ( "regexp" "strconv" "strings" - "time" "github.com/kballard/go-shellquote" "github.com/yookoala/gofast" @@ -60,7 +59,7 @@ type serverConfig struct { hostname string port int - fcgiPools map[string]*gofast.ClientPool + fcgiPools map[string]gofast.ConnFactory } var config *serverConfig @@ -102,7 +101,7 @@ func readconfig(configPath string) error { } } - config.fcgiPools = make(map[string]*gofast.ClientPool) + config.fcgiPools = make(map[string]gofast.ConnFactory) for hostname, host := range config.Hosts { if host.Cert == "" || host.Key == "" { log.Fatal("a certificate must be specified for each domain (gemini requires TLS for all connections)") @@ -140,9 +139,7 @@ func readconfig(configPath string) error { log.Fatalf("failed to parse fastcgi resource %s: %s", serve.FastCGI, err) } - connFactory := gofast.SimpleConnFactory(f.Scheme, f.Host+f.Path) - clientFactory := gofast.SimpleClientFactory(connFactory, 0) - config.fcgiPools[serve.FastCGI] = gofast.NewClientPool(clientFactory, 1, 1*time.Minute) + config.fcgiPools[serve.FastCGI] = gofast.SimpleConnFactory(f.Scheme, f.Host+f.Path) } } else if serve.Command != "" { serve.cmd, err = shellquote.Split(serve.Command) diff --git a/server_fcgi.go b/server_fcgi.go index 2e10b8d..1cc7369 100644 --- a/server_fcgi.go +++ b/server_fcgi.go @@ -32,22 +32,27 @@ func (w *responseWriter) WriteHeader(statusCode int) { // Do nothing } -func serveFastCGI(c net.Conn, clientPool *gofast.ClientPool, reqURL *url.URL, filePath string) { +func serveFastCGI(c net.Conn, connFactory gofast.ConnFactory, u *url.URL, filePath string) { + header := map[string][]string{ + "Accept": {"*/*"}, + "Host": {u.Hostname()}, + } + r := &http.Request{ Method: "GET", - URL: reqURL, + URL: u, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, - Header: make(http.Header), + Header: header, Body: ioutil.NopCloser(bytes.NewReader(nil)), - Host: reqURL.Host, + Host: u.Host, } gofast. NewHandler( gofast.NewFileEndpoint(filePath)(gofast.BasicSession), - clientPool.CreateClient, + gofast.SimpleClientFactory(connFactory, 0), ). ServeHTTP(newResponseWriter(c), r)