GithubHelp home page GithubHelp logo

ruby-fcgi's Introduction

fcgi - FastCGI library for Ruby

Version 0.8.9

Depends

C version

* ((<libfcgi|URL:http://www.fastcgi.com/#TheDevKit>))(FastCGI Developer's Kit)

Pure Ruby Version

* StringIO

Install

$ ruby install.rb config
  (Pure Ruby Version: ruby install.rb config --without-ext)
  (Some systems need: ruby install.rb config -- --with-fcgi-include=/usr/local/include --with-fcgi-lib=/usr/local/lib)
$ ruby install.rb setup
# ruby install.rb install

Usage

Class Method

— FCGI.accept

Returns FCGI instance

— FCGI.each

— FCGI.each_request

— FCGI.is_cgi?

— FCGI.each_cgi

Automatically detects whether this program is running under the FastCGI
environment, and generates a 'CGI' type object for each request. Also
installs signal handlers for graceful handling of SIGPIPE (which may
occur if a client gives up on a request before it is complete) and
SIGUSR1 (generated by Apache for a 'graceful' exit)

If you are using the HTML output methods you can also pass the HTML type
e.g. FCGI.each_cgi('html3') do ... end

However, you should beware that the CGI library is quite slow when
used in this way, as it dynamically adds a large number of methods
to itself each time a new instance is created.

Instance Method

— FCGI#finish

Finish

— FCGI#in

Returns Stream or StringIO

— FCGI#out

Returns Stream or StringIO

— FCGI#err

Returns Stream or StringIO

— FCGI#env

Returns Environment(Hash)

Sample

Using the FastCGI native interface:

#!/usr/bin/ruby
require "fcgi"

FCGI.each {|request|
  out = request.out
  out.print "Content-Type: text/plain\r\n"
  out.print "\r\n"
  out.print Time.now.to_s
  request.finish
}

Using the CGI-compatible interface, which works both as a standalone CGI and under FastCGI with no modifications:

#!/usr/bin/ruby
require "fcgi"

FCGI.each_cgi {|cgi|
  name = cgi['name'][0]
  puts cgi.header
  puts "You are #{name} " if name
  puts "Connecting from #{cgi.remote_addr}"
}

Note: you can’t reference CGI environment variables using ENV when under FastCGI. It is recommended that you use the CGI-generated methods, e.g. cgi.remote_addr as above.

If you need to access environment variables directly, perhaps extra ones set in your Apache config, then use cgi.env_table instead. This isn’t quite as portable because env_table is a private method in the standard CGI library.

License

fcgi.c     0.1   Copyright (C) 1998-1999  Network Applied Communication Laboratory, Inc.
           0.8   Copyright (C) 2002 MoonWolf <[email protected]>

fastcgi.rb 0.7   Copyright (C) 2001 Eli Green
fcgi.rb    0.8   Copyright (C) 2002 MoonWolf <[email protected]>
fcgi.rb    0.8.5 Copyright (C) 2004 Minero Aoki

ruby-fcgi's People

Contributors

saks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ruby-fcgi's Issues

Non encoded post data being decoded

This issue was in the CGI class not FCGI class. It is an issue with the structure of parse and the way the requests are handled. A patch should be submitted if using the CGI class as it is not something that can be fixed easily.

Please close this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.