-
Notifications
You must be signed in to change notification settings - Fork 2
Using FastCGI protocol
About this protocol you can read more in wiki.
This protocol implement genserver which allows for independence from general app.
Start new fcgi process and start connection with fcgi server
{ok, Pid} = sgi_fcgi:start(1,1), % (FCGI_RESPONDER, FCGI_KEEP_CONN)
We keep pid of process for avoiding copy of data using methods. After this function we keep also connection process.
It icludes list of CGI params and POST pody if exists.
Pid ! {overall, self(), CGIParams, has_body(Http), Body},
But this way slowly than above.
Send Params to server as a pair {Key,Value}
sgi_fcgi:params(Pid, FCGIParams),
Send POST data to a server, using real Pid so without excessive copying
Pid ! {5, Body},
Send the marker that the request is ended
sgi_fcgi:end_req(Pid),
Receive message from server with next tags.
{sgi_fcgi_return, Out, Err} % common respones
sgi_fcgi_return_end % end of the requet, we can retun the answer to a browser
{sgi_fcgi_return_error, Err} % some error
{sgi_fcgi_timeout, Pid} % self timeout
Stop fcgi process with the release of resources. Connection process let go also, of course, if you don't use Multilexer, in that case connection leave after first step.
sgi_fcgi:stop(Pid),