Pretty much. The issue was that go only ever reads environment
variables and populates os.Environ() once - at program start. Changed
the fcgi wrapper to pull the envvars from **environ and put them into
the Go environment.
// fastcgi.go
package fastcgi
/*
#include <stdio.h>
#include <stdlib.h>
#include <fcgi_stdio.h>
extern char **environ;
char *envvar(int index)
{
return environ[index];
}
*/
import "C"
import "os"
import "fmt"
import "strings"
func Accept() (int)
{
retVal := int(C.FCGI_Accept());
for i, next := 0, true; next; i++
{
s := C.GoString(C.envvar(C.int(i)));
if (len(s) > 0)
{
keyVal := strings.Split(s, "=", 2);
os.Setenv(keyVal[0], keyVal[1]);
}
else
{
next = false;
}
}
return retVal;
> > > But, the reason to useFastCGIis because HTTP is a ridiculous
> > > protocol... and no one serves it "properly" except the real web
> > > servers. Also,FastCGIis "Fast", people say.
>
> > > But only if you use it right: thou shalt multiplex!
>
> > >FastCGIis actually a _dog_ of a protocol; if you don't multiplex, you
> > > are just wasting time on all it's ridiculous overhead. (What a cleaner
> > > protocol could do in 1 read + 1 write,FastCGIsplits into 5+ reads,
> > > It's a workingFastCGIimplementation in pure Go.
>
> > > It only supports running in TCP Responder mode (it doesn't support
> > > dynamic spawning IOW)... but this allows for distributed load-
> > > balancing (one of the points ofFastCGI).
>
> > > There is still an outstanding bug with net.Conn.Close(), so fcgigo
> > > can't support multiplexing yet, but once that race condition bug is
> > > fixed, one small code change will re-enable it...
>
> > > (Also, you useFastCGIbecause HTTP is a ridiculous protocol to
> > > implement 100% correctly, so one should just let web servers implement
> > > it, instead of having 9000 http server libraries in every language
> > > that all do the caching edge cases differently... the built-in http
> > > server is just for bare bones local testing purposes only... )
>
> > > What fcgigo will eventually (very soon) be is an HTTP->FastCGI->WSGI
> > > bridge.
>
> > > Fast and highly concurrent WSGI apps in Go, yay! :)
>
> > > For some reason,FastCGIdevelopment has been hijacked by PHP's
> > > retarded implementation of it... and all of the web servers just
> > > follow suit... no one uses GET_VALUES, no one multiplexes, no one
> > > honors keep-alive or FCGI_KEEPCONN. All because PHP doesn't, so, "why
> > > bother?". Lighttpd is THE WORST about this. They have no intention
> > > of ever writing a realFastCGIprotocol... they just have their
> > > "FastPHP" protocol instead... which is just a total waste of time for
> > > everyone involved...
>
> > > On Nov 16, 1:45 pm, murodese <
rawr...@gmail.com> wrote:
>
> > > > Why useFastCGIrather than Go's inbuilt http package? So it can co-
> > > > //fastcgi.Puts() will be enough in most cases