| 1 |
= fcgi - The New generation of FastCGI library for Ruby. |
| 2 |
|
| 3 |
Version 0.9.2.1 |
| 4 |
|
| 5 |
== Depends |
| 6 |
|
| 7 |
=== C version |
| 8 |
* ((<libfcgi|URL:http://www.fastcgi.com/#TheDevKit>))(FastCGI Developer's Kit) |
| 9 |
|
| 10 |
=== Pure Ruby Version |
| 11 |
* StringIO |
| 12 |
|
| 13 |
== Install |
| 14 |
|
| 15 |
$ gem install fcgi |
| 16 |
|
| 17 |
== Usage |
| 18 |
=== Class Method |
| 19 |
--- FCGI.accept |
| 20 |
Returns FCGI instance |
| 21 |
--- FCGI.each |
| 22 |
|
| 23 |
--- FCGI.each_request |
| 24 |
|
| 25 |
--- FCGI.is_cgi? |
| 26 |
|
| 27 |
--- FCGI.each_cgi |
| 28 |
Automatically detects whether this program is running under the FastCGI |
| 29 |
environment, and generates a 'CGI' type object for each request. Also |
| 30 |
installs signal handlers for graceful handling of SIGPIPE (which may |
| 31 |
occur if a client gives up on a request before it is complete) and |
| 32 |
SIGUSR1 (generated by Apache for a 'graceful' exit) |
| 33 |
|
| 34 |
If you are using the HTML output methods you can also pass the HTML type |
| 35 |
e.g. FCGI.each_cgi('html3') do ... end |
| 36 |
|
| 37 |
However, you should beware that the CGI library is quite slow when |
| 38 |
used in this way, as it dynamically adds a large number of methods |
| 39 |
to itself each time a new instance is created. |
| 40 |
|
| 41 |
=== Instance Method |
| 42 |
--- FCGI#finish |
| 43 |
Finish |
| 44 |
|
| 45 |
--- FCGI#in |
| 46 |
Returns Stream or StringIO |
| 47 |
|
| 48 |
--- FCGI#out |
| 49 |
Returns Stream or StringIO |
| 50 |
|
| 51 |
--- FCGI#err |
| 52 |
Returns Stream or StringIO |
| 53 |
|
| 54 |
--- FCGI#env |
| 55 |
Returns Environment(Hash) |
| 56 |
|
| 57 |
== Sample |
| 58 |
|
| 59 |
Using the FastCGI native interface: |
| 60 |
|
| 61 |
#!/usr/bin/ruby |
| 62 |
require "fcgi" |
| 63 |
|
| 64 |
FCGI.each {|request| |
| 65 |
out = request.out |
| 66 |
out.print "Content-Type: text/plain\r\n" |
| 67 |
out.print "\r\n" |
| 68 |
out.print Time.now.to_s |
| 69 |
request.finish |
| 70 |
} |
| 71 |
|
| 72 |
Using the CGI-compatible interface, which works both as a standalone CGI |
| 73 |
and under FastCGI with no modifications: |
| 74 |
|
| 75 |
#!/usr/bin/ruby |
| 76 |
require "fcgi" |
| 77 |
|
| 78 |
FCGI.each_cgi {|cgi| |
| 79 |
name = cgi['name'][0] |
| 80 |
puts cgi.header |
| 81 |
puts "You are #{name} " if name |
| 82 |
puts "Connecting from #{cgi.remote_addr}" |
| 83 |
} |
| 84 |
|
| 85 |
Note: you can't reference CGI environment variables using ENV when under |
| 86 |
FastCGI. It is recommended that you use the CGI-generated methods, e.g. |
| 87 |
cgi.remote_addr as above. |
| 88 |
|
| 89 |
If you need to access environment variables directly, perhaps extra ones set |
| 90 |
in your Apache config, then use cgi.env_table['REMOTE_ADDR'] instead. This |
| 91 |
isn't quite as portable because env_table is a private method in the |
| 92 |
standard CGI library. |
| 93 |
|
| 94 |
== License |
| 95 |
|
| 96 |
* ((<URL:http://www.ruby-lang.org/ja/LICENSE.txt>)) (Japanese) |
| 97 |
* ((<URL:http://www.ruby-lang.org/en/LICENSE.txt>)) (English) |
| 98 |
|
| 99 |
== Copyright |
| 100 |
|
| 101 |
fcgi.c 0.1 Copyright (C) 1998-1999 Network Applied Communication Laboratory, Inc. |
| 102 |
0.8 Copyright (C) 2002 MoonWolf <[email protected]> |
| 103 |
0.9 Copyright (C) 2013 mva <[email protected]> Alpha, LLC |
| 104 |
|
| 105 |
fastcgi.rb 0.7 Copyright (C) 2001 Eli Green |
| 106 |
fcgi.rb 0.8 Copyright (C) 2002 MoonWolf <[email protected]> |
| 107 |
fcgi.rb 0.8.5 Copyright (C) 2004 Minero Aoki |
| 108 |
|