There is no C version of 'each_cgi' Note: for ruby-1.6.8 at least, the constants CGI_PARAMS/CGI_COOKIES are defined within module 'CGI', even if you have subclassed it
Record types
FCGI_BEGIN_REQUEST.flags
FCGI_END_REQUEST.protocolStatus
FCGI_BEGIN_REQUSET.role
static VALUE fcgi_s_accept(VALUE self) { int status; FCGX_Request *req; fd_set readfds; req = ALLOC(FCGX_Request); status = FCGX_InitRequest(req,0,0); if (status != 0) { rb_raise(eFCGIError, "FCGX_Init() failed"); return Qnil; } FD_ZERO(&readfds); FD_SET(req->listen_sock, &readfds); if (rb_thread_select(req->listen_sock+1, &readfds, NULL, NULL, NULL) < 1) { return Qnil; } status = FCGX_Accept_r(req); if (status >= 0) { fcgi_data *data; char **env; VALUE obj,key, value; char *pkey,*pvalue; int flags, fd; /* Unset NONBLOCKING */ fd = ((FCGX_Request*) req)->ipcFd; flags = fcntl(fd, F_GETFL); if (flags & O_NONBLOCK) { fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); } obj = Data_Make_Struct(self, fcgi_data, fcgi_mark, fcgi_free_req, data); data->req = req; data->in = Data_Wrap_Struct(cFCGIStream, 0, 0, req->in); data->out = Data_Wrap_Struct(cFCGIStream, 0, 0, req->out); data->err = Data_Wrap_Struct(cFCGIStream, 0, 0, req->err); data->env = rb_hash_new(); env = req->envp; for (; *env; env++) { int size = 0; pkey = *env; pvalue = pkey; while( *(pvalue++) != '=') size++; key = rb_str_new(pkey, size); value = rb_str_new2(pvalue); OBJ_TAINT(key); OBJ_TAINT(value); rb_hash_aset(data->env, key, value); } return obj; } else { return Qnil; } }
# File lib/fcgi.rb, line 48 def self::default_connection ::Socket.for_fd($stdin.fileno) end
static VALUE fcgi_s_each(VALUE self) { VALUE fcgi; while ((fcgi = fcgi_s_accept(self)) != Qnil) { rb_yield(fcgi); } return Qnil; }
# File lib/fcgi.rb, line 567 def self::each_cgi(*args) require 'cgi' eval(" class CGI public :env_table def self::remove_params if (const_defined?(:CGI_PARAMS)) remove_const(:CGI_PARAMS) remove_const(:CGI_COOKIES) end end end # ::CGI class class FCGI class CGI < ::CGI def initialize(request, *args) ::CGI.remove_params @request = request super(*args) @args = *args end def args @args end def env_table @request.env end def stdinput @request.in end def stdoutput @request.out end end # FCGI::CGI class end # FCGI class ",TOPLEVEL_BINDING) if FCGI::is_cgi? yield ::CGI.new(*args) else exit_requested = false FCGI::each {|request| $stdout, $stderr = request.out, request.err yield CGI.new(request, *args) request.finish } end end
static VALUE fcgi_s_each(VALUE self) { VALUE fcgi; while ((fcgi = fcgi_s_accept(self)) != Qnil) { rb_yield(fcgi); } return Qnil; }
static VALUE fcgi_s_iscgi(VALUE self) { if (FCGX_IsCGI()) { return Qtrue; } else { return Qfalse; } }
static VALUE fcgi_env(VALUE self) { fcgi_data *data; Data_Get_Struct(self, fcgi_data, data); return data->env; }
static VALUE fcgi_err(VALUE self) { fcgi_data *data; Data_Get_Struct(self, fcgi_data, data); return data->err; }
static VALUE fcgi_finish(VALUE self) { fcgi_data *data; Data_Get_Struct(self, fcgi_data, data); FCGX_Finish_r(data->req); return Qtrue; }
static VALUE fcgi_in(VALUE self) { fcgi_data *data; Data_Get_Struct(self, fcgi_data, data); return data->in; }
static VALUE fcgi_out(VALUE self) { fcgi_data *data; Data_Get_Struct(self, fcgi_data, data); return data->out; }