Merge branch 'master' of git@github.com:parasew/instiki

This commit is contained in:
parasew 2009-02-19 22:24:04 +01:00
commit 2e8624be24
916 changed files with 72033 additions and 28531 deletions

0
app/apis/.gitignore vendored Normal file
View file

View file

@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base
def remember_location
if request.method == :get and
response.headers['Status'] == '200 OK' and not \
@status == '200' and not \
%w(locked save back file pic import).include?(action_name)
session[:return_to] = request.request_uri
logger.debug "Session ##{session.object_id}: remembered URL '#{session[:return_to]}'"
@ -115,7 +115,7 @@ class ApplicationController < ActionController::Base
end
def rescue_action_in_public(exception)
if exception.instance_of?(CGI::Session::CookieStore::TamperedWithCookie)
if exception.instance_of?(ActiveController::Session::CookieStore::TamperedWithCookie)
render :text => 'Stale session. Please reload the page.', :status =>500, :layout => 'error'
else
render :status => 500, :text => <<-EOL
@ -241,7 +241,7 @@ module Instiki
module VERSION #:nodoc:
MAJOR = 0
MINOR = 16
TINY = 2
TINY = 3
SUFFIX = '(MML+)'
PRERELEASE = false
if PRERELEASE

View file

@ -18,7 +18,7 @@ class FileController < ApplicationController
new_file = @web.wiki_files.create(params['file'])
if new_file.valid?
flash[:info] = "File '#{@file_name}' successfully uploaded"
redirect_to_page(@page_name)
redirect_to(params['referring_page'])
else
# pass the file with errors back into the form
@file = new_file

View file

@ -1,6 +1,7 @@
<%-
@title = "Upload #{h @file_name}"
@hide_navigation = false
@referring_page ||= request.env["HTTP_REFERER"]
-%>
<%= error_messages_for 'file' %>
@ -8,6 +9,7 @@
<% form_tag({ :controller => 'file', :web => @web_name, :action => 'file' },
{ 'multipart' => true , 'accept-charset' => 'utf-8' }) do %>
<div class="inputFieldWithPrompt">
<input type="hidden" name="referring_page" value="<%= h @referring_page %>" />
<%= hidden_field 'file', 'file_name' %>
<label for="file_content"><b>Content of <%= h @file_name %> to upload</b>:</label>
<br />
@ -15,7 +17,7 @@
<br />
Please note that the file you are uploading will be named <%= h @file_name %> on the wiki -
regardless of how it is named on your computer. To change the wiki name of the file, please go
<%= link_to :back %> and edit the wiki page that refers to the file.
<%= link_to("back", @referring_page) %> and edit the wiki page that refers to the file.
</div>
<div class="inputFieldWithPrompt">
<label for="file_description"><b>Description</b>:</label>

View file

@ -39,14 +39,15 @@
<div id="Container">
<div id="Content">
<h1 id="pageName">
<% if @page and (@page.name == 'HomePage') and %w( show published print ).include?(@action_name) %>
<%= render(:file => 'svg_logo') if @controller.xhtml_enabled? %>
<%- if @page and (@page.name == 'HomePage') and %w( show published print ).include?(@action_name) -%>
<%= h(@web.name) + (@show_diff ? ' (changes)' : '') %>
<% elsif @web %>
<%- elsif @web -%>
<span class="webName"><%= @web.name %></span><br />
<%= @title %>
<% else %>
<%- else -%>
<%= @title %>
<% end %>
<%- end %>
</h1>
<%= render(:file => 'navigation') unless @web.nil? || @hide_navigation %>

View file

@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<%= h headers['Status'] %>
<%= h("#{@status} #{@status_message}") %>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@ -27,7 +27,7 @@
<div id="Error-Container">
<h1>
<%= h headers['Status'] %>
<%= h("#{@status} #{@status_message}") %>
</h1>
<div id="Error-Content">

View file

@ -0,0 +1,10 @@
<span id="svg_logo"><svg version="1.1" width="100%" height="100%" viewBox='0 0 180 197' xmlns='http://www.w3.org/2000/svg'>
<path id="svg_logo_path" fill="#<%= @web ? @web.color : "393" %>" stroke-width='0.5' stroke='#000' d='
M170,60c4,11-1,20-12,25c-9,4-25,3-20,15c5,5,15,0,24,1c11,1,21,11,14,21c-10,15-35,6-48-1c-5-3-27-23-32-10c-1,13,15,10,22,16
c11,4,24,14,34,20c12,10,7,25-9,23c-11-1-22-9-30-16c-5-5-13-18-21-9c-2,6,2,11,5,14c9,9,22,14,22,31c-2,8-12,8-18,4c-4-3-9-8-11-13
c-3-6-5-18-12-18c-14-1-5,28-18,30c-9,2-13-9-12-16c1-14,12-24,21-31c5-4,17-13,10-20c-9-10-19,12-23,16c-7,7-17,16-31,15
c-9-1-18-9-11-17c5-7,14-4,23-6c6-1,15-8,8-15c-5-6-57,2-42-24c7-12,51,4,61,6c6,1,17,4,18-4c2-11-12-7-21-8c-21-2-49-14-49-34
c0-5,3-11,8-11C31,42,34,65,42,67c6,1,9-3,8-9C49,49,38,40,40,25c1-5,4-15,13-14c10,2,11,18,13,29c1,8,0,24,7,28c15,0,5-22,4-30
C74,23,78,7,87,1c8-4,14,1,16,9c2,11-8,21-2,30c8,2,11-6,14-12c9-14,36-18,30,5c-3,9-12,19-21,24c-6,4-22,10-23,19c-2,14,15,2,18-2
c9-9,20-18,33-22C159,52,166,54,170,60' />
</svg></span>

0
cache/.gitignore vendored Normal file
View file

0
components/.gitignore vendored Normal file
View file

View file

@ -3,10 +3,11 @@
####
# Make sure we are using the latest rexml
rexml_versions = ['', 'vendor/plugins/rexml/lib/'].collect { |v|
rexml_versions = ['', File.dirname(__FILE__) + '/../vendor/plugins/rexml/lib/'].collect { |v|
`ruby -r #{v + 'rexml/rexml'} -e 'p REXML::VERSION'`.split('.').collect {|n| n.to_i} }
$:.unshift('vendor/plugins/rexml/lib') if (rexml_versions[0] <=> rexml_versions[1]) == -1
$:.unshift(File.dirname(__FILE__) + '/../vendor/plugins/rexml/lib') if (rexml_versions[0] <=> rexml_versions[1]) == -1
$:.unshift(File.dirname(__FILE__) + '/../vendor/plugins/rack/lib')
require File.join(File.dirname(__FILE__), 'boot')
require 'active_support/secure_random'

0
dump/fixtures/.gitignore vendored Normal file
View file

View file

@ -1,5 +1,6 @@
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + '/vendor/plugins/rack/lib')
# Executable file for a gem
# must be same as ./instiki.rb

0
lib/native/linux-x86/.gitignore vendored Normal file
View file

View file

@ -5,7 +5,7 @@ module Sanitizer
#
# Based heavily on Sam Ruby's code in the Universal FeedParser.
require 'html/tokenizer'
require 'action_controller/vendor/html-scanner/html/tokenizer'
require 'node'
require 'stringsupport'

View file

@ -85,14 +85,22 @@ class UrlGenerator < AbstractUrlGenerator
end
when :publish
if known_page
web = Web.find_by_address(web_address)
action = web.published? ? 'published' : 'show'
href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action,
href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'published',
:id => name
%{<a class="existingWikiWord" href="#{href}">#{text}</a>}
else
%{<span class="newWikiWord">#{text}</span>}
end
when :show
if known_page
href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'show',
:id => name
%{<a class="existingWikiWord" href="#{href}">#{text}</a>}
else
href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'new',
:id => name
%{<span class="newWikiWord">#{text}<a href="#{href}">?</a></span>}
end
else
if known_page
web = Web.find_by_address(web_address)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
public/images/green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

View file

@ -51,7 +51,7 @@ font-size:100%
h1#pageName {
line-height:1em;
margin:0.2em 0 0;
margin:0.2em 0 0.2em 0;
padding:0;
}
@ -62,6 +62,13 @@ line-height:1em;
padding:0;
}
#svg_logo {
float:left;
margin:.5em .25em 0 -.625em;
width:1.5em;
height:1.625em;
}
a.nav,a.nav:link,a.nav:visited {
background-color:#FFF;
color:#000;

View file

@ -1,65 +1,108 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
# Don't do this. Instead, put it here, where we can customize it.
#require 'commands/server'
require 'webrick'
require 'active_support'
require 'action_controller'
require 'fileutils'
require 'optparse'
OPTIONS = {
:port => 2500,
:ip => "0.0.0.0",
:environment => "production",
:server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
:server_type => WEBrick::SimpleServer,
:mime_types => WEBrick::HTTPUtils::DefaultMimeTypes.merge({
'avi' => 'video/x-msvideo',
'gz' => 'application/x-gzip',
'js' => 'application/x-javascript',
'nb' => 'application/mathematica',
'pdf' => 'application/pdf',
'svg' => 'application/svg+xml',
'tar' => 'application/x-tar',
'tex' => 'application/x-tex',
'xhtml' => 'application/xhtml+xml',
'xml' => 'application/xml',
'xslt' => 'application/xslt+xml'
})
# TODO: Push Thin adapter upstream so we don't need worry about requiring it
begin
require_library_or_gem 'thin'
rescue Exception
# Thin not available
end
options = {
:Port => 2500,
:Host => "0.0.0.0",
:environment => (ENV['RAILS_ENV'] || "production").dup,
:config => RAILS_ROOT + "/config.ru",
:detach => false,
:debugger => false
}
ARGV.options do |opts|
script_name = File.basename($0)
opts.banner = "Usage: ruby #{script_name} [options]"
opts.separator ""
ARGV.clone.options do |opts|
opts.on("-p", "--port=port", Integer,
"Runs Instiki on the specified port.",
"Default: 2500") { }
# "Default: 2500") { |OPTIONS[:port]| }
"Runs Instiki on the specified port.", "Default: 2500") { |v| options[:Port] = v }
opts.on("-b", "--binding=ip", String,
"Binds Instiki to the specified ip.",
"Default: 0.0.0.0") { }
# "Default: 0.0.0.0") { |OPTIONS[:ip]| }
"Binds Instiki to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v }
opts.on("-c", "--config=file", String,
"Use custom rackup configuration file") { |v| options[:config] = v }
opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:detach] = true }
opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true }
opts.on("-e", "--environment=name", String,
"Specifies the environment to run this server under (test/development/production).",
"Default: development") { }
# "Default: development") { |OPTIONS[:environment]| }
opts.on("-d", "--daemon",
"Make Instiki run as a Daemon (only works if fork is available -- meaning on *nix)."
) { OPTIONS[:server_type] = WEBrick::Daemon }
"Default: production") { |v| options[:environment] = v }
opts.separator ""
opts.on("-h", "--help",
"Show this help message.") { puts opts; exit }
opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
opts.parse!
end
ENV["RAILS_ENV"] = OPTIONS[:environment]
require File.dirname(__FILE__) + "/../config/environment"
require 'webrick_server'
server = Rack::Handler.get(ARGV.first) rescue nil
unless server
begin
server = Rack::Handler::Mongrel
rescue LoadError => e
server = Rack::Handler::WEBrick
end
end
OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT)
puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}"
puts "=> Instiki started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
puts "=> Ctrl-C to shutdown; call with --help for options" if OPTIONS[:server_type] == WEBrick::SimpleServer
DispatchServlet.dispatch(OPTIONS)
%w(cache pids sessions sockets).each do |dir_to_make|
FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', dir_to_make))
end
if options[:detach]
Process.daemon
pid = "#{RAILS_ROOT}/tmp/pids/server.pid"
File.open(pid, 'w'){ |f| f.write(Process.pid) }
at_exit { File.delete(pid) if File.exist?(pid) }
end
ENV["RAILS_ENV"] = options[:environment]
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
if File.exist?(options[:config])
config = options[:config]
if config =~ /\.ru$/
cfgfile = File.read(config)
if cfgfile[/^#\\(.*)/]
opts.parse!($1.split(/\s+/))
end
inner_app = eval("Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config)
else
require config
inner_app = Object.const_get(File.basename(config, '.rb').capitalize)
end
else
require RAILS_ROOT + "/config/environment"
inner_app = ActionController::Dispatcher.new
end
app = Rack::Builder.new {
use Rails::Rack::LogTailer unless options[:detach]
use Rails::Rack::Static
use Rails::Rack::Debugger if options[:debugger]
run inner_app
}.to_app
puts "=> Call with -d to detach"
trap(:INT) { exit }
puts "=> Ctrl-C to shutdown server"
begin
server.run(app, options.merge(:AccessLog => []))
ensure
puts 'Exiting'
end

0
storage/.gitignore vendored Normal file
View file

View file

@ -6,7 +6,7 @@ require 'admin_controller'
# Raise errors beyond the default web-based presentation
class AdminController; def rescue_action(e) logger.error(e); raise e end; end
class AdminControllerTest < Test::Unit::TestCase
class AdminControllerTest < ActionController::TestCase
fixtures :webs, :pages, :revisions, :system, :wiki_references
def setup

View file

@ -6,7 +6,7 @@ require 'wiki_controller'
# Need some concrete class to test the abstract class features
class WikiController; def rescue_action(e) logger.error(e); raise e end; end
class ApplicationTest < Test::Unit::TestCase
class ApplicationTest < ActionController::TestCase
fixtures :webs, :pages, :revisions, :system
Mime::LOOKUP["text/html"] = HTML
@ -20,43 +20,43 @@ class ApplicationTest < Test::Unit::TestCase
def test_utf8_header
get :show, :web => 'wiki1', :id => 'HomePage'
assert_equal 'text/html; charset=utf-8', @response.headers['type']
assert_equal 'text/html; charset=utf-8', @response.headers['Content-Type']
end
def test_mathplayer_mime_type
@request.user_agent = 'MathPlayer'
get :show, :web => 'wiki1', :id => 'HomePage'
assert_equal 'application/xhtml+xml', @response.headers['type']
assert_equal 'application/xhtml+xml', @response.headers['Content-Type']
end
def test_validator_mime_type
@request.user_agent = 'Validator'
get :show, :web => 'wiki1', :id => 'HomePage'
assert_equal 'application/xhtml+xml; charset=utf-8', @response.headers['type']
assert_equal 'application/xhtml+xml; charset=utf-8', @response.headers['Content-Type']
end
def test_accept_header_xhtml
@request.user_agent = 'Mozilla/5.0'
@request.env.update({'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' })
get :show, :web => 'wiki1', :id => 'HomePage'
assert_equal 'application/xhtml+xml; charset=utf-8', @response.headers['type']
assert_equal 'application/xhtml+xml; charset=utf-8', @response.headers['Content-Type']
end
def test_accept_header_html
@request.user_agent = 'Foo'
@request.env.update({'HTTP_ACCEPT' => 'text/html,application/xml;q=0.9,*/*;q=0.8' })
get :show, :web => 'wiki1', :id => 'HomePage'
assert_equal 'text/html; charset=utf-8', @response.headers['type']
assert_equal 'text/html; charset=utf-8', @response.headers['Content-Type']
end
def test_tex_mime_type
get :tex, :web => 'wiki1', :id => 'HomePage'
assert_equal 'text/plain; charset=utf-8', @response.headers['type']
assert_equal 'text/plain; charset=utf-8', @response.headers['Content-Type']
end
def test_atom_mime_type
get :atom_with_content, :web => 'wiki1'
assert_equal 'application/atom+xml; charset=utf-8', @response.headers['type']
assert_equal 'application/atom+xml; charset=utf-8', @response.headers['Content-Type']
end
def test_connect_to_model_unknown_wiki

View file

@ -8,7 +8,7 @@ require 'stringio'
# Raise errors beyond the default web-based presentation
class FileController; def rescue_action(e) logger.error(e); raise e end; end
class FileControllerTest < Test::Unit::TestCase
class FileControllerTest < ActionController::TestCase
fixtures :webs, :pages, :revisions, :system
def setup
@ -41,7 +41,7 @@ class FileControllerTest < Test::Unit::TestCase
assert_response(:success, bypass_body_parsing = true)
assert_equal "Contents of the file", r.body
assert_equal 'text/plain', r.headers['type']
assert_equal 'text/plain', r.headers['Content-Type']
assert_equal 'inline; filename="foo.txt"', r.headers['Content-Disposition']
end
@ -53,7 +53,7 @@ class FileControllerTest < Test::Unit::TestCase
assert_response(:success, bypass_body_parsing = true)
assert_equal "Contents of the file", r.body
assert_equal 'application/octet-stream', r.headers['type']
assert_equal 'application/octet-stream', r.headers['Content-Type']
assert_equal 'attachment; filename="foo.html"', r.headers['Content-Disposition']
end
@ -65,7 +65,7 @@ class FileControllerTest < Test::Unit::TestCase
assert_response(:success, bypass_body_parsing = true)
assert_equal "aaa\nbbb\n", r.body
assert_equal 'application/pdf', r.headers['type']
assert_equal 'application/pdf', r.headers['Content-Type']
end
def test_pic_download_gif
@ -75,7 +75,7 @@ class FileControllerTest < Test::Unit::TestCase
r = get :file, :web => 'wiki1', :id => 'rails.gif'
assert_response(:success, bypass_body_parsing = true)
assert_equal 'image/gif', r.headers['type']
assert_equal 'image/gif', r.headers['Content-Type']
assert_equal pic.size, r.body.size
assert_equal pic, r.body
assert_equal 'inline; filename="rails.gif"', r.headers['Content-Disposition']
@ -89,10 +89,10 @@ class FileControllerTest < Test::Unit::TestCase
end
def test_pic_upload_end_to_end
# edit and re-render home page so that it has an "unknown file" link to 'rails-e2e.gif'
# edit and re-render a page so that it has an "unknown file" link to 'rails-e2e.gif'
PageRenderer.setup_url_generator(StubUrlGenerator.new)
renderer = PageRenderer.new
@wiki.revise_page('wiki1', 'HomePage', '[[rails-e2e.gif:pic]]',
@wiki.revise_page('wiki1', 'Oak', '[[rails-e2e.gif:pic]]',
Time.now, 'AnonymousBrave', renderer)
assert_equal "<p><span class='newWikiWord'>rails-e2e.gif<a href='../file/rails-e2e.gif'>" +
"?</a></span></p>",
@ -112,14 +112,15 @@ class FileControllerTest < Test::Unit::TestCase
# updated from post to get - post fails the spam protection (no javascript)
# Moron! If substituting GET for POST actually works, you
# have much, much bigger problems.
r = get :file, :web => 'wiki1',
r = get :file, :web => 'wiki1', :referring_page => '/wiki1/show/Oak',
:file => {:file_name => 'rails-e2e.gif',
:content => StringIO.new(picture),
:description => 'Rails, end-to-end'}
assert_redirected_to '/wiki1/show/Oak'
assert @web.has_file?('rails-e2e.gif')
assert_equal(picture, WikiFile.find_by_file_name('rails-e2e.gif').content)
PageRenderer.setup_url_generator(StubUrlGenerator.new)
@wiki.revise_page('wiki1', 'HomePage', 'Try [[rails-e2e.gif:pic]] again.',
@wiki.revise_page('wiki1', 'Oak', 'Try [[rails-e2e.gif:pic]] again.',
Time.now, 'AnonymousBrave', renderer)
assert_equal "<p>Try <img alt='Rails, end-to-end' src='../file/rails-e2e.gif'/> again.</p>",
renderer.display_content

View file

@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../test_helper'
require 'action_controller/routing'
class RoutesTest < Test::Unit::TestCase
class RoutesTest < ActionController::TestCase
def test_parse_uri
assert_routing('', :controller => 'wiki', :action => 'index')

View file

@ -13,7 +13,7 @@ require 'zip/zipfilesystem'
# Raise errors beyond the default web-based presentation
class WikiController; def rescue_action(e) logger.error(e); raise e end; end
class WikiControllerTest < Test::Unit::TestCase
class WikiControllerTest < ActionController::TestCase
fixtures :webs, :pages, :revisions, :system, :wiki_references
def setup
@ -30,6 +30,7 @@ class WikiControllerTest < Test::Unit::TestCase
@home = @page = pages(:home_page)
@oak = pages(:oak)
@elephant = pages(:elephant)
@eternity = Regexp.new('author=.*; path=/; expires=' + Time.utc(2030).strftime("%a, %d-%b-%Y %H:%M:%S GMT"))
end
def test_authenticate
@ -37,7 +38,7 @@ class WikiControllerTest < Test::Unit::TestCase
get :authenticate, :web => 'wiki1', :password => 'pswd'
assert_redirected_to :web => 'wiki1', :action => 'show', :id => 'HomePage'
assert_equal ['pswd'], @response.cookies['wiki1']
assert_equal 'pswd', @response.cookies['wiki1']
end
def test_authenticate_wrong_password
@ -118,7 +119,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'export_html', 'web' => 'wiki1'
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['type']
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-xhtml-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
@ -149,7 +150,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'export_html', 'web' => 'wiki1'
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['type']
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
@ -177,7 +178,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'export_html', 'web' => 'wiki1', 'layout' => 'no'
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['type']
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-x?html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
@ -187,7 +188,7 @@ class WikiControllerTest < Test::Unit::TestCase
r = process 'export_markup', 'web' => 'wiki1'
assert_response(:success, bypass_body_parsing = true)
assert_equal 'application/zip', r.headers['type']
assert_equal 'application/zip', r.headers['Content-Type']
assert_match /attachment; filename="wiki1-markdownMML-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/,
r.headers['Content-Disposition']
assert_equal 'PK', r.body[0..1], 'Content is not a zip file'
@ -199,7 +200,7 @@ class WikiControllerTest < Test::Unit::TestCase
# def test_export_pdf
# r = process 'export_pdf', 'web' => 'wiki1'
# assert_response(:success, bypass_body_parsing = true)
# assert_equal 'application/pdf', r.headers['type']
# assert_equal 'application/pdf', r.headers['Content-Type']
# assert_match /attachment; filename="wiki1-tex-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/,
# r.headers['Content-Disposition']
# assert_equal '%PDF', r.body[0..3]
@ -216,7 +217,7 @@ class WikiControllerTest < Test::Unit::TestCase
# r = process 'export_tex', 'web' => 'wiki1'
#
# assert_response(:success, bypass_body_parsing = true)
# assert_equal 'application/octet-stream', r.headers['type']
# assert_equal 'application/octet-stream', r.headers['Content-Type']
# assert_match /attachment; filename="wiki1-tex-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.tex"/,
# r.headers['Content-Disposition']
# assert_equal '\documentclass', r.body[0..13], 'Content is not a TeX file'
@ -296,7 +297,7 @@ class WikiControllerTest < Test::Unit::TestCase
# assert_equal '%PDF', r.body[0..3]
# assert_equal "EOF\n", r.body[-4..-1]
#
# assert_equal 'application/pdf', r.headers['type']
# assert_equal 'application/pdf', r.headers['Content-Type']
# assert_match /attachment; filename="HomePage-wiki1-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.pdf"/,
# r.headers['Content-Disposition']
# end
@ -319,6 +320,13 @@ class WikiControllerTest < Test::Unit::TestCase
assert_response(:success)
assert_equal @home, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='http:\/\/test.host\/wiki1\/published\/ThatWay'>That Way<\/a>/, r.body
r = process('show', 'web' => 'wiki1', 'id' => 'HomePage')
assert_response(:success)
assert_equal @home, r.template_objects['page']
assert_match /<a class='existingWikiWord' href='http:\/\/test.host\/wiki1\/show\/ThatWay'>That Way<\/a>/, r.body
end
@ -584,8 +592,8 @@ class WikiControllerTest < Test::Unit::TestCase
'author' => 'AuthorOfNewPage'
assert_redirected_to :web => 'wiki1', :action => 'show', :id => 'NewPage'
assert_equal ['AuthorOfNewPage'], r.cookies['author'].value
assert_equal Time.utc(2030), r.cookies['author'].expires
assert_equal 'AuthorOfNewPage', r.cookies['author']
assert_match @eternity, r.headers["Set-Cookie"][0]
new_page = @wiki.read_page('wiki1', 'NewPage')
assert_equal 'Contents of a new page', new_page.content
assert_equal 'AuthorOfNewPage', new_page.author
@ -596,8 +604,8 @@ class WikiControllerTest < Test::Unit::TestCase
'author' => 'AuthorOfNewPage'
assert_redirected_to :web => 'wiki1', :action => 'new', :id => 'NewPage', :content => ''
assert_equal ['AuthorOfNewPage'], r.cookies['author'].value
assert_equal Time.utc(2030), r.cookies['author'].expires
assert_equal 'AuthorOfNewPage', r.cookies['author']
assert_match @eternity, r.headers["Set-Cookie"][0]
end
def test_save_not_utf8_ncr
@ -605,8 +613,8 @@ class WikiControllerTest < Test::Unit::TestCase
'author' => 'AuthorOfNewPage'
assert_redirected_to :web => 'wiki1', :action => 'new', :id => 'NewPage'
assert_equal ['AuthorOfNewPage'], r.cookies['author'].value
assert_equal Time.utc(2030), r.cookies['author'].expires
assert_equal 'AuthorOfNewPage', r.cookies['author']
assert_match @eternity, r.headers["Set-Cookie"][0]
end
def test_save_not_utf8_dec_ncr
@ -614,8 +622,8 @@ class WikiControllerTest < Test::Unit::TestCase
'author' => 'AuthorOfNewPage'
assert_redirected_to :web => 'wiki1', :action => 'new', :id => 'NewPage'
assert_equal ['AuthorOfNewPage'], r.cookies['author'].value
assert_equal Time.utc(2030), r.cookies['author'].expires
assert_equal 'AuthorOfNewPage', r.cookies['author']
assert_match @eternity, r.headers["Set-Cookie"][0]
end
def test_save_new_revision_of_existing_page
@ -626,7 +634,7 @@ class WikiControllerTest < Test::Unit::TestCase
'author' => 'Batman'
assert_redirected_to :web => 'wiki1', :action => 'show', :id => 'HomePage'
assert_equal ['Batman'], r.cookies['author'].value
assert_equal 'Batman', r.cookies['author']
home_page = @wiki.read_page('wiki1', 'HomePage')
assert_equal current_revisions+1, home_page.revisions.size
assert_equal 'Revised HomePage', home_page.content
@ -645,7 +653,7 @@ class WikiControllerTest < Test::Unit::TestCase
:content => 'HisWay would be MyWay $\sin(x)\begin{svg}<svg/>\end{svg}\includegraphics[width' +
'=3em]{foo}$ in kinda ThatWay in HisWay though MyWay \OverThere -- see SmartEng' +
'ine in that SmartEngineGUI'
assert_equal ['Batman'], r.cookies['author'].value
assert_equal 'Batman', r.cookies['author']
home_page = @wiki.read_page('wiki1', 'HomePage')
assert_equal current_revisions, home_page.revisions.size
assert_equal 'DavidHeinemeierHansson', home_page.author

0
test/mocks/development/.gitignore vendored Normal file
View file

0
test/mocks/test/.gitignore vendored Normal file
View file

View file

@ -4,8 +4,7 @@ ENV['RAILS_ENV'] = 'test'
# File.expand_path can be removed if Ruby 1.9 is in use.
require File.expand_path(File.dirname(__FILE__) + '/../config/environment')
require 'test/unit'
require 'active_record/fixtures'
require 'test_help'
require 'wiki_content'
require 'url_generator'
require 'digest/sha1'
@ -17,10 +16,12 @@ class FakeSessionDbMan
end
end
Test::Unit::TestCase.pre_loaded_fixtures = false
Test::Unit::TestCase.use_transactional_fixtures = true
Test::Unit::TestCase.use_instantiated_fixtures = false
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
class ActiveSupport::TestCase
self.pre_loaded_fixtures = false
self.use_transactional_fixtures = true
self.use_instantiated_fixtures = false
self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
end
# activate PageObserver
PageObserver.instance

View file

@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class PageRendererTest < Test::Unit::TestCase
class PageRendererTest < ActiveSupport::TestCase
fixtures :webs, :pages, :revisions, :system, :wiki_references
def setup

View file

@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class PageTest < Test::Unit::TestCase
class PageTest < ActiveSupport::TestCase
fixtures :webs, :pages, :revisions, :system
def setup

View file

@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
#require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class WebTest < Test::Unit::TestCase
class WebTest < ActiveSupport::TestCase
fixtures :system, :webs, :pages, :revisions, :wiki_references
def setup

View file

@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'fileutils'
class WikiFileTest < Test::Unit::TestCase
class WikiFileTest < ActiveSupport::TestCase
include FileUtils
fixtures :webs, :pages, :revisions, :system, :wiki_references

0
tmp/.gitignore vendored Normal file
View file

0
tmp/cache/.gitignore vendored Normal file
View file

0
tmp/pids/.gitignore vendored Normal file
View file

0
tmp/sessions/.gitignore vendored Normal file
View file

0
tmp/sockets/.gitignore vendored Normal file
View file

View file

@ -14,7 +14,7 @@ module FormSpamProtection
def protect_form_handler_from_spam
unless request.get? || request.xml_http_request?
if params[:_form_key] && session[:form_keys]
key = session.dbman.generate_digest(params[:_form_key])
key = Digest::SHA1.hexdigest(params[:_form_key])
if session[:form_keys].keys.include?(key)
session[:form_keys][key][1] += 1
if session[:form_keys][key][1] >= 4

View file

@ -8,7 +8,7 @@ module ActionView
if name == :form && @protect_form_from_spam
session[:form_keys] ||= {}
form_key = Digest::SHA1.hexdigest(self.object_id.to_s + rand.to_s)
session[:form_keys][session.dbman.generate_digest(form_key)] = [Time.now, 0]
session[:form_keys][Digest::SHA1.hexdigest(form_key)] = [Time.now, 0]
if session[:form_keys].length > 30
first = session[:form_keys].values.sort { |a,b| a[0] <=> b[0] } [0]
session[:form_keys].delete(session[:form_keys].index(first))

View file

@ -10,11 +10,28 @@
#| +--------------------------------------------------
#+---------------------------------------------------
OpenDiv = /^[ ]{0,3}\+\-\-+\s*(\{([^{}]*|".*"|'.*')*\})?\s*\-*\s*$/
CloseDiv = /^[ ]{0,3}\=\-\-+\s*(\{([^{}]*|".*"|'.*')*\})?\s*\-*\s*$/
# note these are not enough for parsing the above example:
#OpenDiv = /^[ ]{0,3}\+\-\-+\s*(.*)$/
#CloseDiv = /^[ ]{0,3}\=\-\-+\s*(.*)$/
## These cause Instiki to hang when it encounters
##
## +--
## ###### Definition
## A _Froelicher Space_ is a triple $(X,C_X,F_X)$
## =-- {: .num_defn #FroelicherSpace
##
## or
##
## +-- {: .num_defn #FroelicherSpace
## ###### Definition
## A _Froelicher Space_ is a triple $(X,C_X,F_X)$
## =--
#
#OpenDiv = /^[ ]{0,3}\+\-\-+\s*(\{([^{}]*|".*"|'.*')*\})?\s*\-*\s*$/
#CloseDiv = /^[ ]{0,3}\=\-\-+\s*(\{([^{}]*|".*"|'.*')*\})?\s*\-*\s*$/
#
## note these are not enough for parsing the above example:
## (but they don't produce a hang ...)
#
OpenDiv = /^[ ]{0,3}\+\-\-+\s*(.*)$/
CloseDiv = /^[ ]{0,3}\=\-\-+\s*(.*)$/
StartPipe = /^[ ]{0,3}\|(.*)$/ # $1 is rest of line
DecorativeClosing = OpenDiv

8
vendor/plugins/rack/AUTHORS vendored Normal file
View file

@ -0,0 +1,8 @@
* Christian Neukirchen <chneukirchen@gmail.com>
* HTTP authentication: Tim Fletcher <twoggle@gmail.com>
* Cookie sessions, Static handler: Luc Heinrich <luc@honk-honk.com>
* Pool sessions, OpenID authentication: blink <blinketje@gmail.com>
* Rack::Deflater: Christoffer Sawicki <christoffer.sawicki@gmail.com>
* LiteSpeed handler: Adrian Madrid
* SCGI handler: Jeremy Evans
* Official Logo: Armin Ronacher

18
vendor/plugins/rack/COPYING vendored Normal file
View file

@ -0,0 +1,18 @@
Copyright (c) 2007 Christian Neukirchen <purl.org/net/chneukirchen>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1423
vendor/plugins/rack/ChangeLog vendored Normal file

File diff suppressed because it is too large Load diff

18
vendor/plugins/rack/KNOWN-ISSUES vendored Normal file
View file

@ -0,0 +1,18 @@
= Known issues with Rack and Web servers
* Lighttpd sets wrong SCRIPT_NAME and PATH_INFO if you mount your
FastCGI app at "/". This can be fixed by using this middleware:
class LighttpdScriptNameFix
def initialize(app)
@app = app
end
def call(env)
env["PATH_INFO"] = env["SCRIPT_NAME"].to_s + env["PATH_INFO"].to_s
env["SCRIPT_NAME"] = ""
@app.call(env)
end
end
Of course, use this only when your app runs at "/".

324
vendor/plugins/rack/RDOX vendored Normal file
View file

@ -0,0 +1,324 @@
== Rack::Auth::Basic
* should challenge correctly when no credentials are specified
* should rechallenge if incorrect credentials are specified
* should return application output if correct credentials are specified
* should return 400 Bad Request if different auth scheme used
== Rack::Auth::Digest::MD5
* should challenge when no credentials are specified
* should return application output if correct credentials given
* should return application output if correct credentials given (hashed passwords)
* should rechallenge if incorrect username given
* should rechallenge if incorrect password given
* should rechallenge with stale parameter if nonce is stale
* should return 400 Bad Request if incorrect qop given
* should return 400 Bad Request if incorrect uri given
* should return 400 Bad Request if different auth scheme used
== Rack::Auth::OpenID
* realm uri should be absolute and have a path
* uri options should be absolute
* return_to should be absolute and be under the realm
* extensions should be a module
* extensions should have required constants defined
* extensions should have Request and Response defined and inherit from OpenID::Extension
* extensions should have NS_URI defined and be a string of an absolute http uri
== Rack::Builder
* chains apps by default
* has implicit #to_app
* supports blocks on use
* has explicit #to_app
* apps are initialized once
== Rack::Adapter::Camping
* works with GET
* works with POST
== Rack::Cascade
* should dispatch onward on 404 by default
* should dispatch onward on whatever is passed
* should fail if empty
* should append new app
== Rack::Handler::CGI
* startup (empty)
* should respond
* should be a lighttpd
* should have rack headers
* should have CGI headers on GET
* should have CGI headers on POST
* should support HTTP auth
* should set status
* shutdown
== Rack::CommonLogger
* should log to rack.errors by default
* should log to anything with <<
== Rack::ConditionalGet
* should set a 304 status and truncate body when If-Modified-Since hits
* should set a 304 status and truncate body when If-None-Match hits
* should not affect non-GET/HEAD requests
== Rack::ContentLength
* sets Content-Length on String bodies if none is set
* sets Content-Length on Array bodies if none is set
* does not set Content-Length on variable length bodies
* does not change Content-Length if it is already set
* does not set Content-Length on 304 responses
* does not set Content-Length when Transfer-Encoding is chunked
== Rack::Deflater
* should be able to deflate bodies that respond to each
* should be able to deflate String bodies
* should be able to gzip bodies that respond to each
* should be able to fallback to no deflation
* should be able to skip when there is no response entity body
* should handle the lack of an acceptable encoding
* should handle gzip response with Last-Modified header
* should do nothing when no-transform Cache-Control directive present
== Rack::Directory
* serves directory indices
* passes to app if file found
* serves uri with URL encoded filenames
* does not allow directory traversal
* 404s if it can't find the file
== Rack::Handler::FastCGI
* startup (empty)
* should respond
* should be a lighttpd
* should have rack headers
* should have CGI headers on GET
* should have CGI headers on POST
* should support HTTP auth
* should set status
* shutdown
== Rack::File
* serves files
* sets Last-Modified header
* serves files with URL encoded filenames
* does not allow directory traversal
* does not allow directory traversal with encoded periods
* 404s if it can't find the file
* detects SystemCallErrors
== Rack::Handler
* has registered default handlers
* should get unregistered handler by name
* should register custom handler
== Rack::Head
* response (empty)
* passes GET, POST, PUT, DELETE, OPTIONS, TRACE requests
* removes body from HEAD requests
== Rack::Lint
* passes valid request
* notices fatal errors
* notices environment errors
* notices input errors
* notices error errors
* notices status errors
* notices header errors
* notices content-type errors
* notices content-length errors
* notices body errors
* notices input handling errors
* notices error handling errors
* notices HEAD errors
== Rack::Lint::InputWrapper
* delegates :size to underlying IO object
* delegates :rewind to underlying IO object
== Rack::Lobster::LambdaLobster
* should be a single lambda
* should look like a lobster
* should be flippable
== Rack::Lobster
* should look like a lobster
* should be flippable
* should provide crashing for testing purposes
== Rack::MethodOverride
* should not affect GET requests
* _method parameter should modify REQUEST_METHOD for POST requests
* X-HTTP-Method-Override header should modify REQUEST_METHOD for POST requests
* should not modify REQUEST_METHOD if the method is unknown
* should not modify REQUEST_METHOD when _method is nil
* should store the original REQUEST_METHOD prior to overriding
== Rack::MockRequest
* should return a MockResponse
* should be able to only return the environment
* should provide sensible defaults
* should allow GET/POST/PUT/DELETE
* should allow posting
* should use all parts of an URL
* should behave valid according to the Rack spec
== Rack::MockResponse
* should provide access to the HTTP status
* should provide access to the HTTP headers
* should provide access to the HTTP body
* should provide access to the Rack errors
* should optionally make Rack errors fatal
== Rack::Handler::Mongrel
* should respond
* should be a Mongrel
* should have rack headers
* should have CGI headers on GET
* should have CGI headers on POST
* should support HTTP auth
* should set status
* should provide a .run
* should provide a .run that maps a hash
* should provide a .run that maps a urlmap
* should provide a .run that maps a urlmap restricting by host
* should stream #each part of the response
== Rack::Recursive
* should allow for subrequests
* should raise error on requests not below the app
* should support forwarding
== Rack::Request
* wraps the rack variables
* can figure out the correct host
* can parse the query string
* can parse POST data
* can parse POST data with explicit content type
* does not parse POST data when media type is not form-data
* rewinds input after parsing POST data
* does not rewind unwindable CGI input
* can get value by key from params with #[]
* can set value to key on params with #[]=
* values_at answers values by keys in order given
* referrer should be extracted correct
* can cache, but invalidates the cache
* can figure out if called via XHR
* can parse cookies
* parses cookies according to RFC 2109
* provides setters
* provides the original env
* can restore the URL
* can restore the full path
* can handle multiple media type parameters
* can parse multipart form data
* can parse big multipart form data
* can detect invalid multipart form data
* should work around buggy 1.8.* Tempfile equality
* does conform to the Rack spec
* should parse Accept-Encoding correctly
* should provide ip information
== Rack::Response
* has sensible default values
* can be written to
* can set and read headers
* can set cookies
* formats the Cookie expiration date accordingly to RFC 2109
* can set secure cookies
* can delete cookies
* has a useful constructor
* has a constructor that can take a block
* doesn't return invalid responses
* knows if it's empty
* should provide access to the HTTP status
* should provide access to the HTTP headers
== Rack::Session::Cookie
* creates a new cookie
* loads from a cookie
* survives broken cookies
* barks on too big cookies
* creates a new cookie with integrity hash
* loads from a cookie wih integrity hash
* ignores tampered with session cookies
== Rack::Session::Memcache
* startup (empty)
* faults on no connection
* creates a new cookie
* determines session from a cookie
* survives broken cookies
* maintains freshness
* multithread: should cleanly merge sessions
* shutdown
== Rack::Session::Pool
* creates a new cookie
* determines session from a cookie
* survives broken cookies
* maintains freshness
* multithread: should merge sessions
== Rack::ShowExceptions
* catches exceptions
== Rack::ShowStatus
* should provide a default status message
* should let the app provide additional information
* should not replace existing messages
* should pass on original headers
* should replace existing messages if there is detail
== Rack::Static
* serves files
* 404s if url root is known but it can't find the file
* calls down the chain if url root is not known
== Rack::Handler::Thin
* should respond
* should be a Thin
* should have rack headers
* should have CGI headers on GET
* should have CGI headers on POST
* should support HTTP auth
* should set status
== Rack::URLMap
* dispatches paths correctly
* dispatches hosts correctly
* should be nestable
* should route root apps correctly
== Rack::Utils
* should escape correctly
* should unescape correctly
* should parse query strings correctly
* should build query strings correctly
* should figure out which encodings are acceptable
== Rack::Utils::HeaderHash
* should retain header case
* should check existence of keys case insensitively
* should merge case-insensitively
* should overwrite case insensitively and assume the new key's case
* should be converted to real Hash
== Rack::Utils::Context
* should perform checks on both arguments
* should set context correctly
* should alter app on recontexting
* should run different apps
== Rack::Handler::WEBrick
* should respond
* should be a WEBrick
* should have rack headers
* should have CGI headers on GET
* should have CGI headers on POST
* should support HTTP auth
* should set status
* should correctly set cookies
* should provide a .run
244 specifications, 4 empty (1004 requirements), 0 failures

306
vendor/plugins/rack/README vendored Normal file
View file

@ -0,0 +1,306 @@
= Rack, a modular Ruby webserver interface
Rack provides a minimal, modular and adaptable interface for developing
web applications in Ruby. By wrapping HTTP requests and responses in
the simplest way possible, it unifies and distills the API for web
servers, web frameworks, and software in between (the so-called
middleware) into a single method call.
The exact details of this are described in the Rack specification,
which all Rack applications should conform to.
== Supported web servers
The included *handlers* connect all kinds of web servers to Rack:
* Mongrel
* EventedMongrel
* SwiftipliedMongrel
* WEBrick
* FCGI
* CGI
* SCGI
* LiteSpeed
* Thin
These web servers include Rack handlers in their distributions:
* Ebb
* Fuzed
* Phusion Passenger (which is mod_rack for Apache)
Any valid Rack app will run the same on all these handlers, without
changing anything.
== Supported web frameworks
The included *adapters* connect Rack with existing Ruby web frameworks:
* Camping
These frameworks include Rack adapters in their distributions:
* Coset
* Halcyon
* Mack
* Maveric
* Merb
* Racktools::SimpleApplication
* Ramaze
* Ruby on Rails
* Sinatra
* Sin
* Vintage
* Waves
Current links to these projects can be found at
http://ramaze.net/#other-frameworks
== Available middleware
Between the server and the framework, Rack can be customized to your
applications needs using middleware, for example:
* Rack::URLMap, to route to multiple applications inside the same process.
* Rack::CommonLogger, for creating Apache-style logfiles.
* Rack::ShowException, for catching unhandled exceptions and
presenting them in a nice and helpful way with clickable backtrace.
* Rack::File, for serving static files.
* ...many others!
All these components use the same interface, which is described in
detail in the Rack specification. These optional components can be
used in any way you wish.
== Convenience
If you want to develop outside of existing frameworks, implement your
own ones, or develop middleware, Rack provides many helpers to create
Rack applications quickly and without doing the same web stuff all
over:
* Rack::Request, which also provides query string parsing and
multipart handling.
* Rack::Response, for convenient generation of HTTP replies and
cookie handling.
* Rack::MockRequest and Rack::MockResponse for efficient and quick
testing of Rack application without real HTTP round-trips.
== rack-contrib
The plethora of useful middleware created the need for a project that
collects fresh Rack middleware. rack-contrib includes a variety of
add-on components for Rack and it is easy to contribute new modules.
* http://github.com/rack/rack-contrib
== rackup
rackup is a useful tool for running Rack applications, which uses the
Rack::Builder DSL to configure middleware and build up applications
easily.
rackup automatically figures out the environment it is run in, and
runs your application as FastCGI, CGI, or standalone with Mongrel or
WEBrick---all from the same configuration.
== Quick start
Try the lobster!
Either with the embedded WEBrick starter:
ruby -Ilib lib/rack/lobster.rb
Or with rackup:
bin/rackup -Ilib example/lobster.ru
By default, the lobster is found at http://localhost:9292.
== Installing with RubyGems
A Gem of Rack is available. You can install it with:
gem install rack
I also provide a local mirror of the gems (and development snapshots)
at my site:
gem install rack --source http://chneukirchen.org/releases/gems/
== Running the tests
Testing Rack requires the test/spec testing framework:
gem install test-spec
There are two rake-based test tasks:
rake test tests all the fast tests (no Handlers or Adapters)
rake fulltest runs all the tests
The fast testsuite has no dependencies outside of the core Ruby
installation and test-spec.
To run the test suite completely, you need:
* camping
* mongrel
* fcgi
* ruby-openid
* memcache-client
The full set of tests test FCGI access with lighttpd (on port
9203) so you will need lighttpd installed as well as the FCGI
libraries and the fcgi gem:
Download and install lighttpd:
http://www.lighttpd.net/download
Installing the FCGI libraries:
curl -O http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure --prefix=/usr/local
make
sudo make install
cd ..
Installing the Ruby fcgi gem:
gem install fcgi
Furthermore, to test Memcache sessions, you need memcached (will be
run on port 11211) and memcache-client installed.
== History
* March 3rd, 2007: First public release 0.1.
* May 16th, 2007: Second public release 0.2.
* HTTP Basic authentication.
* Cookie Sessions.
* Static file handler.
* Improved Rack::Request.
* Improved Rack::Response.
* Added Rack::ShowStatus, for better default error messages.
* Bug fixes in the Camping adapter.
* Removed Rails adapter, was too alpha.
* February 26th, 2008: Third public release 0.3.
* LiteSpeed handler, by Adrian Madrid.
* SCGI handler, by Jeremy Evans.
* Pool sessions, by blink.
* OpenID authentication, by blink.
* :Port and :File options for opening FastCGI sockets, by blink.
* Last-Modified HTTP header for Rack::File, by blink.
* Rack::Builder#use now accepts blocks, by Corey Jewett.
(See example/protectedlobster.ru)
* HTTP status 201 can contain a Content-Type and a body now.
* Many bugfixes, especially related to Cookie handling.
* August 21st, 2008: Fourth public release 0.4.
* New middleware, Rack::Deflater, by Christoffer Sawicki.
* OpenID authentication now needs ruby-openid 2.
* New Memcache sessions, by blink.
* Explicit EventedMongrel handler, by Joshua Peek <josh@joshpeek.com>
* Rack::Reloader is not loaded in rackup development mode.
* rackup can daemonize with -D.
* Many bugfixes, especially for pool sessions, URLMap, thread safety
and tempfile handling.
* Improved tests.
* Rack moved to Git.
* January 6th, 2009: Fifth public release 0.9.
* Rack is now managed by the Rack Core Team.
* Rack::Lint is stricter and follows the HTTP RFCs more closely.
* Added ConditionalGet middleware.
* Added ContentLength middleware.
* Added Deflater middleware.
* Added Head middleware.
* Added MethodOverride middleware.
* Rack::Mime now provides popular MIME-types and their extension.
* Mongrel Header now streams.
* Added Thin handler.
* Official support for swiftiplied Mongrel.
* Secure cookies.
* Made HeaderHash case-preserving.
* Many bugfixes and small improvements.
* January 9th, 2009: Sixth public release 0.9.1.
* Fix directory traversal exploits in Rack::File and Rack::Directory.
== Contact
Please mail bugs, suggestions and patches to
<mailto:rack-devel@googlegroups.com>.
Mailing list archives are available at
<http://groups.google.com/group/rack-devel>.
There is a bug tracker at <http://rack.lighthouseapp.com/>.
Git repository (patches rebased on master are most welcome):
* http://github.com/rack/rack
* http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack.git
You are also welcome to join the #rack channel on irc.freenode.net.
== Thanks
The Rack Core Team, consisting of
* Christian Neukirchen (chneukirchen)
* James Tucker (raggi)
* Josh Peek (josh)
* Michael Fellinger (manveru)
* Ryan Tomayko (rtomayko)
* Scytrin dai Kinthra (scytrin)
would like to thank:
* Adrian Madrid, for the LiteSpeed handler.
* Christoffer Sawicki, for the first Rails adapter and Rack::Deflater.
* Tim Fletcher, for the HTTP authentication code.
* Luc Heinrich for the Cookie sessions, the static file handler and bugfixes.
* Armin Ronacher, for the logo and racktools.
* Aredridel, Ben Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd,
Tom Robinson, and Phil Hagelberg for bug fixing and other
improvements.
* Stephen Bannasch, for bug reports and documentation.
* Gary Wright, for proposing a better Rack::Response interface.
* Jonathan Buch, for improvements regarding Rack::Response.
* Armin Röhrl, for tracking down bugs in the Cookie generator.
* Alexander Kellett for testing the Gem and reviewing the announcement.
* Marcus Rückert, for help with configuring and debugging lighttpd.
* The WSGI team for the well-done and documented work they've done and
Rack builds up on.
* All bug reporters and patch contributers not mentioned above.
== Copyright
Copyright (C) 2007, 2008, 2009 Christian Neukirchen <http://purl.org/net/chneukirchen>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
== Links
Rack:: <http://rack.rubyforge.org/>
Rack's Rubyforge project:: <http://rubyforge.org/projects/rack>
Official Rack repositories:: <http://github.com/rack>
rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
Christian Neukirchen:: <http://chneukirchen.org/>

188
vendor/plugins/rack/Rakefile vendored Normal file
View file

@ -0,0 +1,188 @@
# Rakefile for Rack. -*-ruby-*-
require 'rake/rdoctask'
require 'rake/testtask'
desc "Run all the tests"
task :default => [:test]
desc "Do predistribution stuff"
task :predist => [:chmod, :changelog, :rdoc]
desc "Make an archive as .tar.gz"
task :dist => [:fulltest, :predist] do
sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX SPEC ChangeLog doc"
sh "gzip -f -9 #{release}.tar"
end
# Helper to retrieve the "revision number" of the git tree.
def git_tree_version
if File.directory?(".git")
@tree_version ||= `git describe`.strip.sub('-', '.')
@tree_version << ".0" unless @tree_version.count('.') == 2
else
$: << "lib"
require 'rack'
@tree_version = Rack.release
end
@tree_version
end
def gem_version
git_tree_version.gsub(/-.*/, '')
end
def release
"rack-#{git_tree_version}"
end
def manifest
`git ls-files`.split("\n")
end
desc "Make binaries executable"
task :chmod do
Dir["bin/*"].each { |binary| File.chmod(0775, binary) }
Dir["test/cgi/test*"].each { |binary| File.chmod(0775, binary) }
end
desc "Generate a ChangeLog"
task :changelog do
File.open("ChangeLog", "w") { |out|
`git log -z`.split("\0").map { |chunk|
author = chunk[/Author: (.*)/, 1].strip
date = chunk[/Date: (.*)/, 1].strip
desc, detail = $'.strip.split("\n", 2)
detail ||= ""
detail = detail.gsub(/.*darcs-hash:.*/, '')
detail.rstrip!
out.puts "#{date} #{author}"
out.puts " * #{desc.strip}"
out.puts detail unless detail.empty?
out.puts
}
}
end
desc "Generate RDox"
task "RDOX" do
sh "specrb -Ilib:test -a --rdox >RDOX"
end
desc "Generate Rack Specification"
task "SPEC" do
File.open("SPEC", "wb") { |file|
IO.foreach("lib/rack/lint.rb") { |line|
if line =~ /## (.*)/
file.puts $1
end
}
}
end
desc "Run all the fast tests"
task :test do
sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS'] || '-t "^(?!Rack::Handler|Rack::Adapter|Rack::Session::Memcache|Rack::Auth::OpenID)"'}"
end
desc "Run all the tests"
task :fulltest => [:chmod] do
sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
end
begin
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'fileutils'
rescue LoadError
# Too bad.
else
spec = Gem::Specification.new do |s|
s.name = "rack"
s.version = gem_version
s.platform = Gem::Platform::RUBY
s.summary = "a modular Ruby webserver interface"
s.description = <<-EOF
Rack provides minimal, modular and adaptable interface for developing
web applications in Ruby. By wrapping HTTP requests and responses in
the simplest way possible, it unifies and distills the API for web
servers, web frameworks, and software in between (the so-called
middleware) into a single method call.
Also see http://rack.rubyforge.org.
EOF
s.files = manifest + %w(SPEC RDOX)
s.bindir = 'bin'
s.executables << 'rackup'
s.require_path = 'lib'
s.has_rdoc = true
s.extra_rdoc_files = ['README', 'SPEC', 'RDOX', 'KNOWN-ISSUES']
s.test_files = Dir['test/{test,spec}_*.rb']
s.author = 'Christian Neukirchen'
s.email = 'chneukirchen@gmail.com'
s.homepage = 'http://rack.rubyforge.org'
s.rubyforge_project = 'rack'
s.add_development_dependency 'test-spec'
s.add_development_dependency 'camping'
s.add_development_dependency 'fcgi'
s.add_development_dependency 'memcache-client'
s.add_development_dependency 'mongrel'
s.add_development_dependency 'ruby-openid', '~> 2.0.0'
s.add_development_dependency 'thin'
end
Rake::GemPackageTask.new(spec) do |p|
p.gem_spec = spec
p.need_tar = false
p.need_zip = false
end
end
desc "Generate RDoc documentation"
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.options << '--line-numbers' << '--inline-source' <<
'--main' << 'README' <<
'--title' << 'Rack Documentation' <<
'--charset' << 'utf-8'
rdoc.rdoc_dir = "doc"
rdoc.rdoc_files.include 'README'
rdoc.rdoc_files.include 'KNOWN-ISSUES'
rdoc.rdoc_files.include 'SPEC'
rdoc.rdoc_files.include 'RDOX'
rdoc.rdoc_files.include('lib/rack.rb')
rdoc.rdoc_files.include('lib/rack/*.rb')
rdoc.rdoc_files.include('lib/rack/*/*.rb')
end
task :rdoc => ["SPEC", "RDOX"]
task :pushsite => [:rdoc] do
sh "rsync -avz doc/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/doc/"
sh "rsync -avz site/ chneukirchen@rack.rubyforge.org:/var/www/gforge-projects/rack/"
end
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.test_files = FileList['test/{spec,test}_*.rb']
t.verbose = true # uncomment to see the executed command
t.rcov_opts = ["--text-report",
"-Ilib:test",
"--include-file", "^lib,^test",
"--exclude-only", "^/usr,^/home/.*/src,active_"]
end
rescue LoadError
end

129
vendor/plugins/rack/SPEC vendored Normal file
View file

@ -0,0 +1,129 @@
This specification aims to formalize the Rack protocol. You
can (and should) use Rack::Lint to enforce it.
When you develop middleware, be sure to add a Lint before and
after to catch all mistakes.
= Rack applications
A Rack application is an Ruby object (not a class) that
responds to +call+.
It takes exactly one argument, the *environment*
and returns an Array of exactly three values:
The *status*,
the *headers*,
and the *body*.
== The Environment
The environment must be an true instance of Hash (no
subclassing allowed) that includes CGI-like headers.
The application is free to modify the environment.
The environment is required to include these variables
(adopted from PEP333), except when they'd be empty, but see
below.
<tt>REQUEST_METHOD</tt>:: The HTTP request method, such as
"GET" or "POST". This cannot ever
be an empty string, and so is
always required.
<tt>SCRIPT_NAME</tt>:: The initial portion of the request
URL's "path" that corresponds to the
application object, so that the
application knows its virtual
"location". This may be an empty
string, if the application corresponds
to the "root" of the server.
<tt>PATH_INFO</tt>:: The remainder of the request URL's
"path", designating the virtual
"location" of the request's target
within the application. This may be an
empty string, if the request URL targets
the application root and does not have a
trailing slash.
<tt>QUERY_STRING</tt>:: The portion of the request URL that
follows the <tt>?</tt>, if any. May be
empty, but is always required!
<tt>SERVER_NAME</tt>, <tt>SERVER_PORT</tt>:: When combined with <tt>SCRIPT_NAME</tt> and <tt>PATH_INFO</tt>, these variables can be used to complete the URL. Note, however, that <tt>HTTP_HOST</tt>, if present, should be used in preference to <tt>SERVER_NAME</tt> for reconstructing the request URL. <tt>SERVER_NAME</tt> and <tt>SERVER_PORT</tt> can never be empty strings, and so are always required.
<tt>HTTP_</tt> Variables:: Variables corresponding to the
client-supplied HTTP request
headers (i.e., variables whose
names begin with <tt>HTTP_</tt>). The
presence or absence of these
variables should correspond with
the presence or absence of the
appropriate HTTP header in the
request.
In addition to this, the Rack environment must include these
Rack-specific variables:
<tt>rack.version</tt>:: The Array [0,1], representing this version of Rack.
<tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the request URL.
<tt>rack.input</tt>:: See below, the input stream.
<tt>rack.errors</tt>:: See below, the error stream.
<tt>rack.multithread</tt>:: true if the application object may be simultaneously invoked by another thread in the same process, false otherwise.
<tt>rack.multiprocess</tt>:: true if an equivalent application object may be simultaneously invoked by another process, false otherwise.
<tt>rack.run_once</tt>:: true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar).
The server or the application can store their own data in the
environment, too. The keys must contain at least one dot,
and should be prefixed uniquely. The prefix <tt>rack.</tt>
is reserved for use with the Rack core distribution and must
not be used otherwise.
The environment must not contain the keys
<tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
(use the versions without <tt>HTTP_</tt>).
The CGI keys (named without a period) must have String values.
There are the following restrictions:
* <tt>rack.version</tt> must be an array of Integers.
* <tt>rack.url_scheme</tt> must either be +http+ or +https+.
* There must be a valid input stream in <tt>rack.input</tt>.
* There must be a valid error stream in <tt>rack.errors</tt>.
* The <tt>REQUEST_METHOD</tt> must be a valid token.
* The <tt>SCRIPT_NAME</tt>, if non-empty, must start with <tt>/</tt>
* The <tt>PATH_INFO</tt>, if non-empty, must start with <tt>/</tt>
* The <tt>CONTENT_LENGTH</tt>, if given, must consist of digits only.
* One of <tt>SCRIPT_NAME</tt> or <tt>PATH_INFO</tt> must be
set. <tt>PATH_INFO</tt> should be <tt>/</tt> if
<tt>SCRIPT_NAME</tt> is empty.
<tt>SCRIPT_NAME</tt> never should be <tt>/</tt>, but instead be empty.
=== The Input Stream
The input stream must respond to +gets+, +each+ and +read+.
* +gets+ must be called without arguments and return a string,
or +nil+ on EOF.
* +read+ must be called without or with one integer argument
and return a string, or +nil+ on EOF.
* +each+ must be called without arguments and only yield Strings.
* +close+ must never be called on the input stream.
=== The Error Stream
The error stream must respond to +puts+, +write+ and +flush+.
* +puts+ must be called with a single argument that responds to +to_s+.
* +write+ must be called with a single argument that is a String.
* +flush+ must be called without arguments and must be called
in order to make the error appear for sure.
* +close+ must never be called on the error stream.
== The Response
=== The Status
The status, if parsed as integer (+to_i+), must be greater than or equal to 100.
=== The Headers
The header must respond to each, and yield values of key and value.
The header keys must be Strings.
The header must not contain a +Status+ key,
contain keys with <tt>:</tt> or newlines in their name,
contain keys names that end in <tt>-</tt> or <tt>_</tt>,
but only contain keys that consist of
letters, digits, <tt>_</tt> or <tt>-</tt> and start with a letter.
The values of the header must respond to #each.
The values passed on #each must be Strings
and not contain characters below 037.
=== The Content-Type
There must be a <tt>Content-Type</tt>, except when the
+Status+ is 1xx, 204 or 304, in which case there must be none
given.
=== The Content-Length
There must be a <tt>Content-Length</tt>, except when the
+Status+ is 1xx, 204 or 304, in which case there must be none
given.
=== The Body
The Body must respond to #each
and must only yield String values.
If the Body responds to #close, it will be called after iteration.
The Body commonly is an Array of Strings, the application
instance itself, or a File-like object.
== Thanks
Some parts of this specification are adopted from PEP333: Python
Web Server Gateway Interface
v1.0 (http://www.python.org/dev/peps/pep-0333/). I'd like to thank
everyone involved in that effort.

172
vendor/plugins/rack/bin/rackup vendored Executable file
View file

@ -0,0 +1,172 @@
#!/usr/bin/env ruby
# -*- ruby -*-
require 'optparse'
automatic = false
server = nil
env = "development"
daemonize = false
pid = nil
options = {:Port => 9292, :Host => "0.0.0.0", :AccessLog => []}
opts = OptionParser.new("", 24, ' ') { |opts|
opts.banner = "Usage: rackup [ruby options] [rack options] [rackup config]"
opts.separator ""
opts.separator "Ruby options:"
lineno = 1
opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line|
eval line, TOPLEVEL_BINDING, "-e", lineno
lineno += 1
}
opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") {
$DEBUG = true
}
opts.on("-w", "--warn", "turn warnings on for your script") {
$-w = true
}
opts.on("-I", "--include PATH",
"specify $LOAD_PATH (may be used more than once)") { |path|
$LOAD_PATH.unshift(*path.split(":"))
}
opts.on("-r", "--require LIBRARY",
"require the library, before executing your script") { |library|
require library
}
opts.separator ""
opts.separator "Rack options:"
opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s|
server = s
}
opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host|
options[:Host] = host
}
opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port|
options[:Port] = port
}
opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e|
env = e
}
opts.on("-D", "--daemonize", "run daemonized in the background") { |d|
daemonize = d ? true : false
}
opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f|
pid = File.expand_path(f)
}
opts.separator ""
opts.separator "Common options:"
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("--version", "Show version") do
require 'rack'
puts "Rack #{Rack.version}"
exit
end
opts.parse! ARGV
}
require 'pp' if $DEBUG
config = ARGV[0] || "config.ru"
if !File.exist? config
abort "configuration #{config} not found"
end
if config =~ /\.ru$/
cfgfile = File.read(config)
if cfgfile[/^#\\(.*)/]
opts.parse! $1.split(/\s+/)
end
require 'rack'
inner_app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app",
nil, config
else
require 'rack'
require config
inner_app = Object.const_get(File.basename(config, '.rb').capitalize)
end
unless server = Rack::Handler.get(server)
# Guess.
if ENV.include?("PHP_FCGI_CHILDREN")
server = Rack::Handler::FastCGI
# We already speak FastCGI
options.delete :File
options.delete :Port
elsif ENV.include?("REQUEST_METHOD")
server = Rack::Handler::CGI
else
begin
server = Rack::Handler::Mongrel
rescue LoadError => e
server = Rack::Handler::WEBrick
end
end
end
p server if $DEBUG
case env
when "development"
app = Rack::Builder.new {
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
use Rack::ShowExceptions
use Rack::Lint
run inner_app
}.to_app
when "deployment"
app = Rack::Builder.new {
use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
run inner_app
}.to_app
when "none"
app = inner_app
end
if $DEBUG
pp app
pp inner_app
end
if daemonize
if RUBY_VERSION < "1.9"
exit if fork
Process.setsid
exit if fork
Dir.chdir "/"
File.umask 0000
STDIN.reopen "/dev/null"
STDOUT.reopen "/dev/null", "a"
STDERR.reopen "/dev/null", "a"
else
Process.daemon
end
if pid
File.open(pid, 'w'){ |f| f.write("#{Process.pid}") }
at_exit { File.delete(pid) if File.exist?(pid) }
end
end
server.run app, options

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 35 KiB

149
vendor/plugins/rack/doc/classes/L2.html vendored Normal file
View file

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: L2</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">L2</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/lib/rack/forward_rb.html">
lib/rack/forward.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
<a href="Rack/Lobster.html">
Rack::Lobster
</a>
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000001">call</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000001" class="method-detail">
<a name="M000001"></a>
<div class="method-heading">
<a href="#M000001" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000001-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/forward.rb, line 47</span>
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
48: <span class="ruby-identifier">s</span>,<span class="ruby-identifier">h</span>,<span class="ruby-identifier">b</span> = <span class="ruby-keyword kw">super</span>
49: [<span class="ruby-identifier">s</span>,<span class="ruby-identifier">h</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value str">&quot;env&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">inspect</span>),<span class="ruby-identifier">b</span>]
50: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,438 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/lib/rack_rb.html">
lib/rack.rb
</a>
<br />
<a href="../files/lib/rack/builder_rb.html">
lib/rack/builder.rb
</a>
<br />
<a href="../files/lib/rack/cascade_rb.html">
lib/rack/cascade.rb
</a>
<br />
<a href="../files/lib/rack/commonlogger_rb.html">
lib/rack/commonlogger.rb
</a>
<br />
<a href="../files/lib/rack/conditionalget_rb.html">
lib/rack/conditionalget.rb
</a>
<br />
<a href="../files/lib/rack/content_length_rb.html">
lib/rack/content_length.rb
</a>
<br />
<a href="../files/lib/rack/deflater_rb.html">
lib/rack/deflater.rb
</a>
<br />
<a href="../files/lib/rack/directory_rb.html">
lib/rack/directory.rb
</a>
<br />
<a href="../files/lib/rack/file_rb.html">
lib/rack/file.rb
</a>
<br />
<a href="../files/lib/rack/forward_rb.html">
lib/rack/forward.rb
</a>
<br />
<a href="../files/lib/rack/handler_rb.html">
lib/rack/handler.rb
</a>
<br />
<a href="../files/lib/rack/head_rb.html">
lib/rack/head.rb
</a>
<br />
<a href="../files/lib/rack/lint_rb.html">
lib/rack/lint.rb
</a>
<br />
<a href="../files/lib/rack/lobster_rb.html">
lib/rack/lobster.rb
</a>
<br />
<a href="../files/lib/rack/methodoverride_rb.html">
lib/rack/methodoverride.rb
</a>
<br />
<a href="../files/lib/rack/mime_rb.html">
lib/rack/mime.rb
</a>
<br />
<a href="../files/lib/rack/mock_rb.html">
lib/rack/mock.rb
</a>
<br />
<a href="../files/lib/rack/recursive_rb.html">
lib/rack/recursive.rb
</a>
<br />
<a href="../files/lib/rack/reloader_rb.html">
lib/rack/reloader.rb
</a>
<br />
<a href="../files/lib/rack/request_rb.html">
lib/rack/request.rb
</a>
<br />
<a href="../files/lib/rack/response_rb.html">
lib/rack/response.rb
</a>
<br />
<a href="../files/lib/rack/showexceptions_rb.html">
lib/rack/showexceptions.rb
</a>
<br />
<a href="../files/lib/rack/showstatus_rb.html">
lib/rack/showstatus.rb
</a>
<br />
<a href="../files/lib/rack/static_rb.html">
lib/rack/static.rb
</a>
<br />
<a href="../files/lib/rack/urlmap_rb.html">
lib/rack/urlmap.rb
</a>
<br />
<a href="../files/lib/rack/utils_rb.html">
lib/rack/utils.rb
</a>
<br />
<a href="../files/lib/rack/adapter/camping_rb.html">
lib/rack/adapter/camping.rb
</a>
<br />
<a href="../files/lib/rack/auth/basic_rb.html">
lib/rack/auth/basic.rb
</a>
<br />
<a href="../files/lib/rack/auth/openid_rb.html">
lib/rack/auth/openid.rb
</a>
<br />
<a href="../files/lib/rack/handler/cgi_rb.html">
lib/rack/handler/cgi.rb
</a>
<br />
<a href="../files/lib/rack/handler/evented_mongrel_rb.html">
lib/rack/handler/evented_mongrel.rb
</a>
<br />
<a href="../files/lib/rack/handler/fastcgi_rb.html">
lib/rack/handler/fastcgi.rb
</a>
<br />
<a href="../files/lib/rack/handler/lsws_rb.html">
lib/rack/handler/lsws.rb
</a>
<br />
<a href="../files/lib/rack/handler/mongrel_rb.html">
lib/rack/handler/mongrel.rb
</a>
<br />
<a href="../files/lib/rack/handler/scgi_rb.html">
lib/rack/handler/scgi.rb
</a>
<br />
<a href="../files/lib/rack/handler/swiftiplied_mongrel_rb.html">
lib/rack/handler/swiftiplied_mongrel.rb
</a>
<br />
<a href="../files/lib/rack/handler/thin_rb.html">
lib/rack/handler/thin.rb
</a>
<br />
<a href="../files/lib/rack/handler/webrick_rb.html">
lib/rack/handler/webrick.rb
</a>
<br />
<a href="../files/lib/rack/session/cookie_rb.html">
lib/rack/session/cookie.rb
</a>
<br />
<a href="../files/lib/rack/session/memcache_rb.html">
lib/rack/session/memcache.rb
</a>
<br />
<a href="../files/lib/rack/session/pool_rb.html">
lib/rack/session/pool.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
require &#8216;cgi&#8216;
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000004">call</a>&nbsp;&nbsp;
<a href="#M000003">release</a>&nbsp;&nbsp;
<a href="#M000002">version</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Module <a href="Rack/Adapter.html" class="link">Rack::Adapter</a><br />
Module <a href="Rack/Auth.html" class="link">Rack::Auth</a><br />
Module <a href="Rack/Handler.html" class="link">Rack::Handler</a><br />
Module <a href="Rack/Mime.html" class="link">Rack::Mime</a><br />
Module <a href="Rack/Session.html" class="link">Rack::Session</a><br />
Module <a href="Rack/Utils.html" class="link">Rack::Utils</a><br />
Class <a href="Rack/Builder.html" class="link">Rack::Builder</a><br />
Class <a href="Rack/Cascade.html" class="link">Rack::Cascade</a><br />
Class <a href="Rack/CommonLogger.html" class="link">Rack::CommonLogger</a><br />
Class <a href="Rack/ConditionalGet.html" class="link">Rack::ConditionalGet</a><br />
Class <a href="Rack/ContentLength.html" class="link">Rack::ContentLength</a><br />
Class <a href="Rack/Deflater.html" class="link">Rack::Deflater</a><br />
Class <a href="Rack/Directory.html" class="link">Rack::Directory</a><br />
Class <a href="Rack/File.html" class="link">Rack::File</a><br />
Class <a href="Rack/ForwardRequest.html" class="link">Rack::ForwardRequest</a><br />
Class <a href="Rack/Forwarder.html" class="link">Rack::Forwarder</a><br />
Class <a href="Rack/Head.html" class="link">Rack::Head</a><br />
Class <a href="Rack/Lint.html" class="link">Rack::Lint</a><br />
Class <a href="Rack/Lobster.html" class="link">Rack::Lobster</a><br />
Class <a href="Rack/MethodOverride.html" class="link">Rack::MethodOverride</a><br />
Class <a href="Rack/MockRequest.html" class="link">Rack::MockRequest</a><br />
Class <a href="Rack/MockResponse.html" class="link">Rack::MockResponse</a><br />
Class <a href="Rack/Recursive.html" class="link">Rack::Recursive</a><br />
Class <a href="Rack/Reloader.html" class="link">Rack::Reloader</a><br />
Class <a href="Rack/Request.html" class="link">Rack::Request</a><br />
Class <a href="Rack/Response.html" class="link">Rack::Response</a><br />
Class <a href="Rack/ShowExceptions.html" class="link">Rack::ShowExceptions</a><br />
Class <a href="Rack/ShowStatus.html" class="link">Rack::ShowStatus</a><br />
Class <a href="Rack/Static.html" class="link">Rack::Static</a><br />
Class <a href="Rack/URLMap.html" class="link">Rack::URLMap</a><br />
</div>
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">VERSION</td>
<td>=</td>
<td class="context-item-value">[0,1]</td>
<td width="3em">&nbsp;</td>
<td class="context-item-desc">
The <a href="Rack.html">Rack</a> protocol <a
href="Rack.html#M000002">version</a> number implemented.
</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000003" class="method-detail">
<a name="M000003"></a>
<div class="method-heading">
<a href="#M000003" class="method-signature">
<span class="method-name">release</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Return the <a href="Rack.html">Rack</a> <a
href="Rack.html#M000003">release</a> as a dotted string.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000003-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack.rb, line 25</span>
25: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">release</span>
26: <span class="ruby-value str">&quot;0.9&quot;</span>
27: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000002" class="method-detail">
<a name="M000002"></a>
<div class="method-heading">
<a href="#M000002" class="method-signature">
<span class="method-name">version</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
Return the <a href="Rack.html">Rack</a> protocol <a
href="Rack.html#M000002">version</a> as a dotted string.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000002-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack.rb, line 20</span>
20: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">version</span>
21: <span class="ruby-constant">VERSION</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;.&quot;</span>)
22: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000004" class="method-detail">
<a name="M000004"></a>
<div class="method-heading">
<a href="#M000004" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000004-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/lobster.rb, line 32</span>
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
33: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
34: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">req</span>.<span class="ruby-constant">GET</span>[<span class="ruby-value str">&quot;flip&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;left&quot;</span>
35: <span class="ruby-identifier">lobster</span> = <span class="ruby-constant">LobsterString</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;\n&quot;</span>).
36: <span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">ljust</span>(<span class="ruby-value">42</span>).<span class="ruby-identifier">reverse</span> }.
37: <span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
38: <span class="ruby-identifier">href</span> = <span class="ruby-value str">&quot;?flip=right&quot;</span>
39: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">req</span>.<span class="ruby-constant">GET</span>[<span class="ruby-value str">&quot;flip&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;crash&quot;</span>
40: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Lobster crashed&quot;</span>
41: <span class="ruby-keyword kw">else</span>
42: <span class="ruby-identifier">lobster</span> = <span class="ruby-constant">LobsterString</span>
43: <span class="ruby-identifier">href</span> = <span class="ruby-value str">&quot;?flip=left&quot;</span>
44: <span class="ruby-keyword kw">end</span>
45:
46: <span class="ruby-identifier">res</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
47: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;&lt;title&gt;Lobstericious!&lt;/title&gt;&quot;</span>
48: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;&lt;pre&gt;&quot;</span>
49: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">lobster</span>
50: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;&lt;/pre&gt;&quot;</span>
51: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">write</span> <span class="ruby-node">&quot;&lt;p&gt;&lt;a href='#{href}'&gt;flip!&lt;/a&gt;&lt;/p&gt;&quot;</span>
52: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;&lt;p&gt;&lt;a href='?flip=crash'&gt;crash!&lt;/a&gt;&lt;/p&gt;&quot;</span>
53: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">finish</span>
54: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack::Adapter</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack::Adapter</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack_rb.html">
lib/rack.rb
</a>
<br />
<a href="../../files/lib/rack/adapter/camping_rb.html">
lib/rack/adapter/camping.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<b>Adapters</b> connect <a href="../Rack.html">Rack</a> with third party
web frameworks.
</p>
<p>
<a href="../Rack.html">Rack</a> includes an adapter for <a
href="Adapter/Camping.html">Camping</a>, see README for other frameworks
supporting <a href="../Rack.html">Rack</a> in their code bases.
</p>
<p>
Refer to the submodules for framework-specific calling details.
</p>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Class <a href="Adapter/Camping.html" class="link">Rack::Adapter::Camping</a><br />
</div>
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Adapter::Camping</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Adapter::Camping</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/adapter/camping_rb.html">
lib/rack/adapter/camping.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000006">call</a>&nbsp;&nbsp;
<a href="#M000005">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000005" class="method-detail">
<a name="M000005"></a>
<div class="method-heading">
<a href="#M000005" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000005-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/adapter/camping.rb, line 4</span>
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
5: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
6: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000006" class="method-detail">
<a name="M000006"></a>
<div class="method-heading">
<a href="#M000006" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000006-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/adapter/camping.rb, line 8</span>
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
9: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
10: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
11: <span class="ruby-identifier">controller</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.input'</span>], <span class="ruby-identifier">env</span>)
12: <span class="ruby-identifier">h</span> = <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">headers</span>
13: <span class="ruby-identifier">h</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
14: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">URI</span>
15: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>
16: <span class="ruby-keyword kw">end</span>
17: <span class="ruby-keyword kw">end</span>
18: [<span class="ruby-identifier">controller</span>.<span class="ruby-identifier">status</span>, <span class="ruby-identifier">controller</span>.<span class="ruby-identifier">headers</span>, [<span class="ruby-identifier">controller</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_s</span>]]
19: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack::Auth</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack::Auth</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack_rb.html">
lib/rack.rb
</a>
<br />
<a href="../../files/lib/rack/auth/basic_rb.html">
lib/rack/auth/basic.rb
</a>
<br />
<a href="../../files/lib/rack/auth/openid_rb.html">
lib/rack/auth/openid.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Module <a href="Auth/Digest.html" class="link">Rack::Auth::Digest</a><br />
Class <a href="Auth/Basic.html" class="link">Rack::Auth::Basic</a><br />
Class <a href="Auth/OpenID.html" class="link">Rack::Auth::OpenID</a><br />
</div>
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Auth::Basic</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Auth::Basic</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/auth/basic_rb.html">
lib/rack/auth/basic.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
AbstractHandler
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Basic.html">Rack::Auth::Basic</a> implements HTTP <a
href="Basic.html">Basic</a> Authentication, as per RFC 2617.
</p>
<p>
Initialize with the <a href="../../Rack.html">Rack</a> application that you
want protecting, and a block that checks if a username and password pair
are valid.
</p>
<p>
See also: <tt>example/protectedlobster.rb</tt>
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000011">call</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Class <a href="Basic/Request.html" class="link">Rack::Auth::Basic::Request</a><br />
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000011" class="method-detail">
<a name="M000011"></a>
<div class="method-heading">
<a href="#M000011" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000011-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/basic.rb, line 15</span>
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
16: <span class="ruby-identifier">auth</span> = <span class="ruby-constant">Basic</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
17:
18: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">unauthorized</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">provided?</span>
19:
20: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">bad_request</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">basic?</span>
21:
22: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">valid?</span>(<span class="ruby-identifier">auth</span>)
23: <span class="ruby-identifier">env</span>[<span class="ruby-value str">'REMOTE_USER'</span>] = <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">username</span>
24:
25: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
26: <span class="ruby-keyword kw">end</span>
27:
28: <span class="ruby-identifier">unauthorized</span>
29: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Auth::Basic::Request</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Auth::Basic::Request</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../../files/lib/rack/auth/basic_rb.html">
lib/rack/auth/basic.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Auth::AbstractRequest
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000012">basic?</a>&nbsp;&nbsp;
<a href="#M000013">credentials</a>&nbsp;&nbsp;
<a href="#M000014">username</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000012" class="method-detail">
<a name="M000012"></a>
<div class="method-heading">
<a href="#M000012" class="method-signature">
<span class="method-name">basic?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000012-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/basic.rb, line 43</span>
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">basic?</span>
44: <span class="ruby-identifier">:basic</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">scheme</span>
45: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000013" class="method-detail">
<a name="M000013"></a>
<div class="method-heading">
<a href="#M000013" class="method-signature">
<span class="method-name">credentials</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000013-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/basic.rb, line 47</span>
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">credentials</span>
48: <span class="ruby-ivar">@credentials</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">&quot;m*&quot;</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/:/</span>, <span class="ruby-value">2</span>)
49: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000014" class="method-detail">
<a name="M000014"></a>
<div class="method-heading">
<a href="#M000014" class="method-signature">
<span class="method-name">username</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000014-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/basic.rb, line 51</span>
51: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">username</span>
52: <span class="ruby-identifier">credentials</span>.<span class="ruby-identifier">first</span>
53: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack::Auth::Digest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack::Auth::Digest</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack_rb.html">
lib/rack.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,807 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Auth::OpenID</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Auth::OpenID</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/auth/openid_rb.html">
lib/rack/auth/openid.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
AbstractHandler
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="OpenID.html">Rack::Auth::OpenID</a> provides a simple method for
permitting openid based logins. It requires the ruby-openid library from
janrain to operate, as well as a rack method of session management.
</p>
<p>
The ruby-openid home page is at <a
href="http://openidenabled.com/ruby-openid">openidenabled.com/ruby-openid</a>/.
</p>
<p>
The <a href="OpenID.html">OpenID</a> specifications can be found at <a
href="http://openid.net/specs/openid-authentication-1_1.html">openid.net/specs/openid-authentication-1_1.html</a>
and <a
href="http://openid.net/specs/openid-authentication-2_0.html">openid.net/specs/openid-authentication-2_0.html</a>.
Documentation for published <a href="OpenID.html">OpenID</a> extensions and
related topics can be found at <a
href="http://openid.net/developers/specs">openid.net/developers/specs</a>/.
</p>
<p>
It is recommended to read through the <a href="OpenID.html">OpenID</a>
spec, as well as ruby-openid&#8216;s documentation, to understand what
exactly goes on. However a setup as simple as the presented examples is
enough to provide functionality.
</p>
<p>
This library strongly intends to utilize the <a
href="OpenID.html">OpenID</a> 2.0 features of the ruby-openid library,
while maintaining <a href="OpenID.html">OpenID</a> 1.0 compatiblity.
</p>
<p>
All responses from this rack application will be 303 redirects unless an
error occurs, with the exception of an authentication request requiring an
HTML form submission.
</p>
<p>
NOTE: Extensions are not currently supported by this implimentation of the
<a href="OpenID.html">OpenID</a> rack application due to the complexity of
the current ruby-openid extension handling.
</p>
<p>
NOTE: Due to the amount of data that this library stores in the session, <a
href="../Session/Cookie.html">Rack::Session::Cookie</a> may fault.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000019">add_extension</a>&nbsp;&nbsp;
<a href="#M000016">call</a>&nbsp;&nbsp;
<a href="#M000017">check</a>&nbsp;&nbsp;
<a href="#M000020">extension_namespaces</a>&nbsp;&nbsp;
<a href="#M000018">finish</a>&nbsp;&nbsp;
<a href="#M000015">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Class <a href="OpenID/NoSession.html" class="link">Rack::Auth::OpenID::NoSession</a><br />
</div>
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">OIDStore</td>
<td>=</td>
<td class="context-item-value">::OpenID::Store::Memory.new</td>
<td width="3em">&nbsp;</td>
<td class="context-item-desc">
Required for ruby-openid
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">HTML</td>
<td>=</td>
<td class="context-item-value">'&lt;html&gt;&lt;head&gt;&lt;title&gt;%s&lt;/title&gt;&lt;/head&gt;&lt;body&gt;%s&lt;/body&gt;&lt;/html&gt;'</td>
</tr>
</table>
</div>
</div>
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">extensions</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">options</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000015" class="method-detail">
<a name="M000015"></a>
<div class="method-heading">
<a href="#M000015" class="method-signature">
<span class="method-name">new</span><span class="method-args">(realm, options={})</span>
</a>
</div>
<div class="method-description">
<p>
A Hash of options is taken as it&#8216;s single initializing argument. For
example:
</p>
<pre>
simple_oid = OpenID.new('http://mysite.com/')
return_oid = OpenID.new('http://mysite.com/', {
:return_to =&gt; 'http://mysite.com/openid'
})
page_oid = OpenID.new('http://mysite.com/',
:login_good =&gt; 'http://mysite.com/auth_good'
)
complex_oid = OpenID.new('http://mysite.com/',
:return_to =&gt; 'http://mysite.com/openid',
:login_good =&gt; 'http://mysite.com/user/preferences',
:auth_fail =&gt; [500, {'Content-Type'=&gt;'text/plain'},
'Unable to negotiate with foreign server.'],
:immediate =&gt; true,
:extensions =&gt; {
::OpenID::SReg =&gt; [['email'],['nickname']]
}
)
</pre>
<h1>Arguments</h1>
<p>
The first argument is the realm, identifying the site they are trusting
with their identity. This is required.
</p>
<p>
NOTE: In <a href="OpenID.html">OpenID</a> 1.x, the realm or trust_root is
optional and the return_to url is required. As this library strives tward
ruby-openid 2.0, and <a href="OpenID.html">OpenID</a> 2.0 compatibiliy, the
realm is required and return_to is optional. However, this implimentation
is still backwards compatible with <a href="OpenID.html">OpenID</a> 1.0
servers.
</p>
<p>
The optional second argument is a hash of options.
</p>
<h2>Options</h2>
<p>
<tt>:return_to</tt> defines the url to return to after the client
authenticates with the openid service provider. This url should point to
where <a href="OpenID.html">Rack::Auth::OpenID</a> is mounted. If
<tt>:return_to</tt> is not provided, :return_to will be the current url
including all query parameters.
</p>
<p>
<tt>:session_key</tt> defines the key to the session hash in the env. It
defaults to &#8216;rack.session&#8217;.
</p>
<p>
<tt>:openid_param</tt> defines at what key in the request parameters to
find the identifier to resolve. As per the 2.0 spec, the default is
&#8216;openid_identifier&#8217;.
</p>
<p>
<tt>:immediate</tt> as true will make immediate type of requests the
default. See <a href="OpenID.html">OpenID</a> specification documentation.
</p>
<h3>URL options</h3>
<p>
<tt>:login_good</tt> is the url to go to after the authentication process
has completed.
</p>
<p>
<tt>:login_fail</tt> is the url to go to after the authentication process
has failed.
</p>
<p>
<tt>:login_quit</tt> is the url to go to after the authentication process
has been cancelled.
</p>
<h3><a href="../Response.html">Response</a> options</h3>
<p>
<tt>:no_session</tt> should be a rack response to be returned if no or an
incompatible session is found.
</p>
<p>
<tt>:auth_fail</tt> should be a rack response to be returned if an
OpenID::DiscoveryFailure occurs. This is typically due to being unable to
access the identity url or identity server.
</p>
<p>
<tt>:error</tt> should be a rack response to return if any other generic
error would occur and <tt>options[:catch_errors]</tt> is true.
</p>
<h3>Extensions</h3>
<p>
<tt>:extensions</tt> should be a hash of openid extension implementations.
The key should be the extension main module, the value should be an array
of arguments for <a
href="../Request.html#M000154">extension::Request.new</a>
</p>
<p>
The hash is iterated over and passed to <a
href="OpenID.html#M000019">add_extension</a> for processing. Please see <a
href="OpenID.html#M000019">add_extension</a> for further documentation.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000015-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/openid.rb, line 137</span>
137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">realm</span>, <span class="ruby-identifier">options</span>={})
138: <span class="ruby-ivar">@realm</span> = <span class="ruby-identifier">realm</span>
139: <span class="ruby-identifier">realm</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">realm</span>)
140: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">realm</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
141: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Invalid realm path: '#{realm.path}'&quot;</span>
142: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">realm</span>.<span class="ruby-identifier">absolute?</span>
143: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Realm '#{@realm}' not absolute&quot;</span>
144: <span class="ruby-keyword kw">end</span>
145:
146: [<span class="ruby-identifier">:return_to</span>, <span class="ruby-identifier">:login_good</span>, <span class="ruby-identifier">:login_fail</span>, <span class="ruby-identifier">:login_quit</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
147: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">key</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">luri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>])
148: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">luri</span>.<span class="ruby-identifier">absolute?</span>
149: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;:#{key} is not an absolute uri: '#{luri}'&quot;</span>
150: <span class="ruby-keyword kw">end</span>
151: <span class="ruby-keyword kw">end</span>
152: <span class="ruby-keyword kw">end</span>
153:
154: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:return_to</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">ruri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:return_to</span>])
155: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ruri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>
156: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Invalid return_to path: '#{ruri.path}'&quot;</span>
157: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">realm</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">ruri</span>.<span class="ruby-identifier">path</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">realm</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">size</span>]
158: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'return_to not within realm.'</span> \
159: <span class="ruby-keyword kw">end</span>
160: <span class="ruby-keyword kw">end</span>
161:
162: <span class="ruby-comment cmt"># TODO: extension support</span>
163: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">extensions</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:extensions</span>)
164: <span class="ruby-identifier">extensions</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ext</span>, <span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
165: <span class="ruby-identifier">add_extension</span> <span class="ruby-identifier">ext</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
166: <span class="ruby-keyword kw">end</span>
167: <span class="ruby-keyword kw">end</span>
168:
169: <span class="ruby-ivar">@options</span> = {
170: <span class="ruby-identifier">:session_key</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'rack.session'</span>,
171: <span class="ruby-identifier">:openid_param</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'openid_identifier'</span>,
172: <span class="ruby-comment cmt">#:return_to, :login_good, :login_fail, :login_quit</span>
173: <span class="ruby-comment cmt">#:no_session, :auth_fail, :error</span>
174: <span class="ruby-identifier">:store</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">OIDStore</span>,
175: <span class="ruby-identifier">:immediate</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
176: <span class="ruby-identifier">:anonymous</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
177: <span class="ruby-identifier">:catch_errors</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>
178: }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
179: <span class="ruby-ivar">@extensions</span> = {}
180: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000019" class="method-detail">
<a name="M000019"></a>
<div class="method-heading">
<a href="#M000019" class="method-signature">
<span class="method-name">add_extension</span><span class="method-args">(ext, *args)</span>
</a>
</div>
<div class="method-description">
<p>
The first argument should be the main extension module. The extension
module should contain the constants:
</p>
<pre>
* class Request, with OpenID::Extension as an ancestor
* class Response, with OpenID::Extension as an ancestor
* string NS_URI, which defines the namespace of the extension, should
be an absolute http uri
</pre>
<p>
All trailing arguments will be passed to <a
href="../Request.html#M000154">extension::Request.new</a> in <a
href="OpenID.html#M000017">check</a>. The openid response will be passed to
extension::Response#from_success_response, get_extension_args will be
called on the result to attain the gathered data.
</p>
<p>
This method returns the key at which the response data will be found in the
session, which is the namespace uri by default.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000019-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/openid.rb, line 402</span>
402: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_extension</span> <span class="ruby-identifier">ext</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
403: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">ext</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Module</span>
404: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;#{ext.inspect} is not a module&quot;</span>
405: <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">m</span> = <span class="ruby-node">%w'Request Response NS_URI'</span> <span class="ruby-operator">-</span>
406: <span class="ruby-identifier">ext</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_s</span> }).<span class="ruby-identifier">empty?</span>
407: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;#{ext.inspect} missing #{m*', '}&quot;</span>
408: <span class="ruby-keyword kw">end</span>
409:
410: <span class="ruby-identifier">consts</span> = [<span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>, <span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>]
411:
412: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">consts</span>.<span class="ruby-identifier">all?</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Class</span> }
413: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;#{ext.inspect}'s Request or Response is not a class&quot;</span>
414: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">consts</span>.<span class="ruby-identifier">all?</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">Extension</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">c</span> }
415: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;#{ext.inspect}'s Request or Response not a decendant of OpenID::Extension&quot;</span>
416: <span class="ruby-keyword kw">end</span>
417:
418: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">NS_URI</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
419: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;#{ext.inspect}'s NS_URI is not a string&quot;</span>
420: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">NS_URI</span>)
421: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;#{ext.inspect}'s NS_URI is not a valid uri&quot;</span>
422: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^https?$/</span>
423: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;#{ext.inspect}'s NS_URI is not an http uri&quot;</span>
424: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">absolute?</span>
425: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;#{ext.inspect}'s NS_URI is not and absolute uri&quot;</span>
426: <span class="ruby-keyword kw">end</span>
427: <span class="ruby-ivar">@extensions</span>[<span class="ruby-identifier">ext</span>] = <span class="ruby-identifier">args</span>
428: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">NS_URI</span>
429: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000016" class="method-detail">
<a name="M000016"></a>
<div class="method-heading">
<a href="#M000016" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p>
It sets up and uses session data at <tt>:openid</tt> within the session. It
sets up the ::OpenID::Consumer using the store specified by
<tt>options[:store]</tt>.
</p>
<p>
If the parameter specified by <tt>options[:openid_param]</tt> is present,
processing is passed to <a href="OpenID.html#M000017">check</a> and the
result is returned.
</p>
<p>
If the parameter &#8216;openid.mode&#8217; is set, implying a followup from
the openid server, processing is passed to <a
href="OpenID.html#M000018">finish</a> and the result is returned.
</p>
<p>
If neither of these conditions are met, a 400 error is returned.
</p>
<p>
If an error is thrown and <tt>options[:catch_errors]</tt> is false, the
exception will be reraised. Otherwise a 500 error is returned.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000016-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/openid.rb, line 199</span>
199: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
200: <span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.auth.openid'</span>] = <span class="ruby-keyword kw">self</span>
201: <span class="ruby-identifier">session</span> = <span class="ruby-identifier">env</span>[<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:session_key</span>]]
202: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">session</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">session</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
203: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">NoSession</span>, <span class="ruby-value str">'No compatible session'</span>)
204: <span class="ruby-keyword kw">end</span>
205: <span class="ruby-comment cmt"># let us work in our own namespace...</span>
206: <span class="ruby-identifier">session</span> = (<span class="ruby-identifier">session</span>[<span class="ruby-identifier">:openid</span>] <span class="ruby-operator">||=</span> {})
207: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">session</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">session</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
208: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">NoSession</span>, <span class="ruby-value str">'Incompatible session'</span>)
209: <span class="ruby-keyword kw">end</span>
210:
211: <span class="ruby-identifier">request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">env</span>
212: <span class="ruby-identifier">consumer</span> = <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">Consumer</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">session</span>, <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:store</span>]
213:
214: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'openid.mode'</span>]
215: <span class="ruby-identifier">finish</span> <span class="ruby-identifier">consumer</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">request</span>
216: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:openid_param</span>]]
217: <span class="ruby-identifier">check</span> <span class="ruby-identifier">consumer</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">request</span>
218: <span class="ruby-keyword kw">else</span>
219: <span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>].<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;No valid params provided.&quot;</span>
220: <span class="ruby-identifier">bad_request</span>
221: <span class="ruby-keyword kw">end</span>
222: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NoSession</span>
223: <span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>].<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">$!</span>.<span class="ruby-identifier">message</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">$@</span>)
224:
225: <span class="ruby-ivar">@options</span>. <span class="ruby-comment cmt">### Missing or incompatible session</span>
226: <span class="ruby-identifier">fetch</span> <span class="ruby-identifier">:no_session</span>, [ <span class="ruby-value">500</span>,
227: {<span class="ruby-value str">'Content-Type'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">'text/plain'</span>},
228: <span class="ruby-identifier">$!</span>.<span class="ruby-identifier">message</span> ]
229: <span class="ruby-keyword kw">rescue</span>
230: <span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>].<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">$!</span>.<span class="ruby-identifier">message</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">$@</span>)
231:
232: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:catch_error</span>]
233: <span class="ruby-identifier">raise</span>(<span class="ruby-identifier">$!</span>)
234: <span class="ruby-keyword kw">end</span>
235: <span class="ruby-ivar">@options</span>.
236: <span class="ruby-identifier">fetch</span> <span class="ruby-identifier">:error</span>, [ <span class="ruby-value">500</span>,
237: {<span class="ruby-value str">'Content-Type'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">'text/plain'</span>},
238: <span class="ruby-value str">'OpenID has encountered an error.'</span> ]
239: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000017" class="method-detail">
<a name="M000017"></a>
<div class="method-heading">
<a href="#M000017" class="method-signature">
<span class="method-name">check</span><span class="method-args">(consumer, session, req)</span>
</a>
</div>
<div class="method-description">
<p>
As the first part of <a href="OpenID.html">OpenID</a> consumer action, <a
href="OpenID.html#M000017">check</a> retrieves the data required for
completion.
</p>
<ul>
<li><tt>session[:openid][:openid_param]</tt> is set to the submitted identifier
to be authenticated.
</li>
<li><tt>session[:openid][:site_return]</tt> is set as the request&#8216;s
HTTP_REFERER, unless already set.
</li>
<li><tt><a href="http://'rack.auth.openid.request'">env</a></tt> is the openid
checkid request instance.
</li>
</ul>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000017-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/openid.rb, line 250</span>
250: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check</span>(<span class="ruby-identifier">consumer</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">req</span>)
251: <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:openid_param</span>] = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">params</span>[<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:openid_param</span>]]
252: <span class="ruby-identifier">oid</span> = <span class="ruby-identifier">consumer</span>.<span class="ruby-identifier">begin</span>(<span class="ruby-identifier">session</span>[<span class="ruby-identifier">:openid_param</span>], <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:anonymous</span>])
253: <span class="ruby-identifier">pp</span> <span class="ruby-identifier">oid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
254: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.auth.openid.request'</span>] = <span class="ruby-identifier">oid</span>
255:
256: <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:site_return</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">'HTTP_REFERER'</span>]
257:
258: <span class="ruby-comment cmt"># SETUP_NEEDED check!</span>
259: <span class="ruby-comment cmt"># see OpenID::Consumer::CheckIDRequest docs</span>
260: <span class="ruby-identifier">query_args</span> = [<span class="ruby-ivar">@realm</span>, <span class="ruby-operator">*</span><span class="ruby-ivar">@options</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-identifier">:return_to</span>, <span class="ruby-identifier">:immediate</span>)]
261: <span class="ruby-identifier">query_args</span>[<span class="ruby-value">1</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">url</span>
262: <span class="ruby-identifier">query_args</span>[<span class="ruby-value">2</span>] = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">session</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">:setup_needed</span>
263: <span class="ruby-identifier">pp</span> <span class="ruby-identifier">query_args</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
264:
265: <span class="ruby-comment cmt">## Extension support</span>
266: <span class="ruby-identifier">extensions</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ext</span>,<span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
267: <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">add_extension</span> <span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
268: <span class="ruby-keyword kw">end</span>
269:
270: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">send_redirect?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">query_args</span>)
271: <span class="ruby-identifier">redirect</span> = <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">redirect_url</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">query_args</span>)
272: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
273: <span class="ruby-identifier">pp</span> <span class="ruby-identifier">redirect</span>
274: <span class="ruby-identifier">pp</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">parse_query</span>(<span class="ruby-constant">URI</span>(<span class="ruby-identifier">redirect</span>).<span class="ruby-identifier">query</span>)
275: <span class="ruby-keyword kw">end</span>
276: [ <span class="ruby-value">303</span>, {<span class="ruby-value str">'Location'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-identifier">redirect</span>}, [] ]
277: <span class="ruby-keyword kw">else</span>
278: <span class="ruby-comment cmt"># check on 'action' option.</span>
279: <span class="ruby-identifier">formbody</span> = <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">form_markup</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">query_args</span>)
280: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
281: <span class="ruby-identifier">pp</span> <span class="ruby-identifier">formbody</span>
282: <span class="ruby-keyword kw">end</span>
283: <span class="ruby-identifier">body</span> = <span class="ruby-constant">HTML</span> <span class="ruby-operator">%</span> [<span class="ruby-value str">'Confirm...'</span>, <span class="ruby-identifier">formbody</span>]
284: [ <span class="ruby-value">200</span>, {<span class="ruby-value str">'Content-Type'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">'text/html'</span>}, <span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_a</span> ]
285: <span class="ruby-keyword kw">end</span>
286: <span class="ruby-keyword kw">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">DiscoveryFailure</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
287: <span class="ruby-comment cmt"># thrown from inside OpenID::Consumer#begin by yadis stuff</span>
288: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>].<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">$!</span>.<span class="ruby-identifier">message</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">$@</span>)
289:
290: <span class="ruby-ivar">@options</span>. <span class="ruby-comment cmt">### Foreign server failed</span>
291: <span class="ruby-identifier">fetch</span> <span class="ruby-identifier">:auth_fail</span>, [ <span class="ruby-value">503</span>,
292: {<span class="ruby-value str">'Content-Type'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">'text/plain'</span>},
293: <span class="ruby-value str">'Foreign server failure.'</span> ]
294: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000020" class="method-detail">
<a name="M000020"></a>
<div class="method-heading">
<a href="#M000020" class="method-signature">
<span class="method-name">extension_namespaces</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
A conveniance method that returns the namespace of all current extensions
used by this instance.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000020-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/openid.rb, line 433</span>
433: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">extension_namespaces</span>
434: <span class="ruby-ivar">@extensions</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">::</span><span class="ruby-constant">NS_URI</span>}
435: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000018" class="method-detail">
<a name="M000018"></a>
<div class="method-heading">
<a href="#M000018" class="method-signature">
<span class="method-name">finish</span><span class="method-args">(consumer, session, req)</span>
</a>
</div>
<div class="method-description">
<p>
This is the final portion of authentication. Unless any errors outside of
specification occur, a 303 redirect will be returned with Location
determined by the <a href="OpenID.html">OpenID</a> response type. If none
of the response type :login_* urls are set, the redirect will be set to
<tt>session[:openid][:site_return]</tt>. If
<tt>session[:openid][:site_return]</tt> is unset, the realm will be used.
</p>
<p>
Any messages from <a href="OpenID.html">OpenID</a>&#8216;s response are
appended to the 303 response body.
</p>
<p>
Data gathered from extensions are stored in session[:openid] with the
extension&#8216;s namespace uri as the key.
</p>
<ul>
<li><tt><a href="http://'rack.auth.openid.response'">env</a></tt> is the openid
response.
</li>
</ul>
<p>
The four valid possible outcomes are:
</p>
<ul>
<li>failure: <tt>options[:login_fail]</tt> or <tt>session[:site_return]</tt> or
the realm
<ul>
<li><tt>session[:openid]</tt> is cleared and any messages are send to
rack.errors
</li>
<li><tt>session[:openid][&#8216;authenticated&#8217;]</tt> is <tt>false</tt>
</li>
</ul>
</li>
<li>success: <tt>options[:login_good]</tt> or <tt>session[:site_return]</tt> or
the realm
<ul>
<li><tt>session[:openid]</tt> is cleared
</li>
<li><tt>session[:openid][&#8216;authenticated&#8217;]</tt> is <tt>true</tt>
</li>
<li><tt>session[:openid][&#8216;identity&#8217;]</tt> is the actual identifier
</li>
<li><tt>session[:openid][&#8216;identifier&#8217;]</tt> is the pretty
identifier
</li>
</ul>
</li>
<li>cancel: <tt>options[:login_good]</tt> or <tt>session[:site_return]</tt> or
the realm
<ul>
<li><tt>session[:openid]</tt> is cleared
</li>
<li><tt>session[:openid][&#8216;authenticated&#8217;]</tt> is <tt>false</tt>
</li>
</ul>
</li>
<li>setup_needed: resubmits the authentication request. A flag is set for
non-immediate handling.
<ul>
<li><tt>session[:openid][:setup_needed]</tt> is set to <tt>true</tt>, which
will prevent immediate style openid authentication.
</li>
</ul>
</li>
</ul>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000018-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/auth/openid.rb, line 332</span>
332: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finish</span>(<span class="ruby-identifier">consumer</span>, <span class="ruby-identifier">session</span>, <span class="ruby-identifier">req</span>)
333: <span class="ruby-identifier">oid</span> = <span class="ruby-identifier">consumer</span>.<span class="ruby-identifier">complete</span>(<span class="ruby-identifier">req</span>.<span class="ruby-identifier">params</span>, <span class="ruby-identifier">req</span>.<span class="ruby-identifier">url</span>)
334: <span class="ruby-identifier">pp</span> <span class="ruby-identifier">oid</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
335: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.auth.openid.response'</span>] = <span class="ruby-identifier">oid</span>
336:
337: <span class="ruby-identifier">goto</span> = <span class="ruby-identifier">session</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-identifier">:site_return</span>, <span class="ruby-ivar">@realm</span>
338: <span class="ruby-identifier">body</span> = []
339:
340: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">status</span>
341: <span class="ruby-keyword kw">when</span> <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">Consumer</span><span class="ruby-operator">::</span><span class="ruby-constant">FAILURE</span>
342: <span class="ruby-identifier">session</span>.<span class="ruby-identifier">clear</span>
343: <span class="ruby-identifier">session</span>[<span class="ruby-value str">'authenticated'</span>] = <span class="ruby-keyword kw">false</span>
344: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>].<span class="ruby-identifier">puts</span> <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">message</span>
345:
346: <span class="ruby-identifier">goto</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:login_fail</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">:login_fail</span>
347: <span class="ruby-identifier">body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;Authentication unsuccessful.\n&quot;</span>
348: <span class="ruby-keyword kw">when</span> <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">Consumer</span><span class="ruby-operator">::</span><span class="ruby-constant">SUCCESS</span>
349: <span class="ruby-identifier">session</span>.<span class="ruby-identifier">clear</span>
350:
351: <span class="ruby-comment cmt">## Extension support</span>
352: <span class="ruby-identifier">extensions</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ext</span>, <span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
353: <span class="ruby-identifier">session</span>[<span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">NS_URI</span>] = <span class="ruby-identifier">ext</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>.
354: <span class="ruby-identifier">from_success_response</span>(<span class="ruby-identifier">oid</span>).
355: <span class="ruby-identifier">get_extension_args</span>
356: <span class="ruby-keyword kw">end</span>
357:
358: <span class="ruby-identifier">session</span>[<span class="ruby-value str">'authenticated'</span>] = <span class="ruby-keyword kw">true</span>
359: <span class="ruby-comment cmt"># Value for unique identification and such</span>
360: <span class="ruby-identifier">session</span>[<span class="ruby-value str">'identity'</span>] = <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">identity_url</span>
361: <span class="ruby-comment cmt"># Value for display and UI labels</span>
362: <span class="ruby-identifier">session</span>[<span class="ruby-value str">'identifier'</span>] = <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">display_identifier</span>
363:
364: <span class="ruby-identifier">goto</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:login_good</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">:login_good</span>
365: <span class="ruby-identifier">body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;Authentication successful.\n&quot;</span>
366: <span class="ruby-keyword kw">when</span> <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">Consumer</span><span class="ruby-operator">::</span><span class="ruby-constant">CANCEL</span>
367: <span class="ruby-identifier">session</span>.<span class="ruby-identifier">clear</span>
368: <span class="ruby-identifier">session</span>[<span class="ruby-value str">'authenticated'</span>] = <span class="ruby-keyword kw">false</span>
369:
370: <span class="ruby-identifier">goto</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:login_fail</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">key?</span> <span class="ruby-identifier">:login_fail</span>
371: <span class="ruby-identifier">body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;Authentication cancelled.\n&quot;</span>
372: <span class="ruby-keyword kw">when</span> <span class="ruby-operator">::</span><span class="ruby-constant">OpenID</span><span class="ruby-operator">::</span><span class="ruby-constant">Consumer</span><span class="ruby-operator">::</span><span class="ruby-constant">SETUP_NEEDED</span>
373: <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:setup_needed</span>] = <span class="ruby-keyword kw">true</span>
374: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">o_id</span> = <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:openid_param</span>]
375: <span class="ruby-identifier">raise</span>(<span class="ruby-value str">'Required values missing.'</span>)
376: <span class="ruby-keyword kw">end</span>
377:
378: <span class="ruby-identifier">goto</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">script_name</span><span class="ruby-operator">+</span>
379: <span class="ruby-value str">'?'</span><span class="ruby-operator">+</span><span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:openid_param</span>]<span class="ruby-operator">+</span>
380: <span class="ruby-value str">'='</span><span class="ruby-operator">+</span><span class="ruby-identifier">o_id</span>
381: <span class="ruby-identifier">body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;Reauthentication required.\n&quot;</span>
382: <span class="ruby-keyword kw">end</span>
383: <span class="ruby-identifier">body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">message</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">oid</span>.<span class="ruby-identifier">message</span>
384: [ <span class="ruby-value">303</span>, {<span class="ruby-value str">'Location'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-identifier">goto</span>}, <span class="ruby-identifier">body</span>]
385: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Auth::OpenID::NoSession</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Auth::OpenID::NoSession</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../../files/lib/rack/auth/openid_rb.html">
lib/rack/auth/openid.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
RuntimeError
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,340 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Builder</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Builder</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/builder_rb.html">
lib/rack/builder.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Builder.html">Rack::Builder</a> implements a small DSL to
iteratively construct <a href="../Rack.html">Rack</a> applications.
</p>
<p>
Example:
</p>
<pre>
app = Rack::Builder.new {
use Rack::CommonLogger
use Rack::ShowExceptions
map &quot;/lobster&quot; do
use Rack::Lint
run Rack::Lobster.new
end
}
</pre>
<p>
Or
</p>
<pre>
app = Rack::Builder.app do
use Rack::CommonLogger
lambda { |env| [200, {'Content-Type' =&gt; 'text/plain'}, 'OK'] }
end
</pre>
<p>
<tt><a href="Builder.html#M000127">use</a></tt> adds a middleware to the
stack, <tt><a href="Builder.html#M000128">run</a></tt> dispatches to an
application. You can <a href="Builder.html#M000127">use</a> <tt><a
href="Builder.html#M000129">map</a></tt> to construct a <a
href="URLMap.html">Rack::URLMap</a> in a convenient way.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000126">app</a>&nbsp;&nbsp;
<a href="#M000131">call</a>&nbsp;&nbsp;
<a href="#M000129">map</a>&nbsp;&nbsp;
<a href="#M000125">new</a>&nbsp;&nbsp;
<a href="#M000128">run</a>&nbsp;&nbsp;
<a href="#M000130">to_app</a>&nbsp;&nbsp;
<a href="#M000127">use</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000126" class="method-detail">
<a name="M000126"></a>
<div class="method-heading">
<a href="#M000126" class="method-signature">
<span class="method-name">app</span><span class="method-args">(&amp;block)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000126-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000126-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 32</span>
32: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">app</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
33: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>).<span class="ruby-identifier">to_app</span>
34: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000125" class="method-detail">
<a name="M000125"></a>
<div class="method-heading">
<a href="#M000125" class="method-signature">
<span class="method-name">new</span><span class="method-args">(&amp;block)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000125-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000125-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 27</span>
27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
28: <span class="ruby-ivar">@ins</span> = []
29: <span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
30: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000131" class="method-detail">
<a name="M000131"></a>
<div class="method-heading">
<a href="#M000131" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000131-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000131-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 63</span>
63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
64: <span class="ruby-identifier">to_app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
65: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000129" class="method-detail">
<a name="M000129"></a>
<div class="method-heading">
<a href="#M000129" class="method-signature">
<span class="method-name">map</span><span class="method-args">(path, &amp;block)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000129-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000129-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 48</span>
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
49: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@ins</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Hash</span>
50: <span class="ruby-ivar">@ins</span>.<span class="ruby-identifier">last</span>[<span class="ruby-identifier">path</span>] = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>).<span class="ruby-identifier">to_app</span>
51: <span class="ruby-keyword kw">else</span>
52: <span class="ruby-ivar">@ins</span> <span class="ruby-operator">&lt;&lt;</span> {}
53: <span class="ruby-identifier">map</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
54: <span class="ruby-keyword kw">end</span>
55: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000128" class="method-detail">
<a name="M000128"></a>
<div class="method-heading">
<a href="#M000128" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000128-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000128-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 44</span>
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>)
45: <span class="ruby-ivar">@ins</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">app</span> <span class="ruby-comment cmt">#lambda { |nothing| app }</span>
46: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000130" class="method-detail">
<a name="M000130"></a>
<div class="method-heading">
<a href="#M000130" class="method-signature">
<span class="method-name">to_app</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000130-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000130-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 57</span>
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_app</span>
58: <span class="ruby-ivar">@ins</span>[<span class="ruby-value">-1</span>] = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@ins</span>.<span class="ruby-identifier">last</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-ivar">@ins</span>.<span class="ruby-identifier">last</span>
59: <span class="ruby-identifier">inner_app</span> = <span class="ruby-ivar">@ins</span>.<span class="ruby-identifier">last</span>
60: <span class="ruby-ivar">@ins</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>].<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">inner_app</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span>, <span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">a</span>) }
61: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000127" class="method-detail">
<a name="M000127"></a>
<div class="method-heading">
<a href="#M000127" class="method-signature">
<span class="method-name">use</span><span class="method-args">(middleware, *args, &amp;block)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000127-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000127-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/builder.rb, line 36</span>
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use</span>(<span class="ruby-identifier">middleware</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
37: <span class="ruby-ivar">@ins</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
38: <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">app</span><span class="ruby-operator">|</span> <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>) }
39: <span class="ruby-keyword kw">else</span>
40: <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">app</span><span class="ruby-operator">|</span> <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) }
41: <span class="ruby-keyword kw">end</span>
42: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,265 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Cascade</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Cascade</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/cascade_rb.html">
lib/rack/cascade.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Cascade.html">Rack::Cascade</a> tries an request on several apps,
and returns the first response that is not 404 (or in a list of
configurable status codes).
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000202">&lt;&lt;</a>&nbsp;&nbsp;
<a href="#M000200">add</a>&nbsp;&nbsp;
<a href="#M000199">call</a>&nbsp;&nbsp;
<a href="#M000201">include?</a>&nbsp;&nbsp;
<a href="#M000198">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">apps</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000198" class="method-detail">
<a name="M000198"></a>
<div class="method-heading">
<a href="#M000198" class="method-signature">
<span class="method-name">new</span><span class="method-args">(apps, catch=404)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000198-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000198-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/cascade.rb, line 9</span>
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">apps</span>, <span class="ruby-identifier">catch</span>=<span class="ruby-value">404</span>)
10: <span class="ruby-ivar">@apps</span> = <span class="ruby-identifier">apps</span>
11: <span class="ruby-ivar">@catch</span> = [<span class="ruby-operator">*</span><span class="ruby-identifier">catch</span>]
12: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000202" class="method-detail">
<a name="M000202"></a>
<div class="method-heading">
<span class="method-name">&lt;&lt;</span><span class="method-args">(app)</span>
</div>
<div class="method-description">
<p>
Alias for <a href="Cascade.html#M000200">add</a>
</p>
</div>
</div>
<div id="method-M000200" class="method-detail">
<a name="M000200"></a>
<div class="method-heading">
<a href="#M000200" class="method-signature">
<span class="method-name">add</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000200-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000200-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/cascade.rb, line 26</span>
26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span> <span class="ruby-identifier">app</span>
27: <span class="ruby-ivar">@apps</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">app</span>
28: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000199" class="method-detail">
<a name="M000199"></a>
<div class="method-heading">
<a href="#M000199" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000199-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000199-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/cascade.rb, line 14</span>
14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
15: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">headers</span> = <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">nil</span>
16: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;empty cascade&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@apps</span>.<span class="ruby-identifier">empty?</span>
17: <span class="ruby-ivar">@apps</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">app</span><span class="ruby-operator">|</span>
18: <span class="ruby-keyword kw">begin</span>
19: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
20: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@catch</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>)
21: <span class="ruby-keyword kw">end</span>
22: }
23: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
24: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000201" class="method-detail">
<a name="M000201"></a>
<div class="method-heading">
<a href="#M000201" class="method-signature">
<span class="method-name">include?</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000201-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000201-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/cascade.rb, line 30</span>
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include?</span> <span class="ruby-identifier">app</span>
31: <span class="ruby-ivar">@apps</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">app</span>
32: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,308 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::CommonLogger</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::CommonLogger</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/commonlogger_rb.html">
lib/rack/commonlogger.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="CommonLogger.html">Rack::CommonLogger</a> forwards every request
to an <tt>app</tt> given, and logs a line in the Apache common log format
to the <tt>logger</tt>, or rack.errors by default.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000196">&lt;&lt;</a>&nbsp;&nbsp;
<a href="#M000194">_call</a>&nbsp;&nbsp;
<a href="#M000193">call</a>&nbsp;&nbsp;
<a href="#M000195">close</a>&nbsp;&nbsp;
<a href="#M000197">each</a>&nbsp;&nbsp;
<a href="#M000192">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000192" class="method-detail">
<a name="M000192"></a>
<div class="method-heading">
<a href="#M000192" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app, logger=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000192-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000192-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 7</span>
7: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">logger</span>=<span class="ruby-keyword kw">nil</span>)
8: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
9: <span class="ruby-ivar">@logger</span> = <span class="ruby-identifier">logger</span>
10: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000196" class="method-detail">
<a name="M000196"></a>
<div class="method-heading">
<a href="#M000196" class="method-signature">
<span class="method-name">&lt;&lt;</span><span class="method-args">(str)</span>
</a>
</div>
<div class="method-description">
<p>
By default, log to rack.errors.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000196-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000196-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 29</span>
29: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span>(<span class="ruby-identifier">str</span>)
30: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">write</span>(<span class="ruby-identifier">str</span>)
31: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">flush</span>
32: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000194" class="method-detail">
<a name="M000194"></a>
<div class="method-heading">
<a href="#M000194" class="method-signature">
<span class="method-name">_call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000194-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000194-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 16</span>
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
17: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">env</span>
18: <span class="ruby-ivar">@logger</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">self</span>
19: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
20: <span class="ruby-ivar">@status</span>, <span class="ruby-ivar">@header</span>, <span class="ruby-ivar">@body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
21: [<span class="ruby-ivar">@status</span>, <span class="ruby-ivar">@header</span>, <span class="ruby-keyword kw">self</span>]
22: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000193" class="method-detail">
<a name="M000193"></a>
<div class="method-heading">
<a href="#M000193" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000193-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000193-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 12</span>
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
13: <span class="ruby-identifier">dup</span>.<span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
14: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000195" class="method-detail">
<a name="M000195"></a>
<div class="method-heading">
<a href="#M000195" class="method-signature">
<span class="method-name">close</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000195-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000195-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 24</span>
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
25: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
26: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000197" class="method-detail">
<a name="M000197"></a>
<div class="method-heading">
<a href="#M000197" class="method-signature">
<span class="method-name">each</span><span class="method-args">() {|part| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000197-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000197-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 34</span>
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
35: <span class="ruby-identifier">length</span> = <span class="ruby-value">0</span>
36: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
37: <span class="ruby-identifier">length</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">size</span>
38: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">part</span>
39: }
40:
41: <span class="ruby-ivar">@now</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
42:
43: <span class="ruby-comment cmt"># Common Log Format: http://httpd.apache.org/docs/1.3/logs.html#common</span>
44: <span class="ruby-comment cmt"># lilith.local - - [07/Aug/2006 23:58:02] &quot;GET / HTTP/1.1&quot; 500 -</span>
45: <span class="ruby-comment cmt"># %{%s - %s [%s] &quot;%s %s%s %s&quot; %d %s\n} %</span>
46: <span class="ruby-ivar">@logger</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">%{%s - %s [%s] &quot;%s %s%s %s&quot; %d %s %0.4f\n}</span> <span class="ruby-operator">%</span>
47: [
48: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'HTTP_X_FORWARDED_FOR'</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REMOTE_ADDR&quot;</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;-&quot;</span>,
49: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REMOTE_USER&quot;</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;-&quot;</span>,
50: <span class="ruby-ivar">@now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%d/%b/%Y %H:%M:%S&quot;</span>),
51: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>],
52: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>],
53: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>].<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;?&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>],
54: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>],
55: <span class="ruby-ivar">@status</span>.<span class="ruby-identifier">to_s</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>],
56: (<span class="ruby-identifier">length</span>.<span class="ruby-identifier">zero?</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;-&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span>),
57: <span class="ruby-ivar">@now</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@time</span>
58: ]
59: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::ConditionalGet</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::ConditionalGet</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/conditionalget_rb.html">
lib/rack/conditionalget.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
Middleware that enables conditional GET using If-None-Match and
If-Modified-Since. The application should set either or both of the
Last-Modified or Etag response headers according to RFC 2616. When either
of the conditions is met, the response body is set to be zero length and
the response status is set to 304 Not Modified.
</p>
<p>
Applications that defer response body generation until the body&#8216;s
each message is received will avoid response body generation completely
when a conditional GET matches.
</p>
<p>
Adapted from Michael Klishin&#8216;s Merb implementation: <a
href="http://github.com/wycats/merb-core/tree/master/lib/merb-core/rack/middleware/conditional_get.rb">github.com/wycats/merb-core/tree/master/lib/merb-core/rack/middleware/conditional_get.rb</a>
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000191">call</a>&nbsp;&nbsp;
<a href="#M000190">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000190" class="method-detail">
<a name="M000190"></a>
<div class="method-heading">
<a href="#M000190" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000190-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000190-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/conditionalget.rb, line 16</span>
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
17: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
18: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000191" class="method-detail">
<a name="M000191"></a>
<div class="method-heading">
<a href="#M000191" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000191-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000191-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/conditionalget.rb, line 20</span>
20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
21: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-node">%w[GET HEAD]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">'REQUEST_METHOD'</span>])
22:
23: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
24: <span class="ruby-identifier">headers</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">headers</span>)
25: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">etag_matches?</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">headers</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">modified_since?</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">headers</span>)
26: <span class="ruby-identifier">status</span> = <span class="ruby-value">304</span>
27: <span class="ruby-identifier">body</span> = []
28: <span class="ruby-keyword kw">end</span>
29: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
30: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::ContentLength</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::ContentLength</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/content_length_rb.html">
lib/rack/content_length.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
Sets the Content-Length header on responses with fixed-length bodies.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000081">call</a>&nbsp;&nbsp;
<a href="#M000080">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000080" class="method-detail">
<a name="M000080"></a>
<div class="method-heading">
<a href="#M000080" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000080-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/content_length.rb, line 4</span>
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
5: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
6: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000081" class="method-detail">
<a name="M000081"></a>
<div class="method-heading">
<a href="#M000081" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000081-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/content_length.rb, line 8</span>
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
9: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
10: <span class="ruby-identifier">headers</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">headers</span>)
11:
12: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">STATUS_WITH_NO_ENTITY_BODY</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">status</span>) <span class="ruby-operator">&amp;&amp;</span>
13: <span class="ruby-operator">!</span><span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Length'</span>] <span class="ruby-operator">&amp;&amp;</span>
14: <span class="ruby-operator">!</span><span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Transfer-Encoding'</span>] <span class="ruby-operator">&amp;&amp;</span>
15: (<span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_str</span>))
16:
17: <span class="ruby-identifier">body</span> = [<span class="ruby-identifier">body</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_str</span>) <span class="ruby-comment cmt"># rack 0.4 compat</span>
18: <span class="ruby-identifier">length</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_ary</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">len</span>, <span class="ruby-identifier">part</span><span class="ruby-operator">|</span> <span class="ruby-identifier">len</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">length</span> }
19: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Length'</span>] = <span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span>
20: <span class="ruby-keyword kw">end</span>
21:
22: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
23: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,289 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Deflater</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Deflater</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/deflater_rb.html">
lib/rack/deflater.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000151">call</a>&nbsp;&nbsp;
<a href="#M000153">deflate</a>&nbsp;&nbsp;
<a href="#M000152">gzip</a>&nbsp;&nbsp;
<a href="#M000150">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">DEFLATE_ARGS</td>
<td>=</td>
<td class="context-item-value">[ Zlib::DEFAULT_COMPRESSION, # drop the zlib header which causes both Safari and IE to choke -Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000153" class="method-detail">
<a name="M000153"></a>
<div class="method-heading">
<a href="#M000153" class="method-signature">
<span class="method-name">deflate</span><span class="method-args">(body)</span>
</a>
</div>
<div class="method-description">
<p>
Loosely based on Mongrel&#8216;s Deflate handler
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000153-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/deflater.rb, line 77</span>
77: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">deflate</span>(<span class="ruby-identifier">body</span>)
78: <span class="ruby-identifier">deflater</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Deflate</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-constant">DEFLATE_ARGS</span>)
79:
80: <span class="ruby-comment cmt"># TODO: Add streaming</span>
81: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span> <span class="ruby-identifier">deflater</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">part</span> }
82:
83: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">deflater</span>.<span class="ruby-identifier">finish</span>
84: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000152" class="method-detail">
<a name="M000152"></a>
<div class="method-heading">
<a href="#M000152" class="method-signature">
<span class="method-name">gzip</span><span class="method-args">(body, mtime)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000152-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/deflater.rb, line 56</span>
56: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">gzip</span>(<span class="ruby-identifier">body</span>, <span class="ruby-identifier">mtime</span>)
57: <span class="ruby-identifier">io</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
58: <span class="ruby-identifier">gzip</span> = <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipWriter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">io</span>)
59: <span class="ruby-identifier">gzip</span>.<span class="ruby-identifier">mtime</span> = <span class="ruby-identifier">mtime</span>
60:
61: <span class="ruby-comment cmt"># TODO: Add streaming</span>
62: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span> <span class="ruby-identifier">gzip</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">part</span> }
63:
64: <span class="ruby-identifier">gzip</span>.<span class="ruby-identifier">close</span>
65: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">io</span>.<span class="ruby-identifier">string</span>
66: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000150" class="method-detail">
<a name="M000150"></a>
<div class="method-heading">
<a href="#M000150" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000150-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000150-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/deflater.rb, line 8</span>
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
9: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
10: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000151" class="method-detail">
<a name="M000151"></a>
<div class="method-heading">
<a href="#M000151" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000151-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000151-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/deflater.rb, line 12</span>
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
13: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
14: <span class="ruby-identifier">headers</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">headers</span>)
15:
16: <span class="ruby-comment cmt"># Skip compressing empty entity body responses and responses with</span>
17: <span class="ruby-comment cmt"># no-transform set.</span>
18: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">STATUS_WITH_NO_ENTITY_BODY</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">status</span>) <span class="ruby-operator">||</span>
19: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Cache-Control'</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\bno-transform\b/</span>
20: <span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
21: <span class="ruby-keyword kw">end</span>
22:
23: <span class="ruby-identifier">request</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
24:
25: <span class="ruby-identifier">encoding</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">select_best_encoding</span>(<span class="ruby-node">%w(gzip deflate identity)</span>,
26: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">accept_encoding</span>)
27:
28: <span class="ruby-comment cmt"># Set the Vary HTTP header.</span>
29: <span class="ruby-identifier">vary</span> = <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Vary&quot;</span>].<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;,&quot;</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">strip</span> }
30: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">vary</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">&quot;*&quot;</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">vary</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">&quot;Accept-Encoding&quot;</span>)
31: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Vary&quot;</span>] = <span class="ruby-identifier">vary</span>.<span class="ruby-identifier">push</span>(<span class="ruby-value str">&quot;Accept-Encoding&quot;</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;,&quot;</span>)
32: <span class="ruby-keyword kw">end</span>
33:
34: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">encoding</span>
35: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;gzip&quot;</span>
36: <span class="ruby-identifier">mtime</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value str">&quot;Last-Modified&quot;</span>)
37: <span class="ruby-constant">Time</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Last-Modified&quot;</span>])
38: <span class="ruby-keyword kw">else</span>
39: <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
40: <span class="ruby-keyword kw">end</span>
41: [<span class="ruby-identifier">status</span>,
42: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value str">&quot;Content-Encoding&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;gzip&quot;</span>),
43: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">gzip</span>(<span class="ruby-identifier">body</span>, <span class="ruby-identifier">mtime</span>)]
44: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;deflate&quot;</span>
45: [<span class="ruby-identifier">status</span>,
46: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value str">&quot;Content-Encoding&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;deflate&quot;</span>),
47: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">deflate</span>(<span class="ruby-identifier">body</span>)]
48: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;identity&quot;</span>
49: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
50: <span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span>
51: <span class="ruby-identifier">message</span> = [<span class="ruby-node">&quot;An acceptable encoding for the requested resource #{request.fullpath} could not be found.&quot;</span>]
52: [<span class="ruby-value">406</span>, {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/plain&quot;</span>}, <span class="ruby-identifier">message</span>]
53: <span class="ruby-keyword kw">end</span>
54: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,493 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Directory</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Directory</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/directory_rb.html">
lib/rack/directory.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Directory.html">Rack::Directory</a> serves entries below the
<tt>root</tt> given, according to the path info of the <a
href="../Rack.html">Rack</a> request. If a directory is found, the
file&#8216;s contents will be presented in an html based index. If a file
is found, the env will be passed to the specified <tt>app</tt>.
</p>
<p>
If <tt>app</tt> is not specified, a <a href="File.html">Rack::File</a> of
the same <tt>root</tt> will be used.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000137">_call</a>&nbsp;&nbsp;
<a href="#M000136">call</a>&nbsp;&nbsp;
<a href="#M000138">check_forbidden</a>&nbsp;&nbsp;
<a href="#M000143">each</a>&nbsp;&nbsp;
<a href="#M000142">entity_not_found</a>&nbsp;&nbsp;
<a href="#M000144">filesize_format</a>&nbsp;&nbsp;
<a href="#M000139">list_directory</a>&nbsp;&nbsp;
<a href="#M000141">list_path</a>&nbsp;&nbsp;
<a href="#M000135">new</a>&nbsp;&nbsp;
<a href="#M000140">stat</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">DIR_FILE</td>
<td>=</td>
<td class="context-item-value">&quot;&lt;tr&gt;&lt;td class='name'&gt;&lt;a href='%s'&gt;%s&lt;/a&gt;&lt;/td&gt;&lt;td class='size'&gt;%s&lt;/td&gt;&lt;td class='type'&gt;%s&lt;/td&gt;&lt;td class='mtime'&gt;%s&lt;/td&gt;&lt;/tr&gt;&quot;</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">DIR_PAGE</td>
<td>=</td>
<td class="context-item-value">&lt;&lt;-PAGE &lt;html&gt;&lt;head&gt; &lt;title&gt;%s&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt; &lt;style type='text/css'&gt; table { width:100%%; } .name { text-align:left; } .size, .mtime { text-align:right; } .type { width:11em; } .mtime { width:15em; } &lt;/style&gt; &lt;/head&gt;&lt;body&gt; &lt;h1&gt;%s&lt;/h1&gt; &lt;hr /&gt; &lt;table&gt; &lt;tr&gt; &lt;th class='name'&gt;Name&lt;/th&gt; &lt;th class='size'&gt;Size&lt;/th&gt; &lt;th class='type'&gt;Type&lt;/th&gt; &lt;th class='mtime'&gt;Last Modified&lt;/th&gt; &lt;/tr&gt; %s &lt;/table&gt; &lt;hr /&gt; &lt;/body&gt;&lt;/html&gt; PAGE</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">F</td>
<td>=</td>
<td class="context-item-value">::File</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">FILESIZE_FORMAT</td>
<td>=</td>
<td class="context-item-value">[ ['%.1fT', 1 &lt;&lt; 40], ['%.1fG', 1 &lt;&lt; 30], ['%.1fM', 1 &lt;&lt; 20], ['%.1fK', 1 &lt;&lt; 10], ]</td>
<td width="3em">&nbsp;</td>
<td class="context-item-desc">
Stolen from Ramaze
</td>
</tr>
</table>
</div>
</div>
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">files</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">path</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">root</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000135" class="method-detail">
<a name="M000135"></a>
<div class="method-heading">
<a href="#M000135" class="method-signature">
<span class="method-name">new</span><span class="method-args">(root, app=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000135-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000135-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 45</span>
45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">root</span>, <span class="ruby-identifier">app</span>=<span class="ruby-keyword kw">nil</span>)
46: <span class="ruby-ivar">@root</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">root</span>)
47: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@root</span>)
48: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000137" class="method-detail">
<a name="M000137"></a>
<div class="method-heading">
<a href="#M000137" class="method-signature">
<span class="method-name">_call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000137-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000137-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 56</span>
56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
57: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">env</span>
58: <span class="ruby-ivar">@script_name</span> = <span class="ruby-identifier">env</span>[<span class="ruby-value str">'SCRIPT_NAME'</span>]
59: <span class="ruby-ivar">@path_info</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">'PATH_INFO'</span>])
60:
61: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">forbidden</span> = <span class="ruby-identifier">check_forbidden</span>
62: <span class="ruby-identifier">forbidden</span>
63: <span class="ruby-keyword kw">else</span>
64: <span class="ruby-ivar">@path</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@root</span>, <span class="ruby-ivar">@path_info</span>)
65: <span class="ruby-identifier">list_path</span>
66: <span class="ruby-keyword kw">end</span>
67: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000136" class="method-detail">
<a name="M000136"></a>
<div class="method-heading">
<a href="#M000136" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000136-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000136-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 50</span>
50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
51: <span class="ruby-identifier">dup</span>.<span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
52: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000138" class="method-detail">
<a name="M000138"></a>
<div class="method-heading">
<a href="#M000138" class="method-signature">
<span class="method-name">check_forbidden</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000138-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000138-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 69</span>
69: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_forbidden</span>
70: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@path_info</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;..&quot;</span>
71:
72: <span class="ruby-identifier">body</span> = <span class="ruby-value str">&quot;Forbidden\n&quot;</span>
73: <span class="ruby-identifier">size</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:bytesize</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">size</span>
74: <span class="ruby-keyword kw">return</span> [<span class="ruby-value">403</span>, {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/plain&quot;</span>,<span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>}, [<span class="ruby-identifier">body</span>]]
75: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000143" class="method-detail">
<a name="M000143"></a>
<div class="method-heading">
<a href="#M000143" class="method-signature">
<span class="method-name">each</span><span class="method-args">() {|l| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000143-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000143-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 127</span>
127: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
128: <span class="ruby-identifier">show_path</span> = <span class="ruby-ivar">@path</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-node">/^#{@root}/</span>,<span class="ruby-value str">''</span>)
129: <span class="ruby-identifier">files</span> = <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-constant">DIR_FILE</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">f</span> }<span class="ruby-operator">*</span><span class="ruby-value str">&quot;\n&quot;</span>
130: <span class="ruby-identifier">page</span> = <span class="ruby-constant">DIR_PAGE</span> <span class="ruby-operator">%</span> [ <span class="ruby-identifier">show_path</span>, <span class="ruby-identifier">show_path</span> , <span class="ruby-identifier">files</span> ]
131: <span class="ruby-identifier">page</span>.<span class="ruby-identifier">each_line</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">l</span> }
132: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000142" class="method-detail">
<a name="M000142"></a>
<div class="method-heading">
<a href="#M000142" class="method-signature">
<span class="method-name">entity_not_found</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000142-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000142-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 121</span>
121: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">entity_not_found</span>
122: <span class="ruby-identifier">body</span> = <span class="ruby-node">&quot;Entity not found: #{@path_info}\n&quot;</span>
123: <span class="ruby-identifier">size</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:bytesize</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">size</span>
124: <span class="ruby-keyword kw">return</span> [<span class="ruby-value">404</span>, {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/plain&quot;</span>, <span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>}, [<span class="ruby-identifier">body</span>]]
125: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000144" class="method-detail">
<a name="M000144"></a>
<div class="method-heading">
<a href="#M000144" class="method-signature">
<span class="method-name">filesize_format</span><span class="method-args">(int)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000144-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000144-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 143</span>
143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">filesize_format</span>(<span class="ruby-identifier">int</span>)
144: <span class="ruby-constant">FILESIZE_FORMAT</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span>, <span class="ruby-identifier">size</span><span class="ruby-operator">|</span>
145: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">format</span> <span class="ruby-operator">%</span> (<span class="ruby-identifier">int</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">size</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">int</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">size</span>
146: <span class="ruby-keyword kw">end</span>
147:
148: <span class="ruby-identifier">int</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'B'</span>
149: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000139" class="method-detail">
<a name="M000139"></a>
<div class="method-heading">
<a href="#M000139" class="method-signature">
<span class="method-name">list_directory</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000139-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000139-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 77</span>
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list_directory</span>
78: <span class="ruby-ivar">@files</span> = [[<span class="ruby-value str">'../'</span>,<span class="ruby-value str">'Parent Directory'</span>,<span class="ruby-value str">''</span>,<span class="ruby-value str">''</span>,<span class="ruby-value str">''</span>]]
79: <span class="ruby-identifier">glob</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>, <span class="ruby-value str">'*'</span>)
80:
81: <span class="ruby-constant">Dir</span>[<span class="ruby-identifier">glob</span>].<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">node</span><span class="ruby-operator">|</span>
82: <span class="ruby-identifier">stat</span> = <span class="ruby-identifier">stat</span>(<span class="ruby-identifier">node</span>)
83: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">stat</span>
84: <span class="ruby-identifier">basename</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">node</span>)
85: <span class="ruby-identifier">ext</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">node</span>)
86:
87: <span class="ruby-identifier">url</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@script_name</span>, <span class="ruby-ivar">@path_info</span>, <span class="ruby-identifier">basename</span>)
88: <span class="ruby-identifier">size</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">size</span>
89: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-value">? </span><span class="ruby-value str">'directory'</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Mime</span>.<span class="ruby-identifier">mime_type</span>(<span class="ruby-identifier">ext</span>)
90: <span class="ruby-identifier">size</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-value">? </span><span class="ruby-value str">'-'</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">filesize_format</span>(<span class="ruby-identifier">size</span>)
91: <span class="ruby-identifier">mtime</span> = <span class="ruby-identifier">stat</span>.<span class="ruby-identifier">mtime</span>.<span class="ruby-identifier">httpdate</span>
92:
93: <span class="ruby-ivar">@files</span> <span class="ruby-operator">&lt;&lt;</span> [ <span class="ruby-identifier">url</span>, <span class="ruby-identifier">basename</span>, <span class="ruby-identifier">size</span>, <span class="ruby-identifier">type</span>, <span class="ruby-identifier">mtime</span> ]
94: <span class="ruby-keyword kw">end</span>
95:
96: <span class="ruby-keyword kw">return</span> [ <span class="ruby-value">200</span>, {<span class="ruby-value str">'Content-Type'</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">'text/html; charset=utf-8'</span>}, <span class="ruby-keyword kw">self</span> ]
97: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000141" class="method-detail">
<a name="M000141"></a>
<div class="method-heading">
<a href="#M000141" class="method-signature">
<span class="method-name">list_path</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
TODO: add correct response if not readable, not sure if 404 is the best
</p>
<pre>
option
</pre>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000141-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000141-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 107</span>
107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list_path</span>
108: <span class="ruby-ivar">@stat</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-ivar">@path</span>)
109:
110: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stat</span>.<span class="ruby-identifier">readable?</span>
111: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@env</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stat</span>.<span class="ruby-identifier">file?</span>
112: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">list_directory</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stat</span>.<span class="ruby-identifier">directory?</span>
113: <span class="ruby-keyword kw">else</span>
114: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-value str">'No such file or directory'</span>
115: <span class="ruby-keyword kw">end</span>
116:
117: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ELOOP</span>
118: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">entity_not_found</span>
119: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000140" class="method-detail">
<a name="M000140"></a>
<div class="method-heading">
<a href="#M000140" class="method-signature">
<span class="method-name">stat</span><span class="method-args">(node, max = 10)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000140-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000140-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/directory.rb, line 99</span>
99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stat</span>(<span class="ruby-identifier">node</span>, <span class="ruby-identifier">max</span> = <span class="ruby-value">10</span>)
100: <span class="ruby-constant">F</span>.<span class="ruby-identifier">stat</span>(<span class="ruby-identifier">node</span>)
101: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ENOENT</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ELOOP</span>
102: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
103: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,378 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::File</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::File</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/file_rb.html">
lib/rack/file.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="File.html">Rack::File</a> serves files below the <tt>root</tt>
given, according to the path info of the <a href="../Rack.html">Rack</a>
request.
</p>
<p>
Handlers can detect if bodies are a <a href="File.html">Rack::File</a>, and
use mechanisms like sendfile on the <tt>path</tt>.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000206">_call</a>&nbsp;&nbsp;
<a href="#M000205">call</a>&nbsp;&nbsp;
<a href="#M000210">each</a>&nbsp;&nbsp;
<a href="#M000207">forbidden</a>&nbsp;&nbsp;
<a href="#M000204">new</a>&nbsp;&nbsp;
<a href="#M000209">not_found</a>&nbsp;&nbsp;
<a href="#M000208">serving</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">F</td>
<td>=</td>
<td class="context-item-value">::File</td>
</tr>
</table>
</div>
</div>
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">path</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">root</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000204" class="method-detail">
<a name="M000204"></a>
<div class="method-heading">
<a href="#M000204" class="method-signature">
<span class="method-name">new</span><span class="method-args">(root)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000204-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000204-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 15</span>
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">root</span>)
16: <span class="ruby-ivar">@root</span> = <span class="ruby-identifier">root</span>
17: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000206" class="method-detail">
<a name="M000206"></a>
<div class="method-heading">
<a href="#M000206" class="method-signature">
<span class="method-name">_call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000206-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000206-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 25</span>
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
26: <span class="ruby-ivar">@path_info</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>])
27: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">forbidden</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@path_info</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;..&quot;</span>
28:
29: <span class="ruby-ivar">@path</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@root</span>, <span class="ruby-ivar">@path_info</span>)
30:
31: <span class="ruby-keyword kw">begin</span>
32: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">F</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-ivar">@path</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">F</span>.<span class="ruby-identifier">readable?</span>(<span class="ruby-ivar">@path</span>)
33: <span class="ruby-identifier">serving</span>
34: <span class="ruby-keyword kw">else</span>
35: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPERM</span>
36: <span class="ruby-keyword kw">end</span>
37: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemCallError</span>
38: <span class="ruby-identifier">not_found</span>
39: <span class="ruby-keyword kw">end</span>
40: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000205" class="method-detail">
<a name="M000205"></a>
<div class="method-heading">
<a href="#M000205" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000205-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000205-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 19</span>
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
20: <span class="ruby-identifier">dup</span>.<span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
21: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000210" class="method-detail">
<a name="M000210"></a>
<div class="method-heading">
<a href="#M000210" class="method-signature">
<span class="method-name">each</span><span class="method-args">() {|part| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000210-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000210-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 77</span>
77: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
78: <span class="ruby-constant">F</span>.<span class="ruby-identifier">open</span>(<span class="ruby-ivar">@path</span>, <span class="ruby-value str">&quot;rb&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
79: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">part</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">8192</span>)
80: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">part</span>
81: <span class="ruby-keyword kw">end</span>
82: }
83: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000207" class="method-detail">
<a name="M000207"></a>
<div class="method-heading">
<a href="#M000207" class="method-signature">
<span class="method-name">forbidden</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000207-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000207-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 42</span>
42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">forbidden</span>
43: <span class="ruby-identifier">body</span> = <span class="ruby-value str">&quot;Forbidden\n&quot;</span>
44: [<span class="ruby-value">403</span>, {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/plain&quot;</span>,
45: <span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>},
46: [<span class="ruby-identifier">body</span>]]
47: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000209" class="method-detail">
<a name="M000209"></a>
<div class="method-heading">
<a href="#M000209" class="method-signature">
<span class="method-name">not_found</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000209-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000209-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 70</span>
70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">not_found</span>
71: <span class="ruby-identifier">body</span> = <span class="ruby-node">&quot;File not found: #{@path_info}\n&quot;</span>
72: [<span class="ruby-value">404</span>, {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/plain&quot;</span>,
73: <span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>},
74: [<span class="ruby-identifier">body</span>]]
75: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000208" class="method-detail">
<a name="M000208"></a>
<div class="method-heading">
<a href="#M000208" class="method-signature">
<span class="method-name">serving</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p>
NOTE:
</p>
<pre>
We check via File::size? whether this file provides size info
via stat (e.g. /proc files often don't), otherwise we have to
figure it out by reading the whole file into memory. And while
we're at it we also use this as body then.
</pre>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000208-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000208-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/file.rb, line 55</span>
55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serving</span>
56: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span> = <span class="ruby-constant">F</span>.<span class="ruby-identifier">size?</span>(<span class="ruby-ivar">@path</span>)
57: <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">self</span>
58: <span class="ruby-keyword kw">else</span>
59: <span class="ruby-identifier">body</span> = [<span class="ruby-constant">F</span>.<span class="ruby-identifier">read</span>(<span class="ruby-ivar">@path</span>)]
60: <span class="ruby-identifier">size</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>
61: <span class="ruby-keyword kw">end</span>
62:
63: [<span class="ruby-value">200</span>, {
64: <span class="ruby-value str">&quot;Last-Modified&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">F</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-ivar">@path</span>).<span class="ruby-identifier">httpdate</span>,
65: <span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Mime</span>.<span class="ruby-identifier">mime_type</span>(<span class="ruby-constant">F</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-ivar">@path</span>), <span class="ruby-value str">'text/plain'</span>),
66: <span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>
67: }, <span class="ruby-identifier">body</span>]
68: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,184 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::ForwardRequest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::ForwardRequest</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/recursive_rb.html">
lib/rack/recursive.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Exception
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="ForwardRequest.html">Rack::ForwardRequest</a> gets caught by <a
href="Recursive.html">Rack::Recursive</a> and redirects the current request
to the app at <tt>url</tt>.
</p>
<pre>
raise ForwardRequest.new(&quot;/not-found&quot;)
</pre>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000203">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">env</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">url</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000203" class="method-detail">
<a name="M000203"></a>
<div class="method-heading">
<a href="#M000203" class="method-signature">
<span class="method-name">new</span><span class="method-args">(url, env={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000203-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000203-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/recursive.rb, line 13</span>
13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">env</span>={})
14: <span class="ruby-ivar">@url</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">url</span>)
15: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">env</span>
16:
17: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">path</span>
18: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">query</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">query</span>
19: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;HTTP_HOST&quot;</span>] = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">host</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">host</span>
20: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;HTTP_PORT&quot;</span>] = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">port</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">port</span>
21: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;rack.url_scheme&quot;</span>] = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">scheme</span>
22:
23: <span class="ruby-keyword kw">super</span> <span class="ruby-node">&quot;forwarding to #{url}&quot;</span>
24: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Forwarder</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Forwarder</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/forward_rb.html">
lib/rack/forward.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000075">call</a>&nbsp;&nbsp;
<a href="#M000074">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000074" class="method-detail">
<a name="M000074"></a>
<div class="method-heading">
<a href="#M000074" class="method-signature">
<span class="method-name">new</span><span class="method-args">(host, port=80)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000074-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/forward.rb, line 12</span>
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>=<span class="ruby-value">80</span>)
13: <span class="ruby-ivar">@host</span>, <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>
14: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000075" class="method-detail">
<a name="M000075"></a>
<div class="method-heading">
<a href="#M000075" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000075-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/forward.rb, line 16</span>
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
17: <span class="ruby-identifier">rackreq</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
18:
19: <span class="ruby-identifier">headers</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>
20: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
21: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/HTTP_(.*)/</span>
22: <span class="ruby-identifier">headers</span>[<span class="ruby-identifier">$1</span>] = <span class="ruby-identifier">value</span>
23: <span class="ruby-keyword kw">end</span>
24: }
25:
26: <span class="ruby-identifier">res</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-ivar">@host</span>, <span class="ruby-ivar">@port</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
27: <span class="ruby-identifier">m</span> = <span class="ruby-identifier">rackreq</span>.<span class="ruby-identifier">request_method</span>
28: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">m</span>
29: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>, <span class="ruby-value str">&quot;HEAD&quot;</span>, <span class="ruby-value str">&quot;DELETE&quot;</span>, <span class="ruby-value str">&quot;OPTIONS&quot;</span>, <span class="ruby-value str">&quot;TRACE&quot;</span>
30: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">capitalize</span>).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">rackreq</span>.<span class="ruby-identifier">fullpath</span>, <span class="ruby-identifier">headers</span>)
31: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;PUT&quot;</span>, <span class="ruby-value str">&quot;POST&quot;</span>
32: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">capitalize</span>).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">rackreq</span>.<span class="ruby-identifier">fullpath</span>, <span class="ruby-identifier">headers</span>)
33: <span class="ruby-identifier">req</span>.<span class="ruby-identifier">body_stream</span> = <span class="ruby-identifier">rackreq</span>.<span class="ruby-identifier">body</span>
34: <span class="ruby-keyword kw">else</span>
35: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;method not supported: #{method}&quot;</span>
36: <span class="ruby-keyword kw">end</span>
37:
38: <span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">req</span>)
39: }
40:
41: [<span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span>, <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">to_hash</span>), [<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>]]
42: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,242 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack::Handler</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack::Handler</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/handler_rb.html">
lib/rack/handler.rb
</a>
<br />
<a href="../../files/lib/rack/handler/cgi_rb.html">
lib/rack/handler/cgi.rb
</a>
<br />
<a href="../../files/lib/rack/handler/evented_mongrel_rb.html">
lib/rack/handler/evented_mongrel.rb
</a>
<br />
<a href="../../files/lib/rack/handler/fastcgi_rb.html">
lib/rack/handler/fastcgi.rb
</a>
<br />
<a href="../../files/lib/rack/handler/lsws_rb.html">
lib/rack/handler/lsws.rb
</a>
<br />
<a href="../../files/lib/rack/handler/mongrel_rb.html">
lib/rack/handler/mongrel.rb
</a>
<br />
<a href="../../files/lib/rack/handler/scgi_rb.html">
lib/rack/handler/scgi.rb
</a>
<br />
<a href="../../files/lib/rack/handler/swiftiplied_mongrel_rb.html">
lib/rack/handler/swiftiplied_mongrel.rb
</a>
<br />
<a href="../../files/lib/rack/handler/thin_rb.html">
lib/rack/handler/thin.rb
</a>
<br />
<a href="../../files/lib/rack/handler/webrick_rb.html">
lib/rack/handler/webrick.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<b>Handlers</b> connect web servers with <a href="../Rack.html">Rack</a>.
</p>
<p>
<a href="../Rack.html">Rack</a> includes Handlers for <a
href="Handler/Mongrel.html">Mongrel</a>, <a
href="Handler/WEBrick.html">WEBrick</a>, <a
href="Handler/FastCGI.html">FastCGI</a>, <a
href="Handler/CGI.html">CGI</a>, <a href="Handler/SCGI.html">SCGI</a> and
LiteSpeed.
</p>
<p>
Handlers usually are activated by calling <tt>MyHandler.run(myapp)</tt>. A
second optional hash can be passed to include server-specific
configuration.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000044">get</a>&nbsp;&nbsp;
<a href="#M000045">register</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Class <a href="Handler/CGI.html" class="link">Rack::Handler::CGI</a><br />
Class <a href="Handler/EventedMongrel.html" class="link">Rack::Handler::EventedMongrel</a><br />
Class <a href="Handler/FastCGI.html" class="link">Rack::Handler::FastCGI</a><br />
Class <a href="Handler/LSWS.html" class="link">Rack::Handler::LSWS</a><br />
Class <a href="Handler/Mongrel.html" class="link">Rack::Handler::Mongrel</a><br />
Class <a href="Handler/SCGI.html" class="link">Rack::Handler::SCGI</a><br />
Class <a href="Handler/SwiftipliedMongrel.html" class="link">Rack::Handler::SwiftipliedMongrel</a><br />
Class <a href="Handler/Thin.html" class="link">Rack::Handler::Thin</a><br />
Class <a href="Handler/WEBrick.html" class="link">Rack::Handler::WEBrick</a><br />
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000044" class="method-detail">
<a name="M000044"></a>
<div class="method-heading">
<a href="#M000044" class="method-signature">
<span class="method-name">get</span><span class="method-args">(server)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000044-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler.rb, line 11</span>
11: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">server</span>)
12: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">server</span>
13:
14: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span> = <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">server</span>]
15: <span class="ruby-identifier">obj</span> = <span class="ruby-constant">Object</span>
16: <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;::&quot;</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">x</span>) }
17: <span class="ruby-identifier">obj</span>
18: <span class="ruby-keyword kw">else</span>
19: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">server</span>.<span class="ruby-identifier">capitalize</span>)
20: <span class="ruby-keyword kw">end</span>
21: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000045" class="method-detail">
<a name="M000045"></a>
<div class="method-heading">
<a href="#M000045" class="method-signature">
<span class="method-name">register</span><span class="method-args">(server, klass)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000045-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler.rb, line 23</span>
23: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">server</span>, <span class="ruby-identifier">klass</span>)
24: <span class="ruby-ivar">@handlers</span> <span class="ruby-operator">||=</span> {}
25: <span class="ruby-ivar">@handlers</span>[<span class="ruby-identifier">server</span>] = <span class="ruby-identifier">klass</span>
26: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,254 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::CGI</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::CGI</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/cgi_rb.html">
lib/rack/handler/cgi.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000051">run</a>&nbsp;&nbsp;
<a href="#M000054">send_body</a>&nbsp;&nbsp;
<a href="#M000053">send_headers</a>&nbsp;&nbsp;
<a href="#M000052">serve</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000051" class="method-detail">
<a name="M000051"></a>
<div class="method-heading">
<a href="#M000051" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000051-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/cgi.rb, line 4</span>
4: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>=<span class="ruby-keyword kw">nil</span>)
5: <span class="ruby-identifier">serve</span> <span class="ruby-identifier">app</span>
6: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000054" class="method-detail">
<a name="M000054"></a>
<div class="method-heading">
<a href="#M000054" class="method-signature">
<span class="method-name">send_body</span><span class="method-args">(body)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000054-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/cgi.rb, line 49</span>
49: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_body</span>(<span class="ruby-identifier">body</span>)
50: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
51: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">part</span>
52: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">flush</span>
53: }
54: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000053" class="method-detail">
<a name="M000053"></a>
<div class="method-heading">
<a href="#M000053" class="method-signature">
<span class="method-name">send_headers</span><span class="method-args">(status, headers)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000053-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/cgi.rb, line 38</span>
38: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_headers</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>)
39: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;Status: #{status}\r\n&quot;</span>
40: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
41: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
42: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;#{k}: #{v}\r\n&quot;</span>
43: }
44: }
45: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">print</span> <span class="ruby-value str">&quot;\r\n&quot;</span>
46: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">flush</span>
47: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000052" class="method-detail">
<a name="M000052"></a>
<div class="method-heading">
<a href="#M000052" class="method-signature">
<span class="method-name">serve</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000052-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/cgi.rb, line 8</span>
8: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">serve</span>(<span class="ruby-identifier">app</span>)
9: <span class="ruby-identifier">env</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span>
10: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_LENGTH&quot;</span>
11:
12: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
13:
14: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
15: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDIN</span>,
16: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDERR</span>,
17:
18: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
19: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
20: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
21:
22: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;yes&quot;</span>, <span class="ruby-value str">&quot;on&quot;</span>, <span class="ruby-value str">&quot;1&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HTTPS&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;https&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;http&quot;</span>
23: })
24:
25: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
26: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PROTOCOL&quot;</span>]
27: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;/&quot;</span>
28:
29: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
30: <span class="ruby-keyword kw">begin</span>
31: <span class="ruby-identifier">send_headers</span> <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>
32: <span class="ruby-identifier">send_body</span> <span class="ruby-identifier">body</span>
33: <span class="ruby-keyword kw">ensure</span>
34: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
35: <span class="ruby-keyword kw">end</span>
36: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::EventedMongrel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::EventedMongrel</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/evented_mongrel_rb.html">
lib/rack/handler/evented_mongrel.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Handler::Mongrel
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,264 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::FastCGI</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::FastCGI</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/fastcgi_rb.html">
lib/rack/handler/fastcgi.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000046">run</a>&nbsp;&nbsp;
<a href="#M000049">send_body</a>&nbsp;&nbsp;
<a href="#M000048">send_headers</a>&nbsp;&nbsp;
<a href="#M000047">serve</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000046" class="method-detail">
<a name="M000046"></a>
<div class="method-heading">
<a href="#M000046" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000046-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000046-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/fastcgi.rb, line 7</span>
7: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
8: <span class="ruby-identifier">file</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:File</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-constant">UNIXServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file</span>))
9: <span class="ruby-identifier">port</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Port</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">port</span>))
10: <span class="ruby-constant">FCGI</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">request</span><span class="ruby-operator">|</span>
11: <span class="ruby-identifier">serve</span> <span class="ruby-identifier">request</span>, <span class="ruby-identifier">app</span>
12: }
13: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000049" class="method-detail">
<a name="M000049"></a>
<div class="method-heading">
<a href="#M000049" class="method-signature">
<span class="method-name">send_body</span><span class="method-args">(out, body)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000049-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/fastcgi.rb, line 78</span>
78: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_body</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">body</span>)
79: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
80: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">part</span>
81: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">flush</span>
82: }
83: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000048" class="method-detail">
<a name="M000048"></a>
<div class="method-heading">
<a href="#M000048" class="method-signature">
<span class="method-name">send_headers</span><span class="method-args">(out, status, headers)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000048-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/fastcgi.rb, line 67</span>
67: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_headers</span>(<span class="ruby-identifier">out</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>)
68: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;Status: #{status}\r\n&quot;</span>
69: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
70: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
71: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">&quot;#{k}: #{v}\r\n&quot;</span>
72: }
73: }
74: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">print</span> <span class="ruby-value str">&quot;\r\n&quot;</span>
75: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">flush</span>
76: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000047" class="method-detail">
<a name="M000047"></a>
<div class="method-heading">
<a href="#M000047" class="method-signature">
<span class="method-name">serve</span><span class="method-args">(request, app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000047-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/fastcgi.rb, line 31</span>
31: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">serve</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">app</span>)
32: <span class="ruby-identifier">env</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">env</span>
33: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_LENGTH&quot;</span>
34:
35: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">in</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">ProperStream</span>
36:
37: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
38:
39: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
40: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">in</span>,
41: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">err</span>,
42:
43: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
44: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
45: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
46:
47: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;yes&quot;</span>, <span class="ruby-value str">&quot;on&quot;</span>, <span class="ruby-value str">&quot;1&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTPS&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;https&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;http&quot;</span>
48: })
49:
50: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
51: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PROTOCOL&quot;</span>]
52: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;/&quot;</span>
53: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;PATH_INFO&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
54: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;CONTENT_TYPE&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;CONTENT_TYPE&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
55: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;CONTENT_LENGTH&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;CONTENT_LENGTH&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
56:
57: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
58: <span class="ruby-keyword kw">begin</span>
59: <span class="ruby-identifier">send_headers</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">out</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>
60: <span class="ruby-identifier">send_body</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">out</span>, <span class="ruby-identifier">body</span>
61: <span class="ruby-keyword kw">ensure</span>
62: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
63: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">finish</span>
64: <span class="ruby-keyword kw">end</span>
65: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,250 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::LSWS</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::LSWS</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/lsws_rb.html">
lib/rack/handler/lsws.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000058">run</a>&nbsp;&nbsp;
<a href="#M000061">send_body</a>&nbsp;&nbsp;
<a href="#M000060">send_headers</a>&nbsp;&nbsp;
<a href="#M000059">serve</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000058" class="method-detail">
<a name="M000058"></a>
<div class="method-heading">
<a href="#M000058" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000058-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 6</span>
6: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>=<span class="ruby-keyword kw">nil</span>)
7: <span class="ruby-keyword kw">while</span> <span class="ruby-constant">LSAPI</span>.<span class="ruby-identifier">accept</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
8: <span class="ruby-identifier">serve</span> <span class="ruby-identifier">app</span>
9: <span class="ruby-keyword kw">end</span>
10: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000061" class="method-detail">
<a name="M000061"></a>
<div class="method-heading">
<a href="#M000061" class="method-signature">
<span class="method-name">send_body</span><span class="method-args">(body)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000061-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 44</span>
44: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_body</span>(<span class="ruby-identifier">body</span>)
45: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
46: <span class="ruby-identifier">print</span> <span class="ruby-identifier">part</span>
47: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">flush</span>
48: }
49: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000060" class="method-detail">
<a name="M000060"></a>
<div class="method-heading">
<a href="#M000060" class="method-signature">
<span class="method-name">send_headers</span><span class="method-args">(status, headers)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000060-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 34</span>
34: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send_headers</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>)
35: <span class="ruby-identifier">print</span> <span class="ruby-node">&quot;Status: #{status}\r\n&quot;</span>
36: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
37: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
38: <span class="ruby-identifier">print</span> <span class="ruby-node">&quot;#{k}: #{v}\r\n&quot;</span>
39: }
40: }
41: <span class="ruby-identifier">print</span> <span class="ruby-value str">&quot;\r\n&quot;</span>
42: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">flush</span>
43: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000059" class="method-detail">
<a name="M000059"></a>
<div class="method-heading">
<a href="#M000059" class="method-signature">
<span class="method-name">serve</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000059-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/lsws.rb, line 11</span>
11: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">serve</span>(<span class="ruby-identifier">app</span>)
12: <span class="ruby-identifier">env</span> = <span class="ruby-constant">ENV</span>.<span class="ruby-identifier">to_hash</span>
13: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_LENGTH&quot;</span>
14: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
15: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
16: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDIN</span>,
17: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDERR</span>,
18: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
19: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
20: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
21: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;yes&quot;</span>, <span class="ruby-value str">&quot;on&quot;</span>, <span class="ruby-value str">&quot;1&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HTTPS&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;https&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;http&quot;</span>
22: })
23: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
24: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PROTOCOL&quot;</span>]
25: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;/&quot;</span>
26: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
27: <span class="ruby-keyword kw">begin</span>
28: <span class="ruby-identifier">send_headers</span> <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>
29: <span class="ruby-identifier">send_body</span> <span class="ruby-identifier">body</span>
30: <span class="ruby-keyword kw">ensure</span>
31: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
32: <span class="ruby-keyword kw">end</span>
33: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::Mongrel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::Mongrel</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/mongrel_rb.html">
lib/rack/handler/mongrel.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
::Mongrel::HttpHandler
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000066">new</a>&nbsp;&nbsp;
<a href="#M000067">process</a>&nbsp;&nbsp;
<a href="#M000065">run</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000066" class="method-detail">
<a name="M000066"></a>
<div class="method-heading">
<a href="#M000066" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000066-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000066-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/mongrel.rb, line 35</span>
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
36: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
37: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000065" class="method-detail">
<a name="M000065"></a>
<div class="method-heading">
<a href="#M000065" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options={}) {|server if block_given?| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000065-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/mongrel.rb, line 7</span>
7: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
8: <span class="ruby-identifier">server</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span><span class="ruby-operator">::</span><span class="ruby-constant">HttpServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Host</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'0.0.0.0'</span>,
9: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Port</span>] <span class="ruby-operator">||</span> <span class="ruby-value">8080</span>)
10: <span class="ruby-comment cmt"># Acts like Rack::URLMap, utilizing Mongrel's own path finding methods.</span>
11: <span class="ruby-comment cmt"># Use is similar to #run, replacing the app argument with a hash of </span>
12: <span class="ruby-comment cmt"># { path=&gt;app, ... } or an instance of Rack::URLMap.</span>
13: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:map</span>]
14: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">app</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
15: <span class="ruby-identifier">app</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span>, <span class="ruby-identifier">appl</span><span class="ruby-operator">|</span>
16: <span class="ruby-identifier">path</span> = <span class="ruby-value str">'/'</span><span class="ruby-operator">+</span><span class="ruby-identifier">path</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">path</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?/</span>
17: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">path</span>, <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">appl</span>))
18: <span class="ruby-keyword kw">end</span>
19: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">app</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">URLMap</span>
20: <span class="ruby-identifier">app</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-identifier">:@mapping</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">appl</span>)<span class="ruby-operator">|</span>
21: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">host</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Host</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Host</span>] <span class="ruby-operator">!=</span> <span class="ruby-identifier">host</span>
22: <span class="ruby-identifier">path</span> = <span class="ruby-value str">'/'</span><span class="ruby-operator">+</span><span class="ruby-identifier">path</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">path</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?/</span>
23: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">path</span>, <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">appl</span>))
24: <span class="ruby-keyword kw">end</span>
25: <span class="ruby-keyword kw">else</span>
26: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;first argument should be a Hash or URLMap&quot;</span>
27: <span class="ruby-keyword kw">end</span>
28: <span class="ruby-keyword kw">else</span>
29: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">register</span>(<span class="ruby-value str">'/'</span>, <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>))
30: <span class="ruby-keyword kw">end</span>
31: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">server</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
32: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">run</span>.<span class="ruby-identifier">join</span>
33: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000067" class="method-detail">
<a name="M000067"></a>
<div class="method-heading">
<a href="#M000067" class="method-signature">
<span class="method-name">process</span><span class="method-args">(request, response)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000067-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000067-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/mongrel.rb, line 39</span>
39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
40: <span class="ruby-identifier">env</span> = {}.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>)
41: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_TYPE&quot;</span>
42: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_LENGTH&quot;</span>
43:
44: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>
45:
46: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
47: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator">||</span> <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;&quot;</span>),
48: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDERR</span>,
49:
50: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
51: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>, <span class="ruby-comment cmt"># ???</span>
52: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
53:
54: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;http&quot;</span>,
55: })
56: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
57: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;PATH_INFO&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
58:
59: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
60:
61: <span class="ruby-keyword kw">begin</span>
62: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>
63: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_status</span>(<span class="ruby-keyword kw">nil</span>)
64:
65: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
66: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
67: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
68: }
69: }
70: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">send_header</span>
71:
72: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
73: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">part</span>
74: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">socket</span>.<span class="ruby-identifier">flush</span>
75: }
76: <span class="ruby-keyword kw">ensure</span>
77: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
78: <span class="ruby-keyword kw">end</span>
79: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,244 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::SCGI</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::SCGI</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/scgi_rb.html">
lib/rack/handler/scgi.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
::SCGI::Processor
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000056">new</a>&nbsp;&nbsp;
<a href="#M000057">process_request</a>&nbsp;&nbsp;
<a href="#M000055">run</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">app</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000056" class="method-detail">
<a name="M000056"></a>
<div class="method-heading">
<a href="#M000056" class="method-signature">
<span class="method-name">new</span><span class="method-args">(settings = {})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000056-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/scgi.rb, line 16</span>
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">settings</span> = {})
17: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">settings</span>[<span class="ruby-identifier">:app</span>]
18: <span class="ruby-ivar">@log</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
19: <span class="ruby-keyword kw">def</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>); <span class="ruby-keyword kw">end</span>
20: <span class="ruby-keyword kw">def</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>); <span class="ruby-keyword kw">end</span>
21: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">settings</span>)
22: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000055" class="method-detail">
<a name="M000055"></a>
<div class="method-heading">
<a href="#M000055" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000055-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/scgi.rb, line 9</span>
9: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>=<span class="ruby-keyword kw">nil</span>)
10: <span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:app=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">app</span>,
11: <span class="ruby-identifier">:host=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Host</span>],
12: <span class="ruby-identifier">:port=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Port</span>],
13: <span class="ruby-identifier">:socket=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Socket</span>])).<span class="ruby-identifier">listen</span>
14: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000057" class="method-detail">
<a name="M000057"></a>
<div class="method-heading">
<a href="#M000057" class="method-signature">
<span class="method-name">process_request</span><span class="method-args">(request, input_body, socket)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000057-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/scgi.rb, line 24</span>
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_request</span><span class="ruby-identifier">process_request</span><span class="ruby-identifier">process_request</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">input_body</span>, <span class="ruby-identifier">socket</span>)
25: <span class="ruby-identifier">env</span> = {}.<span class="ruby-identifier">replace</span>(<span class="ruby-identifier">request</span>)
26: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_TYPE&quot;</span>
27: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;HTTP_CONTENT_LENGTH&quot;</span>
28: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>], <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_URI&quot;</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">'?'</span>, <span class="ruby-value">2</span>)
29: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PROTOCOL&quot;</span>]
30: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>]
31: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
32: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-value str">&quot;&quot;</span>
33: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
34: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">input_body</span>),
35: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDERR</span>,
36:
37: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
38: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
39: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
40:
41: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;yes&quot;</span>, <span class="ruby-value str">&quot;on&quot;</span>, <span class="ruby-value str">&quot;1&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTPS&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;https&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;http&quot;</span>
42: })
43: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
44: <span class="ruby-keyword kw">begin</span>
45: <span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;Status: #{status}\r\n&quot;</span>)
46: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
47: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{k}: #{v}\r\n&quot;</span>)}
48: <span class="ruby-keyword kw">end</span>
49: <span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;\r\n&quot;</span>)
50: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">s</span>)}
51: <span class="ruby-keyword kw">ensure</span>
52: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
53: <span class="ruby-keyword kw">end</span>
54: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::SwiftipliedMongrel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::SwiftipliedMongrel</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/swiftiplied_mongrel_rb.html">
lib/rack/handler/swiftiplied_mongrel.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Handler::Mongrel
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::Thin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::Thin</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/thin_rb.html">
lib/rack/handler/thin.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000050">run</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000050" class="method-detail">
<a name="M000050"></a>
<div class="method-heading">
<a href="#M000050" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options={}) {|server if block_given?| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000050-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/thin.rb, line 6</span>
6: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
7: <span class="ruby-identifier">server</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Thin</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Host</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'0.0.0.0'</span>,
8: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:Port</span>] <span class="ruby-operator">||</span> <span class="ruby-value">8080</span>,
9: <span class="ruby-identifier">app</span>)
10: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">server</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
11: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">start</span>
12: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Handler::WEBrick</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Handler::WEBrick</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/handler/webrick_rb.html">
lib/rack/handler/webrick.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
::WEBrick::HTTPServlet::AbstractServlet
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000063">new</a>&nbsp;&nbsp;
<a href="#M000062">run</a>&nbsp;&nbsp;
<a href="#M000064">service</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000063" class="method-detail">
<a name="M000063"></a>
<div class="method-heading">
<a href="#M000063" class="method-signature">
<span class="method-name">new</span><span class="method-args">(server, app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000063-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/webrick.rb, line 15</span>
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">server</span>, <span class="ruby-identifier">app</span>)
16: <span class="ruby-keyword kw">super</span> <span class="ruby-identifier">server</span>
17: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
18: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000062" class="method-detail">
<a name="M000062"></a>
<div class="method-heading">
<a href="#M000062" class="method-signature">
<span class="method-name">run</span><span class="method-args">(app, options={}) {|server if block_given?| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000062-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/webrick.rb, line 7</span>
7: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
8: <span class="ruby-identifier">server</span> = <span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>)
9: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">mount</span> <span class="ruby-value str">&quot;/&quot;</span>, <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>, <span class="ruby-identifier">app</span>
10: <span class="ruby-identifier">trap</span>(<span class="ruby-identifier">:INT</span>) { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
11: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">server</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
12: <span class="ruby-identifier">server</span>.<span class="ruby-identifier">start</span>
13: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000064" class="method-detail">
<a name="M000064"></a>
<div class="method-heading">
<a href="#M000064" class="method-signature">
<span class="method-name">service</span><span class="method-args">(req, res)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000064-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/handler/webrick.rb, line 20</span>
20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">service</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">res</span>)
21: <span class="ruby-identifier">env</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">meta_vars</span>
22: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">nil?</span> }
23:
24: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">update</span>({<span class="ruby-value str">&quot;rack.version&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">0</span>,<span class="ruby-value">1</span>],
25: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_s</span>),
26: <span class="ruby-value str">&quot;rack.errors&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">STDERR</span>,
27:
28: <span class="ruby-value str">&quot;rack.multithread&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>,
29: <span class="ruby-value str">&quot;rack.multiprocess&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
30: <span class="ruby-value str">&quot;rack.run_once&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>,
31:
32: <span class="ruby-value str">&quot;rack.url_scheme&quot;</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;yes&quot;</span>, <span class="ruby-value str">&quot;on&quot;</span>, <span class="ruby-value str">&quot;1&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HTTPS&quot;</span>]) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;https&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;http&quot;</span>
33: })
34:
35: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PROTOCOL&quot;</span>]
36: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
37: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_PATH&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;/&quot;</span>
38: <span class="ruby-identifier">env</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;PATH_INFO&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
39:
40: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
41: <span class="ruby-keyword kw">begin</span>
42: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>
43: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">vs</span><span class="ruby-operator">|</span>
44: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;set-cookie&quot;</span>
45: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">cookies</span>.<span class="ruby-identifier">concat</span> <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">to_a</span>
46: <span class="ruby-keyword kw">else</span>
47: <span class="ruby-identifier">vs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
48: <span class="ruby-identifier">res</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
49: }
50: <span class="ruby-keyword kw">end</span>
51: }
52: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
53: <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">part</span>
54: }
55: <span class="ruby-keyword kw">ensure</span>
56: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
57: <span class="ruby-keyword kw">end</span>
58: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Head</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Head</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/head_rb.html">
lib/rack/head.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000073">call</a>&nbsp;&nbsp;
<a href="#M000072">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000072" class="method-detail">
<a name="M000072"></a>
<div class="method-heading">
<a href="#M000072" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000072-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/head.rb, line 4</span>
4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
5: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
6: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000073" class="method-detail">
<a name="M000073"></a>
<div class="method-heading">
<a href="#M000073" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000073-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/head.rb, line 8</span>
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
9: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
10:
11: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;HEAD&quot;</span>
12: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, []]
13: <span class="ruby-keyword kw">else</span>
14: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
15: <span class="ruby-keyword kw">end</span>
16: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Lint</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Lint</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/lint_rb.html">
lib/rack/lint.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Lint.html">Rack::Lint</a> validates your application and the
requests and responses according to the <a href="../Rack.html">Rack</a>
spec.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000082">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000082" class="method-detail">
<a name="M000082"></a>
<div class="method-heading">
<a href="#M000082" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000082-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000082-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/lint.rb, line 6</span>
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
7: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
8: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Lobster</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Lobster</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/lobster_rb.html">
lib/rack/lobster.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
Paste has a Pony, <a href="../Rack.html">Rack</a> has a <a
href="Lobster.html">Lobster</a>!
</p>
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">LobsterString</td>
<td>=</td>
<td class="context-item-value">Zlib::Inflate.inflate(&quot;eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2 P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0 t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==&quot;.delete(&quot;\n &quot;).unpack(&quot;m*&quot;)[0])</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">LambdaLobster</td>
<td>=</td>
<td class="context-item-value">lambda { |env| if env[&quot;QUERY_STRING&quot;].include?(&quot;flip&quot;)</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::MethodOverride</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::MethodOverride</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/methodoverride_rb.html">
lib/rack/methodoverride.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000079">call</a>&nbsp;&nbsp;
<a href="#M000078">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">HTTP_METHODS</td>
<td>=</td>
<td class="context-item-value">%w(GET HEAD PUT POST DELETE OPTIONS)</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">METHOD_OVERRIDE_PARAM_KEY</td>
<td>=</td>
<td class="context-item-value">&quot;_method&quot;.freeze</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">HTTP_METHOD_OVERRIDE_HEADER</td>
<td>=</td>
<td class="context-item-value">&quot;HTTP_X_HTTP_METHOD_OVERRIDE&quot;.freeze</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000078" class="method-detail">
<a name="M000078"></a>
<div class="method-heading">
<a href="#M000078" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000078-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/methodoverride.rb, line 8</span>
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
9: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
10: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000079" class="method-detail">
<a name="M000079"></a>
<div class="method-heading">
<a href="#M000079" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000079-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/methodoverride.rb, line 12</span>
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
13: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;POST&quot;</span>
14: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
15: <span class="ruby-identifier">method</span> = <span class="ruby-identifier">req</span>.<span class="ruby-constant">POST</span>[<span class="ruby-constant">METHOD_OVERRIDE_PARAM_KEY</span>] <span class="ruby-operator">||</span>
16: <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTP_METHOD_OVERRIDE_HEADER</span>]
17: <span class="ruby-identifier">method</span> = <span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>
18: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">HTTP_METHODS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method</span>)
19: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.methodoverride.original_method&quot;</span>] = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
20: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>] = <span class="ruby-identifier">method</span>
21: <span class="ruby-keyword kw">end</span>
22: <span class="ruby-keyword kw">end</span>
23:
24: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
25: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,375 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::MockRequest</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::MockRequest</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/mock_rb.html">
lib/rack/mock.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="MockRequest.html">Rack::MockRequest</a> helps testing your <a
href="../Rack.html">Rack</a> application without actually using HTTP.
</p>
<p>
After performing a <a href="MockRequest.html#M000119">request</a> on a URL
with get/post/put/delete, it returns a <a
href="MockResponse.html">MockResponse</a> with useful helper methods for
effective testing.
</p>
<p>
You can pass a hash with additional configuration to the
get/post/put/delete.
</p>
<table>
<tr><td valign="top"><tt>:input</tt>:</td><td>A String or IO-like to be used as rack.input.
</td></tr>
<tr><td valign="top"><tt>:fatal</tt>:</td><td>Raise a <a href="MockRequest/FatalWarning.html">FatalWarning</a> if the app
writes to rack.errors.
</td></tr>
<tr><td valign="top"><tt>:lint</tt>:</td><td>If true, wrap the application in a <a href="Lint.html">Rack::Lint</a>.
</td></tr>
</table>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000118">delete</a>&nbsp;&nbsp;
<a href="#M000120">env_for</a>&nbsp;&nbsp;
<a href="#M000115">get</a>&nbsp;&nbsp;
<a href="#M000114">new</a>&nbsp;&nbsp;
<a href="#M000116">post</a>&nbsp;&nbsp;
<a href="#M000117">put</a>&nbsp;&nbsp;
<a href="#M000119">request</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Class <a href="MockRequest/FatalWarner.html" class="link">Rack::MockRequest::FatalWarner</a><br />
Class <a href="MockRequest/FatalWarning.html" class="link">Rack::MockRequest::FatalWarning</a><br />
</div>
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">DEFAULT_ENV</td>
<td>=</td>
<td class="context-item-value">{ &quot;rack.version&quot; =&gt; [0,1], &quot;rack.input&quot; =&gt; StringIO.new, &quot;rack.errors&quot; =&gt; StringIO.new, &quot;rack.multithread&quot; =&gt; true, &quot;rack.multiprocess&quot; =&gt; true, &quot;rack.run_once&quot; =&gt; false, }</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000120" class="method-detail">
<a name="M000120"></a>
<div class="method-heading">
<a href="#M000120" class="method-signature">
<span class="method-name">env_for</span><span class="method-args">(uri=&quot;&quot;, opts={})</span>
</a>
</div>
<div class="method-description">
<p>
Return the <a href="../Rack.html">Rack</a> environment used for a <a
href="MockRequest.html#M000119">request</a> to <tt>uri</tt>.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000120-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000120-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 74</span>
74: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">env_for</span>(<span class="ruby-identifier">uri</span>=<span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-identifier">opts</span>={})
75: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-identifier">uri</span>)
76: <span class="ruby-identifier">env</span> = <span class="ruby-constant">DEFAULT_ENV</span>.<span class="ruby-identifier">dup</span>
77:
78: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:method</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;GET&quot;</span>
79: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_NAME&quot;</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;example.org&quot;</span>
80: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SERVER_PORT&quot;</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span> <span class="ruby-value">? </span><span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;80&quot;</span>
81: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_s</span>
82: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>] = (<span class="ruby-operator">!</span><span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>
83: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.url_scheme&quot;</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;http&quot;</span>
84:
85: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:script_name</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>
86:
87: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:fatal</span>]
88: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>] = <span class="ruby-constant">FatalWarner</span>.<span class="ruby-identifier">new</span>
89: <span class="ruby-keyword kw">else</span>
90: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>] = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
91: <span class="ruby-keyword kw">end</span>
92:
93: <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:input</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
94: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:input</span>]
95: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.input&quot;</span>] = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:input</span>])
96: <span class="ruby-keyword kw">else</span>
97: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.input&quot;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:input</span>]
98: <span class="ruby-keyword kw">end</span>
99:
100: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">field</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
101: <span class="ruby-identifier">env</span>[<span class="ruby-identifier">field</span>] = <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">field</span>
102: }
103:
104: <span class="ruby-identifier">env</span>
105: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000114" class="method-detail">
<a name="M000114"></a>
<div class="method-heading">
<a href="#M000114" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000114-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000114-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 51</span>
51: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
52: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
53: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000118" class="method-detail">
<a name="M000118"></a>
<div class="method-heading">
<a href="#M000118" class="method-signature">
<span class="method-name">delete</span><span class="method-args">(uri, opts={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000118-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000118-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 58</span>
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-value str">&quot;DELETE&quot;</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000115" class="method-detail">
<a name="M000115"></a>
<div class="method-heading">
<a href="#M000115" class="method-signature">
<span class="method-name">get</span><span class="method-args">(uri, opts={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000115-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000115-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 55</span>
55: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-value str">&quot;GET&quot;</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000116" class="method-detail">
<a name="M000116"></a>
<div class="method-heading">
<a href="#M000116" class="method-signature">
<span class="method-name">post</span><span class="method-args">(uri, opts={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000116-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000116-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 56</span>
56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-value str">&quot;POST&quot;</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000117" class="method-detail">
<a name="M000117"></a>
<div class="method-heading">
<a href="#M000117" class="method-signature">
<span class="method-name">put</span><span class="method-args">(uri, opts={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000117-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000117-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 57</span>
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-value str">&quot;PUT&quot;</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000119" class="method-detail">
<a name="M000119"></a>
<div class="method-heading">
<a href="#M000119" class="method-signature">
<span class="method-name">request</span><span class="method-args">(method=&quot;GET&quot;, uri=&quot;&quot;, opts={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000119-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000119-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 60</span>
60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>(<span class="ruby-identifier">method</span>=<span class="ruby-value str">&quot;GET&quot;</span>, <span class="ruby-identifier">uri</span>=<span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-identifier">opts</span>={})
61: <span class="ruby-identifier">env</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">env_for</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:method</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">method</span>))
62:
63: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:lint</span>]
64: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@app</span>)
65: <span class="ruby-keyword kw">else</span>
66: <span class="ruby-identifier">app</span> = <span class="ruby-ivar">@app</span>
67: <span class="ruby-keyword kw">end</span>
68:
69: <span class="ruby-identifier">errors</span> = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>]
70: <span class="ruby-constant">MockResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>) <span class="ruby-operator">+</span> [<span class="ruby-identifier">errors</span>]))
71: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::MockRequest::FatalWarner</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::MockRequest::FatalWarner</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/mock_rb.html">
lib/rack/mock.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000123">flush</a>&nbsp;&nbsp;
<a href="#M000121">puts</a>&nbsp;&nbsp;
<a href="#M000124">string</a>&nbsp;&nbsp;
<a href="#M000122">write</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000123" class="method-detail">
<a name="M000123"></a>
<div class="method-heading">
<a href="#M000123" class="method-signature">
<span class="method-name">flush</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000123-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000123-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 34</span>
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">flush</span>
35: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000121" class="method-detail">
<a name="M000121"></a>
<div class="method-heading">
<a href="#M000121" class="method-signature">
<span class="method-name">puts</span><span class="method-args">(warning)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000121-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000121-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 26</span>
26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">puts</span>(<span class="ruby-identifier">warning</span>)
27: <span class="ruby-identifier">raise</span> <span class="ruby-constant">FatalWarning</span>, <span class="ruby-identifier">warning</span>
28: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000124" class="method-detail">
<a name="M000124"></a>
<div class="method-heading">
<a href="#M000124" class="method-signature">
<span class="method-name">string</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000124-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000124-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 37</span>
37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">string</span>
38: <span class="ruby-value str">&quot;&quot;</span>
39: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000122" class="method-detail">
<a name="M000122"></a>
<div class="method-heading">
<a href="#M000122" class="method-signature">
<span class="method-name">write</span><span class="method-args">(warning)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000122-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000122-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 30</span>
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">warning</span>)
31: <span class="ruby-identifier">raise</span> <span class="ruby-constant">FatalWarning</span>, <span class="ruby-identifier">warning</span>
32: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::MockRequest::FatalWarning</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::MockRequest::FatalWarning</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/mock_rb.html">
lib/rack/mock.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
RuntimeError
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,298 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::MockResponse</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::MockResponse</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/mock_rb.html">
lib/rack/mock.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="MockResponse.html">Rack::MockResponse</a> provides useful helpers
for testing your apps. Usually, you don&#8216;t create the <a
href="MockResponse.html">MockResponse</a> on your own, but use <a
href="MockRequest.html">MockRequest</a>.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000070">=~</a>&nbsp;&nbsp;
<a href="#M000069">[]</a>&nbsp;&nbsp;
<a href="#M000071">match</a>&nbsp;&nbsp;
<a href="#M000068">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="includes">
<h3 class="section-bar">Included Modules</h3>
<div id="includes-list">
<span class="include-name"><a href="Response/Helpers.html">Response::Helpers</a></span>
</div>
</div>
<div id="section">
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">body</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc">
Body
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">errors</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc">
Errors
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">headers</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc">
Headers
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">original_headers</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc">
Headers
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">status</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc">
Status
</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000068" class="method-detail">
<a name="M000068"></a>
<div class="method-heading">
<a href="#M000068" class="method-signature">
<span class="method-name">new</span><span class="method-args">(status, headers, body, errors=StringIO.new(&quot;&quot;))</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000068-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 113</span>
113: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">errors</span>=<span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;&quot;</span>))
114: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>
115:
116: <span class="ruby-ivar">@original_headers</span> = <span class="ruby-identifier">headers</span>
117: <span class="ruby-ivar">@headers</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>
118: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">field</span>, <span class="ruby-identifier">values</span><span class="ruby-operator">|</span>
119: <span class="ruby-identifier">values</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
120: <span class="ruby-ivar">@headers</span>[<span class="ruby-identifier">field</span>] = <span class="ruby-identifier">value</span>
121: }
122: <span class="ruby-ivar">@headers</span>[<span class="ruby-identifier">field</span>] = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">values</span>.<span class="ruby-identifier">empty?</span>
123: }
124:
125: <span class="ruby-ivar">@body</span> = <span class="ruby-value str">&quot;&quot;</span>
126: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">part</span> }
127:
128: <span class="ruby-ivar">@errors</span> = <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">string</span>
129: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000070" class="method-detail">
<a name="M000070"></a>
<div class="method-heading">
<a href="#M000070" class="method-signature">
<span class="method-name">=~</span><span class="method-args">(other)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000070-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 145</span>
145: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">=~</span>(<span class="ruby-identifier">other</span>)
146: <span class="ruby-ivar">@body</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">other</span>
147: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000069" class="method-detail">
<a name="M000069"></a>
<div class="method-heading">
<a href="#M000069" class="method-signature">
<span class="method-name">[]</span><span class="method-args">(field)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000069-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 137</span>
137: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">field</span>)
138: <span class="ruby-identifier">headers</span>[<span class="ruby-identifier">field</span>]
139: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000071" class="method-detail">
<a name="M000071"></a>
<div class="method-heading">
<a href="#M000071" class="method-signature">
<span class="method-name">match</span><span class="method-args">(other)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000071-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/mock.rb, line 149</span>
149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">match</span>(<span class="ruby-identifier">other</span>)
150: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">match</span> <span class="ruby-identifier">other</span>
151: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Recursive</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Recursive</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/recursive_rb.html">
lib/rack/recursive.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Recursive.html">Rack::Recursive</a> allows applications called
down the chain to <a href="Recursive.html#M000149">include</a> data from
other applications (by using <tt><a
href="http://'rack.recursive.include'">rack</a>[&#8230;]</tt> or raise a <a
href="ForwardRequest.html">ForwardRequest</a> to redirect internally.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000148">call</a>&nbsp;&nbsp;
<a href="#M000149">include</a>&nbsp;&nbsp;
<a href="#M000147">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000147" class="method-detail">
<a name="M000147"></a>
<div class="method-heading">
<a href="#M000147" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000147-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000147-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/recursive.rb, line 33</span>
33: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
34: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
35: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000148" class="method-detail">
<a name="M000148"></a>
<div class="method-heading">
<a href="#M000148" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000148-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000148-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/recursive.rb, line 37</span>
37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
38: <span class="ruby-ivar">@script_name</span> = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span>]
39: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value str">'rack.recursive.include'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">method</span>(<span class="ruby-identifier">:include</span>)))
40: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ForwardRequest</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">req</span>
41: <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">req</span>.<span class="ruby-identifier">env</span>))
42: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000149" class="method-detail">
<a name="M000149"></a>
<div class="method-heading">
<a href="#M000149" class="method-signature">
<span class="method-name">include</span><span class="method-args">(env, path)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000149-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000149-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/recursive.rb, line 44</span>
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">path</span>)
45: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@script_name</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">path</span>[<span class="ruby-ivar">@script_name</span>.<span class="ruby-identifier">size</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?/</span> <span class="ruby-operator">||</span>
46: <span class="ruby-identifier">path</span>[<span class="ruby-ivar">@script_name</span>.<span class="ruby-identifier">size</span>].<span class="ruby-identifier">nil?</span>)
47: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;can only include below #{@script_name}, not #{path}&quot;</span>
48: <span class="ruby-keyword kw">end</span>
49:
50: <span class="ruby-identifier">env</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value str">&quot;PATH_INFO&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">path</span>, <span class="ruby-value str">&quot;SCRIPT_NAME&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@script_name</span>,
51: <span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;GET&quot;</span>,
52: <span class="ruby-value str">&quot;CONTENT_LENGTH&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;0&quot;</span>, <span class="ruby-value str">&quot;CONTENT_TYPE&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;&quot;</span>,
53: <span class="ruby-value str">&quot;rack.input&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;&quot;</span>))
54: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
55: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,249 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Reloader</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Reloader</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/reloader_rb.html">
lib/rack/reloader.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Reloader.html">Rack::Reloader</a> checks on every request, but at
most every <tt>secs</tt> seconds, if a file loaded changed, and reloads it,
logging to rack.errors.
</p>
<p>
It is recommended you use <a href="ShowExceptions.html">ShowExceptions</a>
to catch SyntaxErrors etc.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000133">call</a>&nbsp;&nbsp;
<a href="#M000132">new</a>&nbsp;&nbsp;
<a href="#M000134">reload!</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000132" class="method-detail">
<a name="M000132"></a>
<div class="method-heading">
<a href="#M000132" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app, secs=10)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000132-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000132-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/reloader.rb, line 11</span>
11: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">secs</span>=<span class="ruby-value">10</span>)
12: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
13: <span class="ruby-ivar">@secs</span> = <span class="ruby-identifier">secs</span> <span class="ruby-comment cmt"># reload every @secs seconds max</span>
14: <span class="ruby-ivar">@last</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
15: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000133" class="method-detail">
<a name="M000133"></a>
<div class="method-heading">
<a href="#M000133" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000133-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000133-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/reloader.rb, line 17</span>
17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
18: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@last</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@secs</span>
19: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">exclusive</span> {
20: <span class="ruby-identifier">reload!</span>(<span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>])
21: <span class="ruby-ivar">@last</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
22: }
23: <span class="ruby-keyword kw">end</span>
24:
25: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
26: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000134" class="method-detail">
<a name="M000134"></a>
<div class="method-heading">
<a href="#M000134" class="method-signature">
<span class="method-name">reload!</span><span class="method-args">(stderr=STDERR)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000134-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000134-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/reloader.rb, line 28</span>
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload!</span>(<span class="ruby-identifier">stderr</span>=<span class="ruby-constant">STDERR</span>)
29: <span class="ruby-identifier">need_reload</span> = <span class="ruby-identifier">$LOADED_FEATURES</span>.<span class="ruby-identifier">find_all</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">loaded</span><span class="ruby-operator">|</span>
30: <span class="ruby-keyword kw">begin</span>
31: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">loaded</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A[.\/]/</span> <span class="ruby-comment cmt"># absolute filename or 1.9</span>
32: <span class="ruby-identifier">abs</span> = <span class="ruby-identifier">loaded</span>
33: <span class="ruby-keyword kw">else</span>
34: <span class="ruby-identifier">abs</span> = <span class="ruby-identifier">$LOAD_PATH</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">loaded</span>) }.
35: <span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">file</span> }
36: <span class="ruby-keyword kw">end</span>
37:
38: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">abs</span>
39: <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">abs</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@last</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@secs</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">false</span>
40: <span class="ruby-keyword kw">else</span>
41: <span class="ruby-keyword kw">false</span>
42: <span class="ruby-keyword kw">end</span>
43: <span class="ruby-keyword kw">end</span>
44: }
45:
46: <span class="ruby-identifier">need_reload</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
47: <span class="ruby-identifier">$LOADED_FEATURES</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">l</span>
48: }
49:
50: <span class="ruby-identifier">need_reload</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">to_load</span><span class="ruby-operator">|</span>
51: <span class="ruby-keyword kw">begin</span>
52: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">require</span> <span class="ruby-identifier">to_load</span>
53: <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{self.class}: reloaded `#{to_load}'&quot;</span>
54: <span class="ruby-keyword kw">end</span>
55: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>, <span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
56: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span> <span class="ruby-comment cmt"># Possibly ShowExceptions</span>
57: <span class="ruby-keyword kw">end</span>
58: }
59:
60: <span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">flush</span>
61: <span class="ruby-identifier">need_reload</span>
62: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,518 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Response</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Response</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/response_rb.html">
lib/rack/response.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Response.html">Rack::Response</a> provides a convenient interface
to create a <a href="../Rack.html">Rack</a> response.
</p>
<p>
It allows setting of headers and cookies, and provides useful defaults (a
OK response containing HTML).
</p>
<p>
You can use <a href="Response.html#M000096">Response#write</a> to
iteratively generate your response, but note that this is buffered by <a
href="Response.html">Rack::Response</a> until you call <tt><a
href="Response.html#M000093">finish</a></tt>. <tt><a
href="Response.html#M000093">finish</a></tt> however can take a block
inside which calls to <tt><a href="Response.html#M000096">write</a></tt>
are syncronous with the <a href="../Rack.html">Rack</a> response.
</p>
<p>
Your application&#8216;s <tt>call</tt> should end returning <a
href="Response.html#M000093">Response#finish</a>.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000089">[]</a>&nbsp;&nbsp;
<a href="#M000090">[]=</a>&nbsp;&nbsp;
<a href="#M000097">close</a>&nbsp;&nbsp;
<a href="#M000092">delete_cookie</a>&nbsp;&nbsp;
<a href="#M000095">each</a>&nbsp;&nbsp;
<a href="#M000098">empty?</a>&nbsp;&nbsp;
<a href="#M000093">finish</a>&nbsp;&nbsp;
<a href="#M000088">new</a>&nbsp;&nbsp;
<a href="#M000091">set_cookie</a>&nbsp;&nbsp;
<a href="#M000094">to_a</a>&nbsp;&nbsp;
<a href="#M000096">write</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="includes">
<h3 class="section-bar">Included Modules</h3>
<div id="includes-list">
<span class="include-name"><a href="Response/Helpers.html">Helpers</a></span>
</div>
</div>
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Module <a href="Response/Helpers.html" class="link">Rack::Response::Helpers</a><br />
</div>
<div id="aliases-list">
<h3 class="section-bar">External Aliases</h3>
<div class="name-list">
<table summary="aliases">
<tr class="top-aligned-row context-row">
<td class="context-item-name">header</td>
<td>-&gt;</td>
<td class="context-item-value">headers</td>
</tr>
</table>
</div>
</div>
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">body</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">header</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">status</td>
<td class="context-item-value">&nbsp;[RW]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000088" class="method-detail">
<a name="M000088"></a>
<div class="method-heading">
<a href="#M000088" class="method-signature">
<span class="method-name">new</span><span class="method-args">(body=[], status=200, header={}) {|self if block_given?| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000088-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 19</span>
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">body</span>=[], <span class="ruby-identifier">status</span>=<span class="ruby-value">200</span>, <span class="ruby-identifier">header</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
20: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>
21: <span class="ruby-ivar">@header</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>({<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/html&quot;</span>}.
22: <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">header</span>))
23:
24: <span class="ruby-ivar">@writer</span> = <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">x</span> }
25: <span class="ruby-ivar">@block</span> = <span class="ruby-keyword kw">nil</span>
26: <span class="ruby-ivar">@length</span> = <span class="ruby-value">0</span>
27:
28: <span class="ruby-ivar">@body</span> = []
29:
30: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:to_str</span>
31: <span class="ruby-identifier">write</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_str</span>
32: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:each</span>)
33: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
34: <span class="ruby-identifier">write</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">to_s</span>
35: }
36: <span class="ruby-keyword kw">else</span>
37: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-value str">&quot;stringable or iterable required&quot;</span>
38: <span class="ruby-keyword kw">end</span>
39:
40: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
41: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000089" class="method-detail">
<a name="M000089"></a>
<div class="method-heading">
<a href="#M000089" class="method-signature">
<span class="method-name">[]</span><span class="method-args">(key)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000089-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 46</span>
46: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
47: <span class="ruby-identifier">header</span>[<span class="ruby-identifier">key</span>]
48: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000090" class="method-detail">
<a name="M000090"></a>
<div class="method-heading">
<a href="#M000090" class="method-signature">
<span class="method-name">[]=</span><span class="method-args">(key, value)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000090-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 50</span>
50: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
51: <span class="ruby-identifier">header</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
52: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000097" class="method-detail">
<a name="M000097"></a>
<div class="method-heading">
<a href="#M000097" class="method-signature">
<span class="method-name">close</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000097-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000097-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 122</span>
122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
123: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:close</span>)
124: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000092" class="method-detail">
<a name="M000092"></a>
<div class="method-heading">
<a href="#M000092" class="method-signature">
<span class="method-name">delete_cookie</span><span class="method-args">(key, value={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000092-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 81</span>
81: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_cookie</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>={})
82: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>]
83: <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>] = [<span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>]].<span class="ruby-identifier">compact</span>
84: <span class="ruby-keyword kw">end</span>
85:
86: <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>].<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">cookie</span><span class="ruby-operator">|</span>
87: <span class="ruby-identifier">cookie</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/\A#{Utils.escape(key)}=/</span>
88: }
89:
90: <span class="ruby-identifier">set_cookie</span>(<span class="ruby-identifier">key</span>,
91: {<span class="ruby-identifier">:value</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">''</span>, <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">:domain</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>,
92: <span class="ruby-identifier">:expires</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-value">0</span>) }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">value</span>))
93: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000095" class="method-detail">
<a name="M000095"></a>
<div class="method-heading">
<a href="#M000095" class="method-signature">
<span class="method-name">each</span><span class="method-args">(&amp;callback)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000095-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000095-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 109</span>
109: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">callback</span>)
110: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">callback</span>)
111: <span class="ruby-ivar">@writer</span> = <span class="ruby-identifier">callback</span>
112: <span class="ruby-ivar">@block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@block</span>
113: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000098" class="method-detail">
<a name="M000098"></a>
<div class="method-heading">
<a href="#M000098" class="method-signature">
<span class="method-name">empty?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000098-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000098-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 126</span>
126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty?</span>
127: <span class="ruby-ivar">@block</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">empty?</span>
128: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000093" class="method-detail">
<a name="M000093"></a>
<div class="method-heading">
<a href="#M000093" class="method-signature">
<span class="method-name">finish</span><span class="method-args">(&amp;block)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000093-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000093-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 96</span>
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">finish</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
97: <span class="ruby-ivar">@block</span> = <span class="ruby-identifier">block</span>
98:
99: <span class="ruby-keyword kw">if</span> [<span class="ruby-value">204</span>, <span class="ruby-value">304</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>)
100: <span class="ruby-identifier">header</span>.<span class="ruby-identifier">delete</span> <span class="ruby-value str">&quot;Content-Type&quot;</span>
101: [<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">header</span>.<span class="ruby-identifier">to_hash</span>, []]
102: <span class="ruby-keyword kw">else</span>
103: <span class="ruby-identifier">header</span>[<span class="ruby-value str">&quot;Content-Length&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-ivar">@length</span>.<span class="ruby-identifier">to_s</span>
104: [<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>, <span class="ruby-identifier">header</span>.<span class="ruby-identifier">to_hash</span>, <span class="ruby-keyword kw">self</span>]
105: <span class="ruby-keyword kw">end</span>
106: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000091" class="method-detail">
<a name="M000091"></a>
<div class="method-heading">
<a href="#M000091" class="method-signature">
<span class="method-name">set_cookie</span><span class="method-args">(key, value)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000091-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 54</span>
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_cookie</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
55: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">value</span>
56: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
57: <span class="ruby-identifier">domain</span> = <span class="ruby-value str">&quot;; domain=&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:domain</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:domain</span>]
58: <span class="ruby-identifier">path</span> = <span class="ruby-value str">&quot;; path=&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:path</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:path</span>]
59: <span class="ruby-comment cmt"># According to RFC 2109, we need dashes here.</span>
60: <span class="ruby-comment cmt"># N.B.: cgi.rb uses spaces...</span>
61: <span class="ruby-identifier">expires</span> = <span class="ruby-value str">&quot;; expires=&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:expires</span>].<span class="ruby-identifier">clone</span>.<span class="ruby-identifier">gmtime</span>.
62: <span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%a, %d-%b-%Y %H:%M:%S GMT&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:expires</span>]
63: <span class="ruby-identifier">secure</span> = <span class="ruby-value str">&quot;; secure&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:secure</span>]
64: <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>[<span class="ruby-identifier">:value</span>]
65: <span class="ruby-keyword kw">end</span>
66: <span class="ruby-identifier">value</span> = [<span class="ruby-identifier">value</span>] <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">value</span>
67: <span class="ruby-identifier">cookie</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">key</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;=&quot;</span> <span class="ruby-operator">+</span>
68: <span class="ruby-identifier">value</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">escape</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;&amp;&quot;</span>) <span class="ruby-operator">+</span>
69: <span class="ruby-node">&quot;#{domain}#{path}#{expires}#{secure}&quot;</span>
70:
71: <span class="ruby-keyword kw">case</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>]
72: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>
73: <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">cookie</span>
74: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>
75: <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>] = [<span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>], <span class="ruby-identifier">cookie</span>]
76: <span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">nil</span>
77: <span class="ruby-keyword kw">self</span>[<span class="ruby-value str">&quot;Set-Cookie&quot;</span>] = <span class="ruby-identifier">cookie</span>
78: <span class="ruby-keyword kw">end</span>
79: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000094" class="method-detail">
<a name="M000094"></a>
<div class="method-heading">
<span class="method-name">to_a</span><span class="method-args">(&amp;block)</span>
</div>
<div class="method-description">
<p>
Alias for <a href="Response.html#M000093">finish</a>
</p>
</div>
</div>
<div id="method-M000096" class="method-detail">
<a name="M000096"></a>
<div class="method-heading">
<a href="#M000096" class="method-signature">
<span class="method-name">write</span><span class="method-args">(str)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000096-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000096-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 115</span>
115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">str</span>)
116: <span class="ruby-identifier">s</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">to_s</span>
117: <span class="ruby-ivar">@length</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">size</span>
118: <span class="ruby-ivar">@writer</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">s</span>
119: <span class="ruby-identifier">str</span>
120: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,479 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack::Response::Helpers</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack::Response::Helpers</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/response_rb.html">
lib/rack/response.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000103">client_error?</a>&nbsp;&nbsp;
<a href="#M000112">content_length</a>&nbsp;&nbsp;
<a href="#M000111">content_type</a>&nbsp;&nbsp;
<a href="#M000109">empty?</a>&nbsp;&nbsp;
<a href="#M000106">forbidden?</a>&nbsp;&nbsp;
<a href="#M000110">include?</a>&nbsp;&nbsp;
<a href="#M000100">informational?</a>&nbsp;&nbsp;
<a href="#M000099">invalid?</a>&nbsp;&nbsp;
<a href="#M000113">location</a>&nbsp;&nbsp;
<a href="#M000107">not_found?</a>&nbsp;&nbsp;
<a href="#M000105">ok?</a>&nbsp;&nbsp;
<a href="#M000108">redirect?</a>&nbsp;&nbsp;
<a href="#M000102">redirection?</a>&nbsp;&nbsp;
<a href="#M000104">server_error?</a>&nbsp;&nbsp;
<a href="#M000101">successful?</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">headers</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc">
Headers
</td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">original_headers</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc">
Headers
</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000103" class="method-detail">
<a name="M000103"></a>
<div class="method-heading">
<a href="#M000103" class="method-signature">
<span class="method-name">client_error?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000103-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000103-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 138</span>
138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">client_error?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">400</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">500</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000112" class="method-detail">
<a name="M000112"></a>
<div class="method-heading">
<a href="#M000112" class="method-signature">
<span class="method-name">content_length</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000112-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000112-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 159</span>
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_length</span>
160: <span class="ruby-identifier">cl</span> = <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Content-Length&quot;</span>]
161: <span class="ruby-identifier">cl</span> <span class="ruby-value">? </span><span class="ruby-identifier">cl</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">cl</span>
162: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000111" class="method-detail">
<a name="M000111"></a>
<div class="method-heading">
<a href="#M000111" class="method-signature">
<span class="method-name">content_type</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000111-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000111-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 155</span>
155: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_type</span>
156: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Content-Type&quot;</span>]
157: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000109" class="method-detail">
<a name="M000109"></a>
<div class="method-heading">
<a href="#M000109" class="method-signature">
<span class="method-name">empty?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000109-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000109-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 146</span>
146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty?</span>; [<span class="ruby-value">201</span>, <span class="ruby-value">204</span>, <span class="ruby-value">304</span>].<span class="ruby-identifier">include?</span> <span class="ruby-ivar">@status</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000106" class="method-detail">
<a name="M000106"></a>
<div class="method-heading">
<a href="#M000106" class="method-signature">
<span class="method-name">forbidden?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000106-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000106-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 142</span>
142: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">forbidden?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">==</span> <span class="ruby-value">403</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000110" class="method-detail">
<a name="M000110"></a>
<div class="method-heading">
<a href="#M000110" class="method-signature">
<span class="method-name">include?</span><span class="method-args">(header)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000110-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000110-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 151</span>
151: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">include?</span>(<span class="ruby-identifier">header</span>)
152: <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-identifier">headers</span>[<span class="ruby-identifier">header</span>]
153: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000100" class="method-detail">
<a name="M000100"></a>
<div class="method-heading">
<a href="#M000100" class="method-signature">
<span class="method-name">informational?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000100-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000100-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 135</span>
135: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">informational?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">100</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">200</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000099" class="method-detail">
<a name="M000099"></a>
<div class="method-heading">
<a href="#M000099" class="method-signature">
<span class="method-name">invalid?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000099-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000099-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 133</span>
133: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">invalid?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">100</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">600</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000113" class="method-detail">
<a name="M000113"></a>
<div class="method-heading">
<a href="#M000113" class="method-signature">
<span class="method-name">location</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000113-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000113-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 164</span>
164: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">location</span>
165: <span class="ruby-identifier">headers</span>[<span class="ruby-value str">&quot;Location&quot;</span>]
166: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000107" class="method-detail">
<a name="M000107"></a>
<div class="method-heading">
<a href="#M000107" class="method-signature">
<span class="method-name">not_found?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000107-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000107-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 143</span>
143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">not_found?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">==</span> <span class="ruby-value">404</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000105" class="method-detail">
<a name="M000105"></a>
<div class="method-heading">
<a href="#M000105" class="method-signature">
<span class="method-name">ok?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000105-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000105-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 141</span>
141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ok?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000108" class="method-detail">
<a name="M000108"></a>
<div class="method-heading">
<a href="#M000108" class="method-signature">
<span class="method-name">redirect?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000108-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000108-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 145</span>
145: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect?</span>; [<span class="ruby-value">301</span>, <span class="ruby-value">302</span>, <span class="ruby-value">303</span>, <span class="ruby-value">307</span>].<span class="ruby-identifier">include?</span> <span class="ruby-ivar">@status</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000102" class="method-detail">
<a name="M000102"></a>
<div class="method-heading">
<a href="#M000102" class="method-signature">
<span class="method-name">redirection?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000102-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000102-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 137</span>
137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirection?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">300</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">400</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000104" class="method-detail">
<a name="M000104"></a>
<div class="method-heading">
<a href="#M000104" class="method-signature">
<span class="method-name">server_error?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000104-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000104-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 139</span>
139: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">server_error?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">500</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">600</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000101" class="method-detail">
<a name="M000101"></a>
<div class="method-heading">
<a href="#M000101" class="method-signature">
<span class="method-name">successful?</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000101-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000101-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/response.rb, line 136</span>
136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">successful?</span>; <span class="ruby-ivar">@status</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">200</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@status</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">300</span>; <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Module: Rack::Session</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Module</strong></td>
<td class="class-name-in-header">Rack::Session</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack_rb.html">
lib/rack.rb
</a>
<br />
<a href="../../files/lib/rack/session/cookie_rb.html">
lib/rack/session/cookie.rb
</a>
<br />
<a href="../../files/lib/rack/session/memcache_rb.html">
lib/rack/session/memcache.rb
</a>
<br />
<a href="../../files/lib/rack/session/pool_rb.html">
lib/rack/session/pool.rb
</a>
<br />
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="class-list">
<h3 class="section-bar">Classes and Modules</h3>
Class <a href="Session/Cookie.html" class="link">Rack::Session::Cookie</a><br />
Class <a href="Session/Memcache.html" class="link">Rack::Session::Memcache</a><br />
Class <a href="Session/Pool.html" class="link">Rack::Session::Pool</a><br />
</div>
<!-- if method_list -->
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Session::Cookie</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Session::Cookie</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/session/cookie_rb.html">
lib/rack/session/cookie.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Cookie.html">Rack::Session::Cookie</a> provides simple cookie
based session management. The session is a Ruby Hash stored as base64
encoded marshalled data set to :key (default: rack.session). When the
secret key is set, cookie data is checked for data integrity.
</p>
<p>
Example:
</p>
<pre>
use Rack::Session::Cookie, :key =&gt; 'rack.session',
:domain =&gt; 'foo.com',
:path =&gt; '/',
:expire_after =&gt; 2592000,
:secret =&gt; 'change_me'
All parameters are optional.
</pre>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000009">call</a>&nbsp;&nbsp;
<a href="#M000008">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000008" class="method-detail">
<a name="M000008"></a>
<div class="method-heading">
<a href="#M000008" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app, options={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000008-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/session/cookie.rb, line 24</span>
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
25: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
26: <span class="ruby-ivar">@key</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:key</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;rack.session&quot;</span>
27: <span class="ruby-ivar">@secret</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:secret</span>]
28: <span class="ruby-ivar">@default_options</span> = {<span class="ruby-identifier">:domain</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>,
29: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;/&quot;</span>,
30: <span class="ruby-identifier">:expire_after</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>}.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>)
31: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000009" class="method-detail">
<a name="M000009"></a>
<div class="method-heading">
<a href="#M000009" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000009-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/session/cookie.rb, line 33</span>
33: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
34: <span class="ruby-identifier">load_session</span>(<span class="ruby-identifier">env</span>)
35: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
36: <span class="ruby-identifier">commit_session</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>)
37: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Session::Memcache</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Session::Memcache</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/session/memcache_rb.html">
lib/rack/session/memcache.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Abstract::ID
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Memcache.html">Rack::Session::Memcache</a> provides simple cookie
based session management. <a href="../Session.html">Session</a> data is
stored in memcached. The corresponding session key is maintained in the
cookie. You may treat <a href="Memcache.html">Session::Memcache</a> as you
would <a href="Pool.html">Session::Pool</a> with the following caveats.
</p>
<ul>
<li>Setting :expire_after to 0 would note to the <a
href="Memcache.html">Memcache</a> server to hang onto the session data
until it would drop it according to it&#8216;s own specifications. However,
the cookie sent to the client would expire immediately.
</li>
</ul>
<p>
Note that memcache does drop data before it may be listed to expire. For a
full description of behaviour, please see memcache&#8216;s documentation.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000007">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">DEFAULT_OPTIONS</td>
<td>=</td>
<td class="context-item-value">Abstract::ID::DEFAULT_OPTIONS.merge({ :namespace =&gt; 'rack:session', :memcache_server =&gt; 'localhost:11211'</td>
</tr>
</table>
</div>
</div>
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">mutex</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">pool</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000007" class="method-detail">
<a name="M000007"></a>
<div class="method-heading">
<a href="#M000007" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app, options={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000007-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/session/memcache.rb, line 29</span>
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
30: <span class="ruby-keyword kw">super</span>
31: <span class="ruby-ivar">@pool</span> = <span class="ruby-constant">MemCache</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@default_options</span>[<span class="ruby-identifier">:memcache_server</span>], <span class="ruby-ivar">@default_options</span>
32: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@pool</span>.<span class="ruby-identifier">servers</span>.<span class="ruby-identifier">any?</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span><span class="ruby-identifier">s</span>.<span class="ruby-identifier">alive?</span>}
33: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{self} unable to find server during initialization.&quot;</span>
34: <span class="ruby-keyword kw">end</span>
35: <span class="ruby-ivar">@mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
36: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,201 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::Session::Pool</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::Session::Pool</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../../files/lib/rack/session/pool_rb.html">
lib/rack/session/pool.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Abstract::ID
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="Pool.html">Rack::Session::Pool</a> provides simple cookie based
session management. <a href="../Session.html">Session</a> data is stored in
a hash held by @pool. In the context of a multithreaded environment,
sessions being committed to the pool is done in a merging manner.
</p>
<p>
Example:
</p>
<pre>
myapp = MyRackApp.new
sessioned = Rack::Session::Pool.new(myapp,
:key =&gt; 'rack.session',
:domain =&gt; 'foo.com',
:path =&gt; '/',
:expire_after =&gt; 2592000
)
Rack::Handler::WEBrick.run sessioned
</pre>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000010">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">DEFAULT_OPTIONS</td>
<td>=</td>
<td class="context-item-value">Abstract::ID::DEFAULT_OPTIONS.dup</td>
</tr>
</table>
</div>
</div>
<div id="attribute-list">
<h3 class="section-bar">Attributes</h3>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">mutex</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">pool</td>
<td class="context-item-value">&nbsp;[R]&nbsp;</td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000010" class="method-detail">
<a name="M000010"></a>
<div class="method-heading">
<a href="#M000010" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app, options={})</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000010-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/session/pool.rb, line 30</span>
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span>={})
31: <span class="ruby-keyword kw">super</span>
32: <span class="ruby-ivar">@pool</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
33: <span class="ruby-ivar">@mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
34: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::ShowExceptions</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::ShowExceptions</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/showexceptions_rb.html">
lib/rack/showexceptions.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="ShowExceptions.html">Rack::ShowExceptions</a> catches all
exceptions raised from the app it wraps. It shows a useful backtrace with
the sourcefile and clickable context, the whole <a
href="../Rack.html">Rack</a> environment and the request data.
</p>
<p>
Be careful when you use this on public-facing sites as it could reveal
information helpful to attackers.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000086">call</a>&nbsp;&nbsp;
<a href="#M000085">new</a>&nbsp;&nbsp;
<a href="#M000087">pretty</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<div id="constants-list">
<h3 class="section-bar">Constants</h3>
<div class="name-list">
<table summary="Constants">
<tr class="top-aligned-row context-row">
<td class="context-item-name">CONTEXT</td>
<td>=</td>
<td class="context-item-value">7</td>
</tr>
</table>
</div>
</div>
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000085" class="method-detail">
<a name="M000085"></a>
<div class="method-heading">
<a href="#M000085" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000085-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000085-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/showexceptions.rb, line 17</span>
17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
18: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
19: <span class="ruby-ivar">@template</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">TEMPLATE</span>)
20: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000086" class="method-detail">
<a name="M000086"></a>
<div class="method-heading">
<a href="#M000086" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000086-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/showexceptions.rb, line 22</span>
22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
23: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
24: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">StandardError</span>, <span class="ruby-constant">LoadError</span>, <span class="ruby-constant">SyntaxError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
25: <span class="ruby-identifier">backtrace</span> = <span class="ruby-identifier">pretty</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">e</span>)
26: [<span class="ruby-value">500</span>,
27: {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/html&quot;</span>,
28: <span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>},
29: <span class="ruby-identifier">backtrace</span>]
30: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000087" class="method-detail">
<a name="M000087"></a>
<div class="method-heading">
<a href="#M000087" class="method-signature">
<span class="method-name">pretty</span><span class="method-args">(env, exception)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000087-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/showexceptions.rb, line 32</span>
32: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pretty</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">exception</span>)
33: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
34: <span class="ruby-identifier">path</span> = (<span class="ruby-identifier">req</span>.<span class="ruby-identifier">script_name</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">path_info</span>).<span class="ruby-identifier">squeeze</span>(<span class="ruby-value str">&quot;/&quot;</span>)
35:
36: <span class="ruby-identifier">frames</span> = <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
37: <span class="ruby-identifier">frame</span> = <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>
38: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(.*?):(\d+)(:in `(.*)')?/</span>
39: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">$1</span>
40: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">lineno</span> = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">to_i</span>
41: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">function</span> = <span class="ruby-identifier">$4</span>
42:
43: <span class="ruby-keyword kw">begin</span>
44: <span class="ruby-identifier">lineno</span> = <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">lineno</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>
45: <span class="ruby-identifier">lines</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">frame</span>.<span class="ruby-identifier">filename</span>)
46: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">pre_context_lineno</span> = [<span class="ruby-identifier">lineno</span><span class="ruby-operator">-</span><span class="ruby-constant">CONTEXT</span>, <span class="ruby-value">0</span>].<span class="ruby-identifier">max</span>
47: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">pre_context</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">frame</span>.<span class="ruby-identifier">pre_context_lineno</span><span class="ruby-operator">...</span><span class="ruby-identifier">lineno</span>]
48: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">context_line</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">lineno</span>].<span class="ruby-identifier">chomp</span>
49: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">post_context_lineno</span> = [<span class="ruby-identifier">lineno</span><span class="ruby-operator">+</span><span class="ruby-constant">CONTEXT</span>, <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">size</span>].<span class="ruby-identifier">min</span>
50: <span class="ruby-identifier">frame</span>.<span class="ruby-identifier">post_context</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">lineno</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">frame</span>.<span class="ruby-identifier">post_context_lineno</span>]
51: <span class="ruby-keyword kw">rescue</span>
52: <span class="ruby-keyword kw">end</span>
53:
54: <span class="ruby-identifier">frame</span>
55: <span class="ruby-keyword kw">else</span>
56: <span class="ruby-keyword kw">nil</span>
57: <span class="ruby-keyword kw">end</span>
58: }.<span class="ruby-identifier">compact</span>
59:
60: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{exception.class}: #{exception.message}&quot;</span>
61: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">puts</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-value str">&quot;\t&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">l</span> }
62: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">flush</span>
63:
64: [<span class="ruby-ivar">@template</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)]
65: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

View file

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::ShowStatus</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::ShowStatus</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/showstatus_rb.html">
lib/rack/showstatus.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="ShowStatus.html">Rack::ShowStatus</a> catches all empty responses
the app it wraps and replaces them with a site explaining the error.
</p>
<p>
Additional details can be put into <tt>rack.showstatus.detail</tt> and will
be shown as HTML. If such details exist, the error page is always rendered,
even if the reply was not empty.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000084">call</a>&nbsp;&nbsp;
<a href="#M000083">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000083" class="method-detail">
<a name="M000083"></a>
<div class="method-heading">
<a href="#M000083" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000083-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000083-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/showstatus.rb, line 14</span>
14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
15: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
16: <span class="ruby-ivar">@template</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">TEMPLATE</span>)
17: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000084" class="method-detail">
<a name="M000084"></a>
<div class="method-heading">
<a href="#M000084" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000084-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000084-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/showstatus.rb, line 19</span>
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
20: <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
21: <span class="ruby-identifier">headers</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderHash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">headers</span>)
22: <span class="ruby-identifier">empty</span> = <span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Length'</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>
23:
24: <span class="ruby-comment cmt"># client or server error, or explicit message</span>
25: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">400</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">empty</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.showstatus.detail&quot;</span>]
26: <span class="ruby-identifier">req</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
27: <span class="ruby-identifier">message</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_s</span>
28: <span class="ruby-identifier">detail</span> = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.showstatus.detail&quot;</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">message</span>
29: <span class="ruby-identifier">body</span> = <span class="ruby-ivar">@template</span>.<span class="ruby-identifier">result</span>(<span class="ruby-identifier">binding</span>)
30: <span class="ruby-identifier">size</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:bytesize</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">size</span>
31: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;text/html&quot;</span>, <span class="ruby-value str">&quot;Content-Length&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>), [<span class="ruby-identifier">body</span>]]
32: <span class="ruby-keyword kw">else</span>
33: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>]
34: <span class="ruby-keyword kw">end</span>
35: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show more