FCGI_ROLE=RESPONDER SCRIPT_FILENAME=/scripts/5.cgi QUERY_STRING=aaa=11111111111111&bbb=2222222222222222&ccc=333333333333333333 REQUEST_METHOD=GET CONTENT_TYPE= CONTENT_LENGTH= SCRIPT_NAME=/5.cgi REQUEST_URI=/5.cgi?aaa=11111111111111&bbb=2222222222222222&ccc=333333333333333333 DOCUMENT_URI=/5.cgi DOCUMENT_ROOT=/home/tools/nginx/html SERVER_PROTOCOL=HTTP/1.1 GATEWAY_INTERFACE=CGI/1.1 SERVER_SOFTWARE=nginx/0.8.52 REMOTE_ADDR=17.17.133.161 REMOTE_PORT=50306 SERVER_ADDR=17.17.110.33 SERVER_PORT=9096 SERVER_NAME=17.17.110.33 REDIRECT_STATUS=200 HTTP_HOST=17.17.110.33:9096 HTTP_CONNECTION=keep-alive HTTP_ACCEPT=application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.215 Safari/534.10 HTTP_ACCEPT_ENCODING=gzip,deflate,sdch HTTP_ACCEPT_LANGUAGE=en-US,en;q=0.8 HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.3
SHELL=/bin/bash TERM=xterm XDG_SESSION_COOKIE=510f514901e514a2096007d54afb8eee-1291949111.149631-1394549368 SSH_CLIENT=17.17.133.161 65395 22 SSH_TTY=/dev/pts/5 USER=root LS_COLORS=rs=0:di=01;34:ln=01;36:hl=44;37:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: SSH_AUTH_SOCK=/tmp/ssh-llchQL2630/agent.2630 PATH=/home/dingfan/server/dataserver/fastcgi/.libs:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games MAIL=/var/mail/root PWD=/home/dingfan/server/dataserver/fastcgi LANG=zh_CN.UTF-8 SPEECHD_PORT=6560 HOME=/root SHLVL=2 LANGUAGE=zh_CN:zh LOGNAME=root SSH_CONNECTION=17.17.133.161 65395 17.17.110.33 22 LESSOPEN=| /usr/bin/lesspipe %s LESSCLOSE=/usr/bin/lesspipe %s %s
/n"; for ( ; *envp; ++envp) { cout << *envp << "/n"; } cout << "/n"; } static long gstdin(FCGX_Request * request, char ** content) { char * clenstr = FCGX_GetParam("CONTENT_LENGTH", request->envp); unsigned long clen = STDIN_MAX; if (clenstr) { clen = strtol(clenstr, &clenstr, 10); if (*clenstr) { cerr << "can't parse /"CONTENT_LENGTH=" << FCGX_GetParam("CONTENT_LENGTH", request->envp) << "/"/n"; clen = STDIN_MAX; } // *always* put a cap on the amount of data that will be read if (clen > STDIN_MAX) clen = STDIN_MAX; *content = new char[clen]; cin.read(*content, clen); clen = cin.gcount(); } else { // *never* read stdin when CONTENT_LENGTH is missing or unparsable *content = 0; clen = 0; } // Chew up any remaining stdin - this shouldn't be necessary // but is because mod_fastcgi doesn't handle it correctly. // ignore() doesn't set the eof bit in some versions of glibc++ // so use gcount() instead of eof()... do cin.ignore(1024); while (cin.gcount() == 1024); return clen; } int main (void) { int count = 0; long pid = getpid(); streambuf * cin_streambuf = cin.rdbuf(); streambuf * cout_streambuf = cout.rdbuf(); streambuf * cerr_streambuf = cerr.rdbuf(); FCGX_Request request; FCGX_Init(); FCGX_InitRequest(&request, 0, 0); while (FCGX_Accept_r(&request) == 0) { // Note that the default bufsize (0) will cause the use of iostream // methods that require positioning (such as peek(), seek(), // unget() and putback()) to fail (in favour of more efficient IO). fcgi_streambuf cin_fcgi_streambuf(request.in); fcgi_streambuf cout_fcgi_streambuf(request.out); fcgi_streambuf cerr_fcgi_streambuf(request.err); #if HAVE_IOSTREAM_WITHASSIGN_STREAMBUF cin = &cin_fcgi_streambuf; cout = &cout_fcgi_streambuf; cerr = &cerr_fcgi_streambuf; #else cin.rdbuf(&cin_fcgi_streambuf); cout.rdbuf(&cout_fcgi_streambuf); cerr.rdbuf(&cerr_fcgi_streambuf); #endif // Although FastCGI supports writing before reading, // many http clients (browsers) don't support it (so // the connection deadlocks until a timeout expires!). char * content; unsigned long clen = gstdin(&request, &content); cout << "Content-type: text/html/r/n" "/r/n" " echo-cpp/n" "