Unvendor Rack

You'll need to rerun

   ruby bundle

as rack is now loaded as gem.
This commit is contained in:
Jacques Distler 2011-06-01 12:26:50 -05:00
parent 7290e90631
commit 7e5dbe5854
137 changed files with 10 additions and 12960 deletions

View file

@ -1,10 +1,11 @@
source "http://rubygems.org" source "http://rubygems.org"
gem "sqlite3-ruby", :require => "sqlite3" gem "sqlite3-ruby", :require => "sqlite3"
gem "itextomml", ">=1.4.5" gem "itextomml", ">=1.4.5"
gem "rack", ">=1.1.0"
gem "mongrel", ">=1.2.0.pre2" gem "mongrel", ">=1.2.0.pre2"
gem "rubyzip" gem "rubyzip"
gem "RedCloth", ">=4.0.0" gem "RedCloth", ">=4.0.0"
gem "erubis" gem "erubis"
gem "nokogiri" gem "nokogiri"
gem "rake" gem "rake", "~>0.8.7"
gem "json" gem "json"

View file

@ -1,5 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), '..', 'config', 'boot')
require File.join(File.dirname(File.dirname(__FILE__)), 'config', 'boot')
# Don't do this. Instead, put it here, where we can customize it. # Don't do this. Instead, put it here, where we can customize it.
#require 'commands/server' #require 'commands/server'
@ -46,7 +47,10 @@ ARGV.clone.options do |opts|
opts.parse! opts.parse!
end end
server = Rack::Handler.get(ARGV.first) rescue nil begin
server = Rack::Handler.get(ARGV.first)
rescue Exception
end
unless server unless server
begin begin
server = Rack::Handler::Mongrel server = Rack::Handler::Mongrel

View file

@ -1,18 +0,0 @@
Copyright (c) 2007, 2008, 2009, 2010 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.

View file

@ -1,21 +0,0 @@
= 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 "/".
Since lighttpd 1.4.23, you also can use the "fix-root-scriptname" flag
in fastcgi.server.

View file

@ -1,401 +0,0 @@
= 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
* Glassfish v3
* Phusion Passenger (which is mod_rack for Apache and for nginx)
* Rainbows!
* Unicorn
* Zbatery
Any valid Rack app will run the same on all these handlers, without
changing anything.
== Supported web frameworks
These frameworks include Rack adapters in their distributions:
* Camping
* Coset
* Halcyon
* Mack
* Maveric
* Merb
* Racktools::SimpleApplication
* Ramaze
* Ruby on Rails
* Rum
* Sinatra
* Sin
* Vintage
* Waves
* Wee
* ... and many others.
Current links to these projects can be found at
http://wiki.ramaze.net/Home#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 at gemcutter.org. 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 bacon testing framework:
gem install bacon
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 bacon.
To run the test suite completely, you need:
* fcgi
* memcache-client
* mongrel
* thin
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.
* April 25th, 2009: Seventh public release 1.0.0.
* SPEC change: Rack::VERSION has been pushed to [1,0].
* SPEC change: header values must be Strings now, split on "\n".
* SPEC change: Content-Length can be missing, in this case chunked transfer
encoding is used.
* SPEC change: rack.input must be rewindable and support reading into
a buffer, wrap with Rack::RewindableInput if it isn't.
* SPEC change: rack.session is now specified.
* SPEC change: Bodies can now additionally respond to #to_path with
a filename to be served.
* NOTE: String bodies break in 1.9, use an Array consisting of a
single String instead.
* New middleware Rack::Lock.
* New middleware Rack::ContentType.
* Rack::Reloader has been rewritten.
* Major update to Rack::Auth::OpenID.
* Support for nested parameter parsing in Rack::Response.
* Support for redirects in Rack::Response.
* HttpOnly cookie support in Rack::Response.
* The Rakefile has been rewritten.
* Many bugfixes and small improvements.
* October 18th, 2009: Eighth public release 1.0.1.
* Bump remainder of rack.versions.
* Support the pure Ruby FCGI implementation.
* Fix for form names containing "=": split first then unescape components
* Fixes the handling of the filename parameter with semicolons in names.
* Add anchor to nested params parsing regexp to prevent stack overflows
* Use more compatible gzip write api instead of "<<".
* Make sure that Reloader doesn't break when executed via ruby -e
* Make sure WEBrick respects the :Host option
* Many Ruby 1.9 fixes.
* January 3rd, 2010: Ninth public release 1.1.0.
* Moved Auth::OpenID to rack-contrib.
* SPEC change that relaxes Lint slightly to allow subclasses of the
required types
* SPEC change to document rack.input binary mode in greator detail
* SPEC define optional rack.logger specification
* File servers support X-Cascade header
* Imported Config middleware
* Imported ETag middleware
* Imported Runtime middleware
* Imported Sendfile middleware
* New Logger and NullLogger middlewares
* Added mime type for .ogv and .manifest.
* Don't squeeze PATH_INFO slashes
* Use Content-Type to determine POST params parsing
* Update Rack::Utils::HTTP_STATUS_CODES hash
* Add status code lookup utility
* Response should call #to_i on the status
* Add Request#user_agent
* Request#host knows about forwared host
* Return an empty string for Request#host if HTTP_HOST and
SERVER_NAME are both missing
* Allow MockRequest to accept hash params
* Optimizations to HeaderHash
* Refactored rackup into Rack::Server
* Added Utils.build_nested_query to complement Utils.parse_nested_query
* Added Utils::Multipart.build_multipart to complement
Utils::Multipart.parse_multipart
* Extracted set and delete cookie helpers into Utils so they can be
used outside Response
* Extract parse_query and parse_multipart in Request so subclasses
can change their behavior
* Enforce binary encoding in RewindableInput
* Set correct external_encoding for handlers that don't use RewindableInput
* June 13th, 2010: Tenth public release 1.2.0.
* Removed Camping adapter: Camping 2.0 supports Rack as-is
* Removed parsing of quoted values
* Add Request.trace? and Request.options?
* Add mime-type for .webm and .htc
* Fix HTTP_X_FORWARDED_FOR
* Various multipart fixes
* Switch test suite to bacon
* June 15th, 2010: Eleventh public release 1.2.1.
* Make CGI handler rewindable
* Rename spec/ to test/ to not conflict with SPEC on lesser
operating systems
== Contact
Please post bugs, suggestions and patches to
the bug tracker at <http://github.com/rack/rack/issues>.
Mailing list archives are available at
<http://groups.google.com/group/rack-devel>.
Git repository (send Git patches to the mailing list):
* http://github.com/rack/rack
* http://git.vuxu.org/cgi-bin/gitweb.cgi?p=rack-github.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.
* Alex Beregszaszi, Alexander Kahn, Anil Wadghule, Aredridel, Ben
Alpert, Dan Kubb, Daniel Roethlisberger, Matt Todd, Tom Robinson,
Phil Hagelberg, S. Brent Faulkner, Bosko Milekic, Daniel Rodríguez
Troitiño, Genki Takiuchi, Geoffrey Grosenbach, Julien Sanchez, Kamal
Fariz Mahyuddin, Masayoshi Takahashi, Patrick Aljordm, Mig, Kazuhiro
Nishiyama, Jon Bardin, Konstantin Haase, Larry Siden, Matias
Korhonen, Sam Ruby, Simon Chiang, Tim Connor, Timur Batyrshin, and
Zach Brock for bug fixing and other improvements.
* Eric Wong, Hongli Lai, Jeremy Kemper for their continuous support
and API improvements.
* Yehuda Katz and Carl Lerche for refactoring rackup.
* Brian Candler, for Rack::ContentType.
* Graham Batty, for improved handler loading.
* 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, 2010 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 Lighthouse Bug Tracking:: <http://rack.lighthouseapp.com/>
rack-devel mailing list:: <http://groups.google.com/group/rack-devel>
Christian Neukirchen:: <http://chneukirchen.org/>

View file

@ -1,100 +0,0 @@
# Rakefile for Rack. -*-ruby-*-
require 'rake/rdoctask'
desc "Run all the tests"
task :default => [:test]
desc "Make an archive as .tar.gz"
task :dist => [:chmod, :changelog, :rdoc, "SPEC"] do
sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
sh "pax -waf #{release}.tar -s ':^:#{release}/:' SPEC ChangeLog doc rack.gemspec"
sh "gzip -f -9 #{release}.tar"
end
desc "Make an official release"
task :officialrelease do
puts "Official build for #{release}..."
sh "rm -rf stage"
sh "git clone --shared . stage"
sh "cd stage && rake officialrelease_really"
sh "mv stage/#{release}.tar.gz stage/#{release}.gem ."
end
task :officialrelease_really => ["SPEC", :dist, :gem] do
sh "sha1sum #{release}.tar.gz #{release}.gem"
end
def release
"rack-#{File.read("rack.gemspec")[/s.version *= *"(.*?)"/, 1]}"
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 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
opts = ENV['TEST'] || '-a'
specopts = ENV['TESTOPTS'] ||
"-q -t '^(?!Rack::Adapter|Rack::Session::Memcache|rackup)'"
sh "bacon -I./lib:./test -w #{opts} #{specopts}"
end
desc "Run all the tests"
task :fulltest => [:chmod] do
opts = ENV['TEST'] || '-a'
specopts = ENV['TESTOPTS'] || '-q'
sh "bacon -I./lib:./test -w #{opts} #{specopts}"
end
task :gem => ["SPEC"] do
sh "gem build rack.gemspec"
end
desc "Generate RDoc documentation"
task :rdoc => ["SPEC"] do
sh(*%w{rdoc --line-numbers --main README
--title 'Rack\ Documentation' --charset utf-8 -U -o doc} +
%w{README KNOWN-ISSUES SPEC} +
Dir["lib/**/*.rb"])
end
task :pushsite => [:rdoc] do
sh "cd site && git gc"
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/"
sh "cd site && git push"
end

View file

@ -1,4 +0,0 @@
#!/usr/bin/env ruby
require "rack"
Rack::Server.start

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 35 KiB

View file

@ -1,4 +0,0 @@
require 'rack/lobster'
use Rack::ShowExceptions
run Rack::Lobster.new

View file

@ -1,14 +0,0 @@
require 'rack'
require 'rack/lobster'
lobster = Rack::Lobster.new
protected_lobster = Rack::Auth::Basic.new(lobster) do |username, password|
'secret' == password
end
protected_lobster.realm = 'Lobster 2.0'
pretty_protected_lobster = Rack::ShowStatus.new(Rack::ShowExceptions.new(protected_lobster))
Rack::Handler::WEBrick.run pretty_protected_lobster, :Port => 9292

View file

@ -1,8 +0,0 @@
require 'rack/lobster'
use Rack::ShowExceptions
use Rack::Auth::Basic, "Lobster 2.0" do |username, password|
'secret' == password
end
run Rack::Lobster.new

View file

@ -1,84 +0,0 @@
# Copyright (C) 2007, 2008, 2009, 2010 Christian Neukirchen <purl.org/net/chneukirchen>
#
# Rack is freely distributable under the terms of an MIT-style license.
# See COPYING or http://www.opensource.org/licenses/mit-license.php.
# The Rack main module, serving as a namespace for all core Rack
# modules and classes.
#
# All modules meant for use in your application are <tt>autoload</tt>ed here,
# so it should be enough just to <tt>require rack.rb</tt> in your code.
module Rack
# The Rack protocol version number implemented.
VERSION = [1,1]
# Return the Rack protocol version as a dotted string.
def self.version
VERSION.join(".")
end
# Return the Rack release as a dotted string.
def self.release
"1.2.1"
end
autoload :Builder, "rack/builder"
autoload :Cascade, "rack/cascade"
autoload :Chunked, "rack/chunked"
autoload :CommonLogger, "rack/commonlogger"
autoload :ConditionalGet, "rack/conditionalget"
autoload :Config, "rack/config"
require "rack/content_length"
# autoload :ContentLength, "rack/content_length"
autoload :ContentType, "rack/content_type"
autoload :ETag, "rack/etag"
autoload :File, "rack/file"
autoload :Deflater, "rack/deflater"
autoload :Directory, "rack/directory"
autoload :ForwardRequest, "rack/recursive"
require "rack/handler"
# autoload :Handler, "rack/handler"
autoload :Head, "rack/head"
autoload :Lint, "rack/lint"
autoload :Lock, "rack/lock"
autoload :Logger, "rack/logger"
autoload :MethodOverride, "rack/methodoverride"
autoload :Mime, "rack/mime"
autoload :NullLogger, "rack/nulllogger"
autoload :Recursive, "rack/recursive"
autoload :Reloader, "rack/reloader"
autoload :Runtime, "rack/runtime"
autoload :Sendfile, "rack/sendfile"
autoload :Server, "rack/server"
autoload :ShowExceptions, "rack/showexceptions"
autoload :ShowStatus, "rack/showstatus"
autoload :Static, "rack/static"
autoload :URLMap, "rack/urlmap"
require "rack/utils"
# autoload :Utils, "rack/utils"
autoload :MockRequest, "rack/mock"
autoload :MockResponse, "rack/mock"
autoload :Request, "rack/request"
autoload :Response, "rack/response"
module Auth
autoload :Basic, "rack/auth/basic"
autoload :AbstractRequest, "rack/auth/abstract/request"
autoload :AbstractHandler, "rack/auth/abstract/handler"
module Digest
autoload :MD5, "rack/auth/digest/md5"
autoload :Nonce, "rack/auth/digest/nonce"
autoload :Params, "rack/auth/digest/params"
autoload :Request, "rack/auth/digest/request"
end
end
module Session
autoload :Cookie, "rack/session/cookie"
autoload :Pool, "rack/session/pool"
autoload :Memcache, "rack/session/memcache"
end
end

View file

@ -1,37 +0,0 @@
module Rack
module Auth
# Rack::Auth::AbstractHandler implements common authentication functionality.
#
# +realm+ should be set for all handlers.
class AbstractHandler
attr_accessor :realm
def initialize(app, realm=nil, &authenticator)
@app, @realm, @authenticator = app, realm, authenticator
end
private
def unauthorized(www_authenticate = challenge)
return [ 401,
{ 'Content-Type' => 'text/plain',
'Content-Length' => '0',
'WWW-Authenticate' => www_authenticate.to_s },
[]
]
end
def bad_request
return [ 400,
{ 'Content-Type' => 'text/plain',
'Content-Length' => '0' },
[]
]
end
end
end
end

View file

@ -1,37 +0,0 @@
module Rack
module Auth
class AbstractRequest
def initialize(env)
@env = env
end
def provided?
!authorization_key.nil?
end
def parts
@parts ||= @env[authorization_key].split(' ', 2)
end
def scheme
@scheme ||= parts.first.downcase.to_sym
end
def params
@params ||= parts.last
end
private
AUTHORIZATION_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION']
def authorization_key
@authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.has_key?(key) }
end
end
end
end

View file

@ -1,58 +0,0 @@
require 'rack/auth/abstract/handler'
require 'rack/auth/abstract/request'
module Rack
module Auth
# Rack::Auth::Basic implements HTTP Basic Authentication, as per RFC 2617.
#
# Initialize with the Rack application that you want protecting,
# and a block that checks if a username and password pair are valid.
#
# See also: <tt>example/protectedlobster.rb</tt>
class Basic < AbstractHandler
def call(env)
auth = Basic::Request.new(env)
return unauthorized unless auth.provided?
return bad_request unless auth.basic?
if valid?(auth)
env['REMOTE_USER'] = auth.username
return @app.call(env)
end
unauthorized
end
private
def challenge
'Basic realm="%s"' % realm
end
def valid?(auth)
@authenticator.call(*auth.credentials)
end
class Request < Auth::AbstractRequest
def basic?
:basic == scheme
end
def credentials
@credentials ||= params.unpack("m*").first.split(/:/, 2)
end
def username
credentials.first
end
end
end
end
end

View file

@ -1,124 +0,0 @@
require 'rack/auth/abstract/handler'
require 'rack/auth/digest/request'
require 'rack/auth/digest/params'
require 'rack/auth/digest/nonce'
require 'digest/md5'
module Rack
module Auth
module Digest
# Rack::Auth::Digest::MD5 implements the MD5 algorithm version of
# HTTP Digest Authentication, as per RFC 2617.
#
# Initialize with the [Rack] application that you want protecting,
# and a block that looks up a plaintext password for a given username.
#
# +opaque+ needs to be set to a constant base64/hexadecimal string.
#
class MD5 < AbstractHandler
attr_accessor :opaque
attr_writer :passwords_hashed
def initialize(*args)
super
@passwords_hashed = nil
end
def passwords_hashed?
!!@passwords_hashed
end
def call(env)
auth = Request.new(env)
unless auth.provided?
return unauthorized
end
if !auth.digest? || !auth.correct_uri? || !valid_qop?(auth)
return bad_request
end
if valid?(auth)
if auth.nonce.stale?
return unauthorized(challenge(:stale => true))
else
env['REMOTE_USER'] = auth.username
return @app.call(env)
end
end
unauthorized
end
private
QOP = 'auth'.freeze
def params(hash = {})
Params.new do |params|
params['realm'] = realm
params['nonce'] = Nonce.new.to_s
params['opaque'] = H(opaque)
params['qop'] = QOP
hash.each { |k, v| params[k] = v }
end
end
def challenge(hash = {})
"Digest #{params(hash)}"
end
def valid?(auth)
valid_opaque?(auth) && valid_nonce?(auth) && valid_digest?(auth)
end
def valid_qop?(auth)
QOP == auth.qop
end
def valid_opaque?(auth)
H(opaque) == auth.opaque
end
def valid_nonce?(auth)
auth.nonce.valid?
end
def valid_digest?(auth)
digest(auth, @authenticator.call(auth.username)) == auth.response
end
def md5(data)
::Digest::MD5.hexdigest(data)
end
alias :H :md5
def KD(secret, data)
H([secret, data] * ':')
end
def A1(auth, password)
[ auth.username, auth.realm, password ] * ':'
end
def A2(auth)
[ auth.method, auth.uri ] * ':'
end
def digest(auth, password)
password_hash = passwords_hashed? ? password : H(A1(auth, password))
KD(password_hash, [ auth.nonce, auth.nc, auth.cnonce, QOP, H(A2(auth)) ] * ':')
end
end
end
end
end

View file

@ -1,51 +0,0 @@
require 'digest/md5'
module Rack
module Auth
module Digest
# Rack::Auth::Digest::Nonce is the default nonce generator for the
# Rack::Auth::Digest::MD5 authentication handler.
#
# +private_key+ needs to set to a constant string.
#
# +time_limit+ can be optionally set to an integer (number of seconds),
# to limit the validity of the generated nonces.
class Nonce
class << self
attr_accessor :private_key, :time_limit
end
def self.parse(string)
new(*string.unpack("m*").first.split(' ', 2))
end
def initialize(timestamp = Time.now, given_digest = nil)
@timestamp, @given_digest = timestamp.to_i, given_digest
end
def to_s
[([ @timestamp, digest ] * ' ')].pack("m*").strip
end
def digest
::Digest::MD5.hexdigest([ @timestamp, self.class.private_key ] * ':')
end
def valid?
digest == @given_digest
end
def stale?
!self.class.time_limit.nil? && (@timestamp - Time.now.to_i) < self.class.time_limit
end
def fresh?
!stale?
end
end
end
end
end

View file

@ -1,55 +0,0 @@
module Rack
module Auth
module Digest
class Params < Hash
def self.parse(str)
split_header_value(str).inject(new) do |header, param|
k, v = param.split('=', 2)
header[k] = dequote(v)
header
end
end
def self.dequote(str) # From WEBrick::HTTPUtils
ret = (/\A"(.*)"\Z/ =~ str) ? $1 : str.dup
ret.gsub!(/\\(.)/, "\\1")
ret
end
def self.split_header_value(str)
str.scan( /(\w+\=(?:"[^\"]+"|[^,]+))/n ).collect{ |v| v[0] }
end
def initialize
super
yield self if block_given?
end
def [](k)
super k.to_s
end
def []=(k, v)
super k.to_s, v.to_s
end
UNQUOTED = ['nc', 'stale']
def to_s
inject([]) do |parts, (k, v)|
parts << "#{k}=" + (UNQUOTED.include?(k) ? v.to_s : quote(v))
parts
end.join(', ')
end
def quote(str) # From WEBrick::HTTPUtils
'"' << str.gsub(/[\\\"]/o, "\\\1") << '"'
end
end
end
end
end

View file

@ -1,40 +0,0 @@
require 'rack/auth/abstract/request'
require 'rack/auth/digest/params'
require 'rack/auth/digest/nonce'
module Rack
module Auth
module Digest
class Request < Auth::AbstractRequest
def method
@env['rack.methodoverride.original_method'] || @env['REQUEST_METHOD']
end
def digest?
:digest == scheme
end
def correct_uri?
(@env['SCRIPT_NAME'].to_s + @env['PATH_INFO'].to_s) == uri
end
def nonce
@nonce ||= Nonce.parse(params['nonce'])
end
def params
@params ||= Params.parse(parts.last)
end
def method_missing(sym)
if params.has_key? key = sym.to_s
return params[key]
end
super
end
end
end
end
end

View file

@ -1,80 +0,0 @@
module Rack
# Rack::Builder implements a small DSL to iteratively construct Rack
# applications.
#
# Example:
#
# app = Rack::Builder.new {
# use Rack::CommonLogger
# use Rack::ShowExceptions
# map "/lobster" do
# use Rack::Lint
# run Rack::Lobster.new
# end
# }
#
# Or
#
# app = Rack::Builder.app do
# use Rack::CommonLogger
# lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'OK'] }
# end
#
# +use+ adds a middleware to the stack, +run+ dispatches to an application.
# You can use +map+ to construct a Rack::URLMap in a convenient way.
class Builder
def self.parse_file(config, opts = Server::Options.new)
options = {}
if config =~ /\.ru$/
cfgfile = ::File.read(config)
if cfgfile[/^#\\(.*)/] && opts
options = opts.parse! $1.split(/\s+/)
end
cfgfile.sub!(/^__END__\n.*/, '')
app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app",
TOPLEVEL_BINDING, config
else
require config
app = Object.const_get(::File.basename(config, '.rb').capitalize)
end
return app, options
end
def initialize(&block)
@ins = []
instance_eval(&block) if block_given?
end
def self.app(&block)
self.new(&block).to_app
end
def use(middleware, *args, &block)
@ins << lambda { |app| middleware.new(app, *args, &block) }
end
def run(app)
@ins << app #lambda { |nothing| app }
end
def map(path, &block)
if @ins.last.kind_of? Hash
@ins.last[path] = self.class.new(&block).to_app
else
@ins << {}
map(path, &block)
end
end
def to_app
@ins[-1] = Rack::URLMap.new(@ins.last) if Hash === @ins.last
inner_app = @ins.last
@ins[0...-1].reverse.inject(inner_app) { |a, e| e.call(a) }
end
def call(env)
to_app.call(env)
end
end
end

View file

@ -1,41 +0,0 @@
module Rack
# Rack::Cascade tries an request on several apps, and returns the
# first response that is not 404 (or in a list of configurable
# status codes).
class Cascade
NotFound = [404, {}, []]
attr_reader :apps
def initialize(apps, catch=404)
@apps = []; @has_app = {}
apps.each { |app| add app }
@catch = {}
[*catch].each { |status| @catch[status] = true }
end
def call(env)
result = NotFound
@apps.each do |app|
result = app.call(env)
break unless @catch.include?(result[0].to_i)
end
result
end
def add app
@has_app[app] = true
@apps << app
end
def include? app
@has_app.include? app
end
alias_method :<<, :add
end
end

View file

@ -1,49 +0,0 @@
require 'rack/utils'
module Rack
# Middleware that applies chunked transfer encoding to response bodies
# when the response does not include a Content-Length header.
class Chunked
include Rack::Utils
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
headers = HeaderHash.new(headers)
if env['HTTP_VERSION'] == 'HTTP/1.0' ||
STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
headers['Content-Length'] ||
headers['Transfer-Encoding']
[status, headers, body]
else
dup.chunk(status, headers, body)
end
end
def chunk(status, headers, body)
@body = body
headers.delete('Content-Length')
headers['Transfer-Encoding'] = 'chunked'
[status, headers, self]
end
def each
term = "\r\n"
@body.each do |chunk|
size = bytesize(chunk)
next if size == 0
yield [size.to_s(16), term, chunk, term].join
end
yield ["0", term, "", term].join
end
def close
@body.close if @body.respond_to?(:close)
end
end
end

View file

@ -1,49 +0,0 @@
module Rack
# Rack::CommonLogger forwards every request to an +app+ given, and
# logs a line in the Apache common log format to the +logger+, or
# rack.errors by default.
class CommonLogger
# Common Log Format: http://httpd.apache.org/docs/1.3/logs.html#common
# lilith.local - - [07/Aug/2006 23:58:02] "GET / HTTP/1.1" 500 -
# %{%s - %s [%s] "%s %s%s %s" %d %s\n} %
FORMAT = %{%s - %s [%s] "%s %s%s %s" %d %s %0.4f\n}
def initialize(app, logger=nil)
@app = app
@logger = logger
end
def call(env)
began_at = Time.now
status, header, body = @app.call(env)
header = Utils::HeaderHash.new(header)
log(env, status, header, began_at)
[status, header, body]
end
private
def log(env, status, header, began_at)
now = Time.now
length = extract_content_length(header)
logger = @logger || env['rack.errors']
logger.write FORMAT % [
env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
env["REMOTE_USER"] || "-",
now.strftime("%d/%b/%Y %H:%M:%S"),
env["REQUEST_METHOD"],
env["PATH_INFO"],
env["QUERY_STRING"].empty? ? "" : "?"+env["QUERY_STRING"],
env["HTTP_VERSION"],
status.to_s[0..3],
length,
now - began_at ]
end
def extract_content_length(headers)
value = headers['Content-Length'] or return '-'
value.to_s == '0' ? '-' : value
end
end
end

View file

@ -1,47 +0,0 @@
require 'rack/utils'
module Rack
# 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.
#
# Applications that defer response body generation until the body's each
# message is received will avoid response body generation completely when
# a conditional GET matches.
#
# Adapted from Michael Klishin's Merb implementation:
# http://github.com/wycats/merb-core/tree/master/lib/merb-core/rack/middleware/conditional_get.rb
class ConditionalGet
def initialize(app)
@app = app
end
def call(env)
return @app.call(env) unless %w[GET HEAD].include?(env['REQUEST_METHOD'])
status, headers, body = @app.call(env)
headers = Utils::HeaderHash.new(headers)
if etag_matches?(env, headers) || modified_since?(env, headers)
status = 304
headers.delete('Content-Type')
headers.delete('Content-Length')
body = []
end
[status, headers, body]
end
private
def etag_matches?(env, headers)
etag = headers['Etag'] and etag == env['HTTP_IF_NONE_MATCH']
end
def modified_since?(env, headers)
last_modified = headers['Last-Modified'] and
last_modified == env['HTTP_IF_MODIFIED_SINCE']
end
end
end

View file

@ -1,15 +0,0 @@
module Rack
# Rack::Config modifies the environment using the block given during
# initialization.
class Config
def initialize(app, &block)
@app = app
@block = block
end
def call(env)
@block.call(env)
@app.call(env)
end
end
end

View file

@ -1,29 +0,0 @@
require 'rack/utils'
module Rack
# Sets the Content-Length header on responses with fixed-length bodies.
class ContentLength
include Rack::Utils
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
headers = HeaderHash.new(headers)
if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) &&
!headers['Content-Length'] &&
!headers['Transfer-Encoding'] &&
(body.respond_to?(:to_ary) || body.respond_to?(:to_str))
body = [body] if body.respond_to?(:to_str) # rack 0.4 compat
length = body.to_ary.inject(0) { |len, part| len + bytesize(part) }
headers['Content-Length'] = length.to_s
end
[status, headers, body]
end
end
end

View file

@ -1,23 +0,0 @@
require 'rack/utils'
module Rack
# Sets the Content-Type header on responses which don't have one.
#
# Builder Usage:
# use Rack::ContentType, "text/plain"
#
# When no content type argument is provided, "text/html" is assumed.
class ContentType
def initialize(app, content_type = "text/html")
@app, @content_type = app, content_type
end
def call(env)
status, headers, body = @app.call(env)
headers = Utils::HeaderHash.new(headers)
headers['Content-Type'] ||= @content_type
[status, headers, body]
end
end
end

View file

@ -1,96 +0,0 @@
require "zlib"
require "stringio"
require "time" # for Time.httpdate
require 'rack/utils'
module Rack
class Deflater
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
headers = Utils::HeaderHash.new(headers)
# Skip compressing empty entity body responses and responses with
# no-transform set.
if Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
headers['Cache-Control'].to_s =~ /\bno-transform\b/
return [status, headers, body]
end
request = Request.new(env)
encoding = Utils.select_best_encoding(%w(gzip deflate identity),
request.accept_encoding)
# Set the Vary HTTP header.
vary = headers["Vary"].to_s.split(",").map { |v| v.strip }
unless vary.include?("*") || vary.include?("Accept-Encoding")
headers["Vary"] = vary.push("Accept-Encoding").join(",")
end
case encoding
when "gzip"
headers['Content-Encoding'] = "gzip"
headers.delete('Content-Length')
mtime = headers.key?("Last-Modified") ?
Time.httpdate(headers["Last-Modified"]) : Time.now
[status, headers, GzipStream.new(body, mtime)]
when "deflate"
headers['Content-Encoding'] = "deflate"
headers.delete('Content-Length')
[status, headers, DeflateStream.new(body)]
when "identity"
[status, headers, body]
when nil
message = "An acceptable encoding for the requested resource #{request.fullpath} could not be found."
[406, {"Content-Type" => "text/plain", "Content-Length" => message.length.to_s}, [message]]
end
end
class GzipStream
def initialize(body, mtime)
@body = body
@mtime = mtime
end
def each(&block)
@writer = block
gzip =::Zlib::GzipWriter.new(self)
gzip.mtime = @mtime
@body.each { |part| gzip.write(part) }
@body.close if @body.respond_to?(:close)
gzip.close
@writer = nil
end
def write(data)
@writer.call(data)
end
end
class DeflateStream
DEFLATE_ARGS = [
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
]
def initialize(body)
@body = body
end
def each
deflater = ::Zlib::Deflate.new(*DEFLATE_ARGS)
@body.each { |part| yield deflater.deflate(part) }
@body.close if @body.respond_to?(:close)
yield deflater.finish
nil
end
end
end
end

View file

@ -1,157 +0,0 @@
require 'time'
require 'rack/utils'
require 'rack/mime'
module Rack
# Rack::Directory serves entries below the +root+ given, according to the
# path info of the Rack request. If a directory is found, the file's contents
# will be presented in an html based index. If a file is found, the env will
# be passed to the specified +app+.
#
# If +app+ is not specified, a Rack::File of the same +root+ will be used.
class Directory
DIR_FILE = "<tr><td class='name'><a href='%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>"
DIR_PAGE = <<-PAGE
<html><head>
<title>%s</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type='text/css'>
table { width:100%%; }
.name { text-align:left; }
.size, .mtime { text-align:right; }
.type { width:11em; }
.mtime { width:15em; }
</style>
</head><body>
<h1>%s</h1>
<hr />
<table>
<tr>
<th class='name'>Name</th>
<th class='size'>Size</th>
<th class='type'>Type</th>
<th class='mtime'>Last Modified</th>
</tr>
%s
</table>
<hr />
</body></html>
PAGE
attr_reader :files
attr_accessor :root, :path
def initialize(root, app=nil)
@root = F.expand_path(root)
@app = app || Rack::File.new(@root)
end
def call(env)
dup._call(env)
end
F = ::File
def _call(env)
@env = env
@script_name = env['SCRIPT_NAME']
@path_info = Utils.unescape(env['PATH_INFO'])
if forbidden = check_forbidden
forbidden
else
@path = F.join(@root, @path_info)
list_path
end
end
def check_forbidden
return unless @path_info.include? ".."
body = "Forbidden\n"
size = Rack::Utils.bytesize(body)
return [403, {"Content-Type" => "text/plain",
"Content-Length" => size.to_s,
"X-Cascade" => "pass"}, [body]]
end
def list_directory
@files = [['../','Parent Directory','','','']]
glob = F.join(@path, '*')
Dir[glob].sort.each do |node|
stat = stat(node)
next unless stat
basename = F.basename(node)
ext = F.extname(node)
url = F.join(@script_name, @path_info, basename)
size = stat.size
type = stat.directory? ? 'directory' : Mime.mime_type(ext)
size = stat.directory? ? '-' : filesize_format(size)
mtime = stat.mtime.httpdate
url << '/' if stat.directory?
basename << '/' if stat.directory?
@files << [ url, basename, size, type, mtime ]
end
return [ 200, {'Content-Type'=>'text/html; charset=utf-8'}, self ]
end
def stat(node, max = 10)
F.stat(node)
rescue Errno::ENOENT, Errno::ELOOP
return nil
end
# TODO: add correct response if not readable, not sure if 404 is the best
# option
def list_path
@stat = F.stat(@path)
if @stat.readable?
return @app.call(@env) if @stat.file?
return list_directory if @stat.directory?
else
raise Errno::ENOENT, 'No such file or directory'
end
rescue Errno::ENOENT, Errno::ELOOP
return entity_not_found
end
def entity_not_found
body = "Entity not found: #{@path_info}\n"
size = Rack::Utils.bytesize(body)
return [404, {"Content-Type" => "text/plain",
"Content-Length" => size.to_s,
"X-Cascade" => "pass"}, [body]]
end
def each
show_path = @path.sub(/^#{@root}/,'')
files = @files.map{|f| DIR_FILE % f }*"\n"
page = DIR_PAGE % [ show_path, show_path , files ]
page.each_line{|l| yield l }
end
# Stolen from Ramaze
FILESIZE_FORMAT = [
['%.1fT', 1 << 40],
['%.1fG', 1 << 30],
['%.1fM', 1 << 20],
['%.1fK', 1 << 10],
]
def filesize_format(int)
FILESIZE_FORMAT.each do |format, size|
return format % (int.to_f / size) if int >= size
end
int.to_s + 'B'
end
end
end

View file

@ -1,32 +0,0 @@
require 'digest/md5'
module Rack
# Automatically sets the ETag header on all String bodies
class ETag
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
if !headers.has_key?('ETag')
digest, body = digest_body(body)
headers['ETag'] = %("#{digest}")
end
[status, headers, body]
end
private
def digest_body(body)
digest = Digest::MD5.new
parts = []
body.each do |part|
digest << part
parts << part
end
[digest.hexdigest, parts]
end
end
end

View file

@ -1,92 +0,0 @@
require 'time'
require 'rack/utils'
require 'rack/mime'
module Rack
# Rack::File serves files below the +root+ directory given, according to the
# path info of the Rack request.
# e.g. when Rack::File.new("/etc") is used, you can access 'passwd' file
# as http://localhost:9292/passwd
#
# Handlers can detect if bodies are a Rack::File, and use mechanisms
# like sendfile on the +path+.
class File
attr_accessor :root
attr_accessor :path
alias :to_path :path
def initialize(root)
@root = root
end
def call(env)
dup._call(env)
end
F = ::File
def _call(env)
@path_info = Utils.unescape(env["PATH_INFO"])
return forbidden if @path_info.include? ".."
@path = F.join(@root, @path_info)
begin
if F.file?(@path) && F.readable?(@path)
serving
else
raise Errno::EPERM
end
rescue SystemCallError
not_found
end
end
def forbidden
body = "Forbidden\n"
[403, {"Content-Type" => "text/plain",
"Content-Length" => body.size.to_s,
"X-Cascade" => "pass"},
[body]]
end
# NOTE:
# 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.
def serving
if size = F.size?(@path)
body = self
else
body = [F.read(@path)]
size = Utils.bytesize(body.first)
end
[200, {
"Last-Modified" => F.mtime(@path).httpdate,
"Content-Type" => Mime.mime_type(F.extname(@path), 'text/plain'),
"Content-Length" => size.to_s
}, body]
end
def not_found
body = "File not found: #{@path_info}\n"
[404, {"Content-Type" => "text/plain",
"Content-Length" => body.size.to_s,
"X-Cascade" => "pass"},
[body]]
end
def each
F.open(@path, "rb") { |file|
while part = file.read(8192)
yield part
end
}
end
end
end

View file

@ -1,89 +0,0 @@
module Rack
# *Handlers* connect web servers with Rack.
#
# Rack includes Handlers for Mongrel, WEBrick, FastCGI, CGI, SCGI
# and LiteSpeed.
#
# Handlers usually are activated by calling <tt>MyHandler.run(myapp)</tt>.
# A second optional hash can be passed to include server-specific
# configuration.
module Handler
def self.get(server)
return unless server
server = server.to_s
if klass = @handlers[server]
obj = Object
klass.split("::").each { |x| obj = obj.const_get(x) }
obj
else
try_require('rack/handler', server)
const_get(server)
end
end
def self.default(options = {})
# Guess.
if ENV.include?("PHP_FCGI_CHILDREN")
# We already speak FastCGI
options.delete :File
options.delete :Port
Rack::Handler::FastCGI
elsif ENV.include?("REQUEST_METHOD")
Rack::Handler::CGI
else
begin
Rack::Handler::Mongrel
rescue LoadError => e
Rack::Handler::WEBrick
end
end
end
# Transforms server-name constants to their canonical form as filenames,
# then tries to require them but silences the LoadError if not found
#
# Naming convention:
#
# Foo # => 'foo'
# FooBar # => 'foo_bar.rb'
# FooBAR # => 'foobar.rb'
# FOObar # => 'foobar.rb'
# FOOBAR # => 'foobar.rb'
# FooBarBaz # => 'foo_bar_baz.rb'
def self.try_require(prefix, const_name)
file = const_name.gsub(/^[A-Z]+/) { |pre| pre.downcase }.
gsub(/[A-Z]+[^A-Z]/, '_\&').downcase
require(::File.join(prefix, file))
rescue LoadError
end
def self.register(server, klass)
@handlers ||= {}
@handlers[server] = klass
end
autoload :CGI, "rack/handler/cgi"
autoload :FastCGI, "rack/handler/fastcgi"
autoload :Mongrel, "rack/handler/mongrel"
autoload :EventedMongrel, "rack/handler/evented_mongrel"
autoload :SwiftipliedMongrel, "rack/handler/swiftiplied_mongrel"
require "rack/handler/webrick"
# autoload :WEBrick, "rack/handler/webrick"
autoload :LSWS, "rack/handler/lsws"
autoload :SCGI, "rack/handler/scgi"
autoload :Thin, "rack/handler/thin"
register 'cgi', 'Rack::Handler::CGI'
register 'fastcgi', 'Rack::Handler::FastCGI'
register 'mongrel', 'Rack::Handler::Mongrel'
register 'emongrel', 'Rack::Handler::EventedMongrel'
register 'smongrel', 'Rack::Handler::SwiftipliedMongrel'
register 'webrick', 'Rack::Handler::WEBrick'
register 'lsws', 'Rack::Handler::LSWS'
register 'scgi', 'Rack::Handler::SCGI'
register 'thin', 'Rack::Handler::Thin'
end
end

View file

@ -1,63 +0,0 @@
require 'rack/content_length'
require 'rack/rewindable_input'
module Rack
module Handler
class CGI
def self.run(app, options=nil)
$stdin.binmode
serve app
end
def self.serve(app)
app = ContentLength.new(app)
env = ENV.to_hash
env.delete "HTTP_CONTENT_LENGTH"
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
env.update({"rack.version" => Rack::VERSION,
"rack.input" => Rack::RewindableInput.new($stdin),
"rack.errors" => $stderr,
"rack.multithread" => false,
"rack.multiprocess" => true,
"rack.run_once" => true,
"rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
})
env["QUERY_STRING"] ||= ""
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
env["REQUEST_PATH"] ||= "/"
status, headers, body = app.call(env)
begin
send_headers status, headers
send_body body
ensure
body.close if body.respond_to? :close
end
end
def self.send_headers(status, headers)
$stdout.print "Status: #{status}\r\n"
headers.each { |k, vs|
vs.split("\n").each { |v|
$stdout.print "#{k}: #{v}\r\n"
}
}
$stdout.print "\r\n"
$stdout.flush
end
def self.send_body(body)
body.each { |part|
$stdout.print part
$stdout.flush
}
end
end
end
end

View file

@ -1,8 +0,0 @@
require 'swiftcore/evented_mongrel'
module Rack
module Handler
class EventedMongrel < Handler::Mongrel
end
end
end

View file

@ -1,89 +0,0 @@
require 'fcgi'
require 'socket'
require 'rack/content_length'
require 'rack/rewindable_input'
if defined? FCGI::Stream
class FCGI::Stream
alias _rack_read_without_buffer read
def read(n, buffer=nil)
buf = _rack_read_without_buffer n
buffer.replace(buf.to_s) if buffer
buf
end
end
end
module Rack
module Handler
class FastCGI
def self.run(app, options={})
file = options[:File] and STDIN.reopen(UNIXServer.new(file))
port = options[:Port] and STDIN.reopen(TCPServer.new(options[:Host], port))
FCGI.each { |request|
serve request, app
}
end
def self.serve(request, app)
app = Rack::ContentLength.new(app)
env = request.env
env.delete "HTTP_CONTENT_LENGTH"
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
rack_input = RewindableInput.new(request.in)
env.update({"rack.version" => Rack::VERSION,
"rack.input" => rack_input,
"rack.errors" => request.err,
"rack.multithread" => false,
"rack.multiprocess" => true,
"rack.run_once" => false,
"rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
})
env["QUERY_STRING"] ||= ""
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
env["REQUEST_PATH"] ||= "/"
env.delete "CONTENT_TYPE" if env["CONTENT_TYPE"] == ""
env.delete "CONTENT_LENGTH" if env["CONTENT_LENGTH"] == ""
begin
status, headers, body = app.call(env)
begin
send_headers request.out, status, headers
send_body request.out, body
ensure
body.close if body.respond_to? :close
end
ensure
rack_input.close
request.finish
end
end
def self.send_headers(out, status, headers)
out.print "Status: #{status}\r\n"
headers.each { |k, vs|
vs.split("\n").each { |v|
out.print "#{k}: #{v}\r\n"
}
}
out.print "\r\n"
out.flush
end
def self.send_body(out, body)
body.each { |part|
out.print part
out.flush
}
end
end
end
end

View file

@ -1,63 +0,0 @@
require 'lsapi'
require 'rack/content_length'
require 'rack/rewindable_input'
module Rack
module Handler
class LSWS
def self.run(app, options=nil)
while LSAPI.accept != nil
serve app
end
end
def self.serve(app)
app = Rack::ContentLength.new(app)
env = ENV.to_hash
env.delete "HTTP_CONTENT_LENGTH"
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
rack_input = RewindableInput.new($stdin.read.to_s)
env.update(
"rack.version" => Rack::VERSION,
"rack.input" => rack_input,
"rack.errors" => $stderr,
"rack.multithread" => false,
"rack.multiprocess" => true,
"rack.run_once" => false,
"rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
)
env["QUERY_STRING"] ||= ""
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
env["REQUEST_PATH"] ||= "/"
status, headers, body = app.call(env)
begin
send_headers status, headers
send_body body
ensure
body.close if body.respond_to? :close
end
ensure
rack_input.close
end
def self.send_headers(status, headers)
print "Status: #{status}\r\n"
headers.each { |k, vs|
vs.split("\n").each { |v|
print "#{k}: #{v}\r\n"
}
}
print "\r\n"
STDOUT.flush
end
def self.send_body(body)
body.each { |part|
print part
STDOUT.flush
}
end
end
end
end

View file

@ -1,90 +0,0 @@
require 'mongrel'
require 'stringio'
require 'rack/content_length'
require 'rack/chunked'
module Rack
module Handler
class Mongrel < ::Mongrel::HttpHandler
def self.run(app, options={})
server = ::Mongrel::HttpServer.new(
options[:Host] || '0.0.0.0',
options[:Port] || 8080,
options[:num_processors] || 950,
options[:throttle] || 0,
options[:timeout] || 60)
# Acts like Rack::URLMap, utilizing Mongrel's own path finding methods.
# Use is similar to #run, replacing the app argument with a hash of
# { path=>app, ... } or an instance of Rack::URLMap.
if options[:map]
if app.is_a? Hash
app.each do |path, appl|
path = '/'+path unless path[0] == ?/
server.register(path, Rack::Handler::Mongrel.new(appl))
end
elsif app.is_a? URLMap
app.instance_variable_get(:@mapping).each do |(host, path, appl)|
next if !host.nil? && !options[:Host].nil? && options[:Host] != host
path = '/'+path unless path[0] == ?/
server.register(path, Rack::Handler::Mongrel.new(appl))
end
else
raise ArgumentError, "first argument should be a Hash or URLMap"
end
else
server.register('/', Rack::Handler::Mongrel.new(app))
end
yield server if block_given?
server.run.join
end
def initialize(app)
@app = Rack::Chunked.new(Rack::ContentLength.new(app))
end
def process(request, response)
env = {}.replace(request.params)
env.delete "HTTP_CONTENT_TYPE"
env.delete "HTTP_CONTENT_LENGTH"
env["SCRIPT_NAME"] = "" if env["SCRIPT_NAME"] == "/"
rack_input = request.body || StringIO.new('')
rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
env.update({"rack.version" => Rack::VERSION,
"rack.input" => rack_input,
"rack.errors" => $stderr,
"rack.multithread" => true,
"rack.multiprocess" => false, # ???
"rack.run_once" => false,
"rack.url_scheme" => "http",
})
env["QUERY_STRING"] ||= ""
status, headers, body = @app.call(env)
begin
response.status = status.to_i
response.send_status(nil)
headers.each { |k, vs|
vs.split("\n").each { |v|
response.header[k] = v
}
}
response.send_header
body.each { |part|
response.write part
response.socket.flush
}
ensure
body.close if body.respond_to? :close
end
end
end
end
end

View file

@ -1,59 +0,0 @@
require 'scgi'
require 'stringio'
require 'rack/content_length'
require 'rack/chunked'
module Rack
module Handler
class SCGI < ::SCGI::Processor
attr_accessor :app
def self.run(app, options=nil)
new(options.merge(:app=>app,
:host=>options[:Host],
:port=>options[:Port],
:socket=>options[:Socket])).listen
end
def initialize(settings = {})
@app = Rack::Chunked.new(Rack::ContentLength.new(settings[:app]))
super(settings)
end
def process_request(request, input_body, socket)
env = {}.replace(request)
env.delete "HTTP_CONTENT_TYPE"
env.delete "HTTP_CONTENT_LENGTH"
env["REQUEST_PATH"], env["QUERY_STRING"] = env["REQUEST_URI"].split('?', 2)
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
env["PATH_INFO"] = env["REQUEST_PATH"]
env["QUERY_STRING"] ||= ""
env["SCRIPT_NAME"] = ""
rack_input = StringIO.new(input_body)
rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
env.update({"rack.version" => Rack::VERSION,
"rack.input" => rack_input,
"rack.errors" => $stderr,
"rack.multithread" => true,
"rack.multiprocess" => true,
"rack.run_once" => false,
"rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
})
status, headers, body = app.call(env)
begin
socket.write("Status: #{status}\r\n")
headers.each do |k, vs|
vs.split("\n").each { |v| socket.write("#{k}: #{v}\r\n")}
end
socket.write("\r\n")
body.each {|s| socket.write(s)}
ensure
body.close if body.respond_to? :close
end
end
end
end
end

View file

@ -1,8 +0,0 @@
require 'swiftcore/swiftiplied_mongrel'
module Rack
module Handler
class SwiftipliedMongrel < Handler::Mongrel
end
end
end

View file

@ -1,18 +0,0 @@
require "thin"
require "rack/content_length"
require "rack/chunked"
module Rack
module Handler
class Thin
def self.run(app, options={})
app = Rack::Chunked.new(Rack::ContentLength.new(app))
server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
options[:Port] || 8080,
app)
yield server if block_given?
server.start
end
end
end
end

View file

@ -1,73 +0,0 @@
require 'webrick'
require 'stringio'
require 'rack/content_length'
module Rack
module Handler
class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet
def self.run(app, options={})
options[:BindAddress] = options.delete(:Host) if options[:Host]
@server = ::WEBrick::HTTPServer.new(options)
@server.mount "/", Rack::Handler::WEBrick, app
yield @server if block_given?
@server.start
end
def self.shutdown
@server.shutdown
@server = nil
end
def initialize(server, app)
super server
@app = Rack::ContentLength.new(app)
end
def service(req, res)
env = req.meta_vars
env.delete_if { |k, v| v.nil? }
rack_input = StringIO.new(req.body.to_s)
rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
env.update({"rack.version" => Rack::VERSION,
"rack.input" => rack_input,
"rack.errors" => $stderr,
"rack.multithread" => true,
"rack.multiprocess" => false,
"rack.run_once" => false,
"rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
})
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
env["QUERY_STRING"] ||= ""
env["REQUEST_PATH"] ||= "/"
unless env["PATH_INFO"] == ""
path, n = req.request_uri.path, env["SCRIPT_NAME"].length
env["PATH_INFO"] = path[n, path.length-n]
end
status, headers, body = @app.call(env)
begin
res.status = status.to_i
headers.each { |k, vs|
if k.downcase == "set-cookie"
res.cookies.concat vs.split("\n")
else
vs.split("\n").each { |v|
res[k] = v
}
end
}
body.each { |part|
res.body << part
}
ensure
body.close if body.respond_to? :close
end
end
end
end
end

View file

@ -1,19 +0,0 @@
module Rack
class Head
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
if env["REQUEST_METHOD"] == "HEAD"
[status, headers, []]
else
[status, headers, body]
end
end
end
end

View file

@ -1,567 +0,0 @@
require 'rack/utils'
module Rack
# Rack::Lint validates your application and the requests and
# responses according to the Rack spec.
class Lint
def initialize(app)
@app = app
@content_length = nil
end
# :stopdoc:
class LintError < RuntimeError; end
module Assertion
def assert(message, &block)
unless block.call
raise LintError, message
end
end
end
include Assertion
## 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+.
def call(env=nil)
dup._call(env)
end
def _call(env)
## It takes exactly one argument, the *environment*
assert("No env given") { env }
check_env env
env['rack.input'] = InputWrapper.new(env['rack.input'])
env['rack.errors'] = ErrorWrapper.new(env['rack.errors'])
## and returns an Array of exactly three values:
status, headers, @body = @app.call(env)
## The *status*,
check_status status
## the *headers*,
check_headers headers
## and the *body*.
check_content_type status, headers
check_content_length status, headers
@head_request = env["REQUEST_METHOD"] == "HEAD"
[status, headers, self]
end
## == The Environment
def check_env(env)
## The environment must be an instance of Hash that includes
## CGI-like headers. The application is free to modify the
## environment.
assert("env #{env.inspect} is not a Hash, but #{env.class}") {
env.kind_of? Hash
}
##
## 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. This value may be
## percent-encoded when I originating from
## a URL.
## <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 [1,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).
##
## Additional environment specifications have approved to
## standardized middleware APIs. None of these are required to
## be implemented by the server.
## <tt>rack.session</tt>:: A hash like interface for storing request session data.
## The store must implement:
if session = env['rack.session']
## store(key, value) (aliased as []=);
assert("session #{session.inspect} must respond to store and []=") {
session.respond_to?(:store) && session.respond_to?(:[]=)
}
## fetch(key, default = nil) (aliased as []);
assert("session #{session.inspect} must respond to fetch and []") {
session.respond_to?(:fetch) && session.respond_to?(:[])
}
## delete(key);
assert("session #{session.inspect} must respond to delete") {
session.respond_to?(:delete)
}
## clear;
assert("session #{session.inspect} must respond to clear") {
session.respond_to?(:clear)
}
end
## <tt>rack.logger</tt>:: A common object interface for logging messages.
## The object must implement:
if logger = env['rack.logger']
## info(message, &block)
assert("logger #{logger.inspect} must respond to info") {
logger.respond_to?(:info)
}
## debug(message, &block)
assert("logger #{logger.inspect} must respond to debug") {
logger.respond_to?(:debug)
}
## warn(message, &block)
assert("logger #{logger.inspect} must respond to warn") {
logger.respond_to?(:warn)
}
## error(message, &block)
assert("logger #{logger.inspect} must respond to error") {
logger.respond_to?(:error)
}
## fatal(message, &block)
assert("logger #{logger.inspect} must respond to fatal") {
logger.respond_to?(:fatal)
}
end
## 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 other
## accepted specifications and must not be used otherwise.
##
%w[REQUEST_METHOD SERVER_NAME SERVER_PORT
QUERY_STRING
rack.version rack.input rack.errors
rack.multithread rack.multiprocess rack.run_once].each { |header|
assert("env missing required key #{header}") { env.include? header }
}
## 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>).
%w[HTTP_CONTENT_TYPE HTTP_CONTENT_LENGTH].each { |header|
assert("env contains #{header}, must use #{header[5,-1]}") {
not env.include? header
}
}
## The CGI keys (named without a period) must have String values.
env.each { |key, value|
next if key.include? "." # Skip extensions
assert("env variable #{key} has non-string value #{value.inspect}") {
value.kind_of? String
}
}
##
## There are the following restrictions:
## * <tt>rack.version</tt> must be an array of Integers.
assert("rack.version must be an Array, was #{env["rack.version"].class}") {
env["rack.version"].kind_of? Array
}
## * <tt>rack.url_scheme</tt> must either be +http+ or +https+.
assert("rack.url_scheme unknown: #{env["rack.url_scheme"].inspect}") {
%w[http https].include? env["rack.url_scheme"]
}
## * There must be a valid input stream in <tt>rack.input</tt>.
check_input env["rack.input"]
## * There must be a valid error stream in <tt>rack.errors</tt>.
check_error env["rack.errors"]
## * The <tt>REQUEST_METHOD</tt> must be a valid token.
assert("REQUEST_METHOD unknown: #{env["REQUEST_METHOD"]}") {
env["REQUEST_METHOD"] =~ /\A[0-9A-Za-z!\#$%&'*+.^_`|~-]+\z/
}
## * The <tt>SCRIPT_NAME</tt>, if non-empty, must start with <tt>/</tt>
assert("SCRIPT_NAME must start with /") {
!env.include?("SCRIPT_NAME") ||
env["SCRIPT_NAME"] == "" ||
env["SCRIPT_NAME"] =~ /\A\//
}
## * The <tt>PATH_INFO</tt>, if non-empty, must start with <tt>/</tt>
assert("PATH_INFO must start with /") {
!env.include?("PATH_INFO") ||
env["PATH_INFO"] == "" ||
env["PATH_INFO"] =~ /\A\//
}
## * The <tt>CONTENT_LENGTH</tt>, if given, must consist of digits only.
assert("Invalid CONTENT_LENGTH: #{env["CONTENT_LENGTH"]}") {
!env.include?("CONTENT_LENGTH") || env["CONTENT_LENGTH"] =~ /\A\d+\z/
}
## * 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.
assert("One of SCRIPT_NAME or PATH_INFO must be set (make PATH_INFO '/' if SCRIPT_NAME is empty)") {
env["SCRIPT_NAME"] || env["PATH_INFO"]
}
## <tt>SCRIPT_NAME</tt> never should be <tt>/</tt>, but instead be empty.
assert("SCRIPT_NAME cannot be '/', make it '' and PATH_INFO '/'") {
env["SCRIPT_NAME"] != "/"
}
end
## === The Input Stream
##
## The input stream is an IO-like object which contains the raw HTTP
## POST data.
def check_input(input)
## When applicable, its external encoding must be "ASCII-8BIT" and it
## must be opened in binary mode, for Ruby 1.9 compatibility.
assert("rack.input #{input} does not have ASCII-8BIT as its external encoding") {
input.external_encoding.name == "ASCII-8BIT"
} if input.respond_to?(:external_encoding)
assert("rack.input #{input} is not opened in binary mode") {
input.binmode?
} if input.respond_to?(:binmode?)
## The input stream must respond to +gets+, +each+, +read+ and +rewind+.
[:gets, :each, :read, :rewind].each { |method|
assert("rack.input #{input} does not respond to ##{method}") {
input.respond_to? method
}
}
end
class InputWrapper
include Assertion
def initialize(input)
@input = input
end
## * +gets+ must be called without arguments and return a string,
## or +nil+ on EOF.
def gets(*args)
assert("rack.input#gets called with arguments") { args.size == 0 }
v = @input.gets
assert("rack.input#gets didn't return a String") {
v.nil? or v.kind_of? String
}
v
end
## * +read+ behaves like IO#read. Its signature is <tt>read([length, [buffer]])</tt>.
## If given, +length+ must be an non-negative Integer (>= 0) or +nil+, and +buffer+ must
## be a String and may not be nil. If +length+ is given and not nil, then this method
## reads at most +length+ bytes from the input stream. If +length+ is not given or nil,
## then this method reads all data until EOF.
## When EOF is reached, this method returns nil if +length+ is given and not nil, or ""
## if +length+ is not given or is nil.
## If +buffer+ is given, then the read data will be placed into +buffer+ instead of a
## newly created String object.
def read(*args)
assert("rack.input#read called with too many arguments") {
args.size <= 2
}
if args.size >= 1
assert("rack.input#read called with non-integer and non-nil length") {
args.first.kind_of?(Integer) || args.first.nil?
}
assert("rack.input#read called with a negative length") {
args.first.nil? || args.first >= 0
}
end
if args.size >= 2
assert("rack.input#read called with non-String buffer") {
args[1].kind_of?(String)
}
end
v = @input.read(*args)
assert("rack.input#read didn't return nil or a String") {
v.nil? or v.kind_of? String
}
if args[0].nil?
assert("rack.input#read(nil) returned nil on EOF") {
!v.nil?
}
end
v
end
## * +each+ must be called without arguments and only yield Strings.
def each(*args)
assert("rack.input#each called with arguments") { args.size == 0 }
@input.each { |line|
assert("rack.input#each didn't yield a String") {
line.kind_of? String
}
yield line
}
end
## * +rewind+ must be called without arguments. It rewinds the input
## stream back to the beginning. It must not raise Errno::ESPIPE:
## that is, it may not be a pipe or a socket. Therefore, handler
## developers must buffer the input data into some rewindable object
## if the underlying input stream is not rewindable.
def rewind(*args)
assert("rack.input#rewind called with arguments") { args.size == 0 }
assert("rack.input#rewind raised Errno::ESPIPE") {
begin
@input.rewind
true
rescue Errno::ESPIPE
false
end
}
end
## * +close+ must never be called on the input stream.
def close(*args)
assert("rack.input#close must not be called") { false }
end
end
## === The Error Stream
def check_error(error)
## The error stream must respond to +puts+, +write+ and +flush+.
[:puts, :write, :flush].each { |method|
assert("rack.error #{error} does not respond to ##{method}") {
error.respond_to? method
}
}
end
class ErrorWrapper
include Assertion
def initialize(error)
@error = error
end
## * +puts+ must be called with a single argument that responds to +to_s+.
def puts(str)
@error.puts str
end
## * +write+ must be called with a single argument that is a String.
def write(str)
assert("rack.errors#write not called with a String") { str.kind_of? String }
@error.write str
end
## * +flush+ must be called without arguments and must be called
## in order to make the error appear for sure.
def flush
@error.flush
end
## * +close+ must never be called on the error stream.
def close(*args)
assert("rack.errors#close must not be called") { false }
end
end
## == The Response
## === The Status
def check_status(status)
## This is an HTTP status. When parsed as integer (+to_i+), it must be
## greater than or equal to 100.
assert("Status must be >=100 seen as integer") { status.to_i >= 100 }
end
## === The Headers
def check_headers(header)
## The header must respond to +each+, and yield values of key and value.
assert("headers object should respond to #each, but doesn't (got #{header.class} as headers)") {
header.respond_to? :each
}
header.each { |key, value|
## The header keys must be Strings.
assert("header key must be a string, was #{key.class}") {
key.kind_of? String
}
## The header must not contain a +Status+ key,
assert("header must not contain Status") { key.downcase != "status" }
## contain keys with <tt>:</tt> or newlines in their name,
assert("header names must not contain : or \\n") { key !~ /[:\n]/ }
## contain keys names that end in <tt>-</tt> or <tt>_</tt>,
assert("header names must not end in - or _") { key !~ /[-_]\z/ }
## but only contain keys that consist of
## letters, digits, <tt>_</tt> or <tt>-</tt> and start with a letter.
assert("invalid header name: #{key}") { key =~ /\A[a-zA-Z][a-zA-Z0-9_-]*\z/ }
## The values of the header must be Strings,
assert("a header value must be a String, but the value of " +
"'#{key}' is a #{value.class}") { value.kind_of? String }
## consisting of lines (for multiple header values, e.g. multiple
## <tt>Set-Cookie</tt> values) seperated by "\n".
value.split("\n").each { |item|
## The lines must not contain characters below 037.
assert("invalid header value #{key}: #{item.inspect}") {
item !~ /[\000-\037]/
}
}
}
end
## === The Content-Type
def check_content_type(status, headers)
headers.each { |key, value|
## 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.
if key.downcase == "content-type"
assert("Content-Type header found in #{status} response, not allowed") {
not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
}
return
end
}
assert("No Content-Type header found") {
Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
}
end
## === The Content-Length
def check_content_length(status, headers)
headers.each { |key, value|
if key.downcase == 'content-length'
## There must not be a <tt>Content-Length</tt> header when the
## +Status+ is 1xx, 204 or 304.
assert("Content-Length header found in #{status} response, not allowed") {
not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
}
@content_length = value
end
}
end
def verify_content_length(bytes)
if @head_request
assert("Response body was given for HEAD request, but should be empty") {
bytes == 0
}
elsif @content_length
assert("Content-Length header was #{@content_length}, but should be #{bytes}") {
@content_length == bytes.to_s
}
end
end
## === The Body
def each
@closed = false
bytes = 0
## The Body must respond to +each+
assert("Response body must respond to each") do
@body.respond_to?(:each)
end
@body.each { |part|
## and must only yield String values.
assert("Body yielded non-string value #{part.inspect}") {
part.kind_of? String
}
bytes += Rack::Utils.bytesize(part)
yield part
}
verify_content_length(bytes)
##
## The Body itself should not be an instance of String, as this will
## break in Ruby 1.9.
##
## If the Body responds to +close+, it will be called after iteration.
# XXX howto: assert("Body has not been closed") { @closed }
##
## If the Body responds to +to_path+, it must return a String
## identifying the location of a file whose contents are identical
## to that produced by calling +each+; this may be used by the
## server as an alternative, possibly more efficient way to
## transport the response.
if @body.respond_to?(:to_path)
assert("The file identified by body.to_path does not exist") {
::File.exist? @body.to_path
}
end
##
## The Body commonly is an Array of Strings, the application
## instance itself, or a File-like object.
end
def close
@closed = true
@body.close if @body.respond_to?(:close)
end
# :startdoc:
end
end
## == 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.

View file

@ -1,65 +0,0 @@
require 'zlib'
require 'rack/request'
require 'rack/response'
module Rack
# Paste has a Pony, Rack has a Lobster!
class Lobster
LobsterString = Zlib::Inflate.inflate("eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2
P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0
t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ
I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==".delete("\n ").unpack("m*")[0])
LambdaLobster = lambda { |env|
if env["QUERY_STRING"].include?("flip")
lobster = LobsterString.split("\n").
map { |line| line.ljust(42).reverse }.
join("\n")
href = "?"
else
lobster = LobsterString
href = "?flip"
end
content = ["<title>Lobstericious!</title>",
"<pre>", lobster, "</pre>",
"<a href='#{href}'>flip!</a>"]
length = content.inject(0) { |a,e| a+e.size }.to_s
[200, {"Content-Type" => "text/html", "Content-Length" => length}, content]
}
def call(env)
req = Request.new(env)
if req.GET["flip"] == "left"
lobster = LobsterString.split("\n").
map { |line| line.ljust(42).reverse }.
join("\n")
href = "?flip=right"
elsif req.GET["flip"] == "crash"
raise "Lobster crashed"
else
lobster = LobsterString
href = "?flip=left"
end
res = Response.new
res.write "<title>Lobstericious!</title>"
res.write "<pre>"
res.write lobster
res.write "</pre>"
res.write "<p><a href='#{href}'>flip!</a></p>"
res.write "<p><a href='?flip=crash'>crash!</a></p>"
res.finish
end
end
end
if $0 == __FILE__
require 'rack'
require 'rack/showexceptions'
Rack::Handler::WEBrick.run \
Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster.new)),
:Port => 9292
end

View file

@ -1,18 +0,0 @@
require 'thread'
module Rack
class Lock
FLAG = 'rack.multithread'.freeze
def initialize(app, lock = Mutex.new)
@app, @lock = app, lock
end
def call(env)
old, env[FLAG] = env[FLAG], false
@lock.synchronize { @app.call(env) }
ensure
env[FLAG] = old
end
end
end

View file

@ -1,20 +0,0 @@
require 'logger'
module Rack
# Sets up rack.logger to write to rack.errors stream
class Logger
def initialize(app, level = ::Logger::INFO)
@app, @level = app, level
end
def call(env)
logger = ::Logger.new(env['rack.errors'])
logger.level = @level
env['rack.logger'] = logger
@app.call(env)
ensure
logger.close
end
end
end

View file

@ -1,27 +0,0 @@
module Rack
class MethodOverride
HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS)
METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze
def initialize(app)
@app = app
end
def call(env)
if env["REQUEST_METHOD"] == "POST"
req = Request.new(env)
method = req.POST[METHOD_OVERRIDE_PARAM_KEY] ||
env[HTTP_METHOD_OVERRIDE_HEADER]
method = method.to_s.upcase
if HTTP_METHODS.include?(method)
env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
env["REQUEST_METHOD"] = method
end
end
@app.call(env)
end
end
end

View file

@ -1,208 +0,0 @@
module Rack
module Mime
# Returns String with mime type if found, otherwise use +fallback+.
# +ext+ should be filename extension in the '.ext' format that
# File.extname(file) returns.
# +fallback+ may be any object
#
# Also see the documentation for MIME_TYPES
#
# Usage:
# Rack::Mime.mime_type('.foo')
#
# This is a shortcut for:
# Rack::Mime::MIME_TYPES.fetch('.foo', 'application/octet-stream')
def mime_type(ext, fallback='application/octet-stream')
MIME_TYPES.fetch(ext.to_s.downcase, fallback)
end
module_function :mime_type
# List of most common mime-types, selected various sources
# according to their usefulness in a webserving scope for Ruby
# users.
#
# To amend this list with your local mime.types list you can use:
#
# require 'webrick/httputils'
# list = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types')
# Rack::Mime::MIME_TYPES.merge!(list)
#
# To add the list mongrel provides, use:
#
# require 'mongrel/handlers'
# Rack::Mime::MIME_TYPES.merge!(Mongrel::DirHandler::MIME_TYPES)
MIME_TYPES = {
".3gp" => "video/3gpp",
".a" => "application/octet-stream",
".ai" => "application/postscript",
".aif" => "audio/x-aiff",
".aiff" => "audio/x-aiff",
".asc" => "application/pgp-signature",
".asf" => "video/x-ms-asf",
".asm" => "text/x-asm",
".asx" => "video/x-ms-asf",
".atom" => "application/atom+xml",
".au" => "audio/basic",
".avi" => "video/x-msvideo",
".bat" => "application/x-msdownload",
".bin" => "application/octet-stream",
".bmp" => "image/bmp",
".bz2" => "application/x-bzip2",
".c" => "text/x-c",
".cab" => "application/vnd.ms-cab-compressed",
".cc" => "text/x-c",
".chm" => "application/vnd.ms-htmlhelp",
".class" => "application/octet-stream",
".com" => "application/x-msdownload",
".conf" => "text/plain",
".cpp" => "text/x-c",
".crt" => "application/x-x509-ca-cert",
".css" => "text/css",
".csv" => "text/csv",
".cxx" => "text/x-c",
".deb" => "application/x-debian-package",
".der" => "application/x-x509-ca-cert",
".diff" => "text/x-diff",
".djv" => "image/vnd.djvu",
".djvu" => "image/vnd.djvu",
".dll" => "application/x-msdownload",
".dmg" => "application/octet-stream",
".doc" => "application/msword",
".dot" => "application/msword",
".dtd" => "application/xml-dtd",
".dvi" => "application/x-dvi",
".ear" => "application/java-archive",
".eml" => "message/rfc822",
".eps" => "application/postscript",
".exe" => "application/x-msdownload",
".f" => "text/x-fortran",
".f77" => "text/x-fortran",
".f90" => "text/x-fortran",
".flv" => "video/x-flv",
".for" => "text/x-fortran",
".gem" => "application/octet-stream",
".gemspec" => "text/x-script.ruby",
".gif" => "image/gif",
".gz" => "application/x-gzip",
".h" => "text/x-c",
".htc" => "text/x-component",
".hh" => "text/x-c",
".htm" => "text/html",
".html" => "text/html",
".ico" => "image/vnd.microsoft.icon",
".ics" => "text/calendar",
".ifb" => "text/calendar",
".iso" => "application/octet-stream",
".jar" => "application/java-archive",
".java" => "text/x-java-source",
".jnlp" => "application/x-java-jnlp-file",
".jpeg" => "image/jpeg",
".jpg" => "image/jpeg",
".js" => "application/javascript",
".json" => "application/json",
".log" => "text/plain",
".m3u" => "audio/x-mpegurl",
".m4v" => "video/mp4",
".man" => "text/troff",
".manifest"=> "text/cache-manifest",
".mathml" => "application/mathml+xml",
".mbox" => "application/mbox",
".mdoc" => "text/troff",
".me" => "text/troff",
".mid" => "audio/midi",
".midi" => "audio/midi",
".mime" => "message/rfc822",
".mml" => "application/mathml+xml",
".mng" => "video/x-mng",
".mov" => "video/quicktime",
".mp3" => "audio/mpeg",
".mp4" => "video/mp4",
".mp4v" => "video/mp4",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".ms" => "text/troff",
".msi" => "application/x-msdownload",
".odp" => "application/vnd.oasis.opendocument.presentation",
".ods" => "application/vnd.oasis.opendocument.spreadsheet",
".odt" => "application/vnd.oasis.opendocument.text",
".ogg" => "application/ogg",
".ogv" => "video/ogg",
".p" => "text/x-pascal",
".pas" => "text/x-pascal",
".pbm" => "image/x-portable-bitmap",
".pdf" => "application/pdf",
".pem" => "application/x-x509-ca-cert",
".pgm" => "image/x-portable-graymap",
".pgp" => "application/pgp-encrypted",
".pkg" => "application/octet-stream",
".pl" => "text/x-script.perl",
".pm" => "text/x-script.perl-module",
".png" => "image/png",
".pnm" => "image/x-portable-anymap",
".ppm" => "image/x-portable-pixmap",
".pps" => "application/vnd.ms-powerpoint",
".ppt" => "application/vnd.ms-powerpoint",
".ps" => "application/postscript",
".psd" => "image/vnd.adobe.photoshop",
".py" => "text/x-script.python",
".qt" => "video/quicktime",
".ra" => "audio/x-pn-realaudio",
".rake" => "text/x-script.ruby",
".ram" => "audio/x-pn-realaudio",
".rar" => "application/x-rar-compressed",
".rb" => "text/x-script.ruby",
".rdf" => "application/rdf+xml",
".roff" => "text/troff",
".rpm" => "application/x-redhat-package-manager",
".rss" => "application/rss+xml",
".rtf" => "application/rtf",
".ru" => "text/x-script.ruby",
".s" => "text/x-asm",
".sgm" => "text/sgml",
".sgml" => "text/sgml",
".sh" => "application/x-sh",
".sig" => "application/pgp-signature",
".snd" => "audio/basic",
".so" => "application/octet-stream",
".svg" => "image/svg+xml",
".svgz" => "image/svg+xml",
".swf" => "application/x-shockwave-flash",
".t" => "text/troff",
".tar" => "application/x-tar",
".tbz" => "application/x-bzip-compressed-tar",
".tcl" => "application/x-tcl",
".tex" => "application/x-tex",
".texi" => "application/x-texinfo",
".texinfo" => "application/x-texinfo",
".text" => "text/plain",
".tif" => "image/tiff",
".tiff" => "image/tiff",
".torrent" => "application/x-bittorrent",
".tr" => "text/troff",
".txt" => "text/plain",
".vcf" => "text/x-vcard",
".vcs" => "text/x-vcalendar",
".vrml" => "model/vrml",
".war" => "application/java-archive",
".wav" => "audio/x-wav",
".webm" => "video/webm",
".wma" => "audio/x-ms-wma",
".wmv" => "video/x-ms-wmv",
".wmx" => "video/x-ms-wmx",
".wrl" => "model/vrml",
".wsdl" => "application/wsdl+xml",
".xbm" => "image/x-xbitmap",
".xhtml" => "application/xhtml+xml",
".xls" => "application/vnd.ms-excel",
".xml" => "application/xml",
".xpm" => "image/x-xpixmap",
".xsl" => "application/xml",
".xslt" => "application/xslt+xml",
".yaml" => "text/yaml",
".yml" => "text/yaml",
".zip" => "application/zip",
}
end
end

View file

@ -1,190 +0,0 @@
require 'uri'
require 'stringio'
require 'rack'
require 'rack/lint'
require 'rack/utils'
require 'rack/response'
module Rack
# Rack::MockRequest helps testing your Rack application without
# actually using HTTP.
#
# After performing a request on a URL with get/post/put/delete, it
# returns a MockResponse with useful helper methods for effective
# testing.
#
# You can pass a hash with additional configuration to the
# get/post/put/delete.
# <tt>:input</tt>:: A String or IO-like to be used as rack.input.
# <tt>:fatal</tt>:: Raise a FatalWarning if the app writes to rack.errors.
# <tt>:lint</tt>:: If true, wrap the application in a Rack::Lint.
class MockRequest
class FatalWarning < RuntimeError
end
class FatalWarner
def puts(warning)
raise FatalWarning, warning
end
def write(warning)
raise FatalWarning, warning
end
def flush
end
def string
""
end
end
DEFAULT_ENV = {
"rack.version" => Rack::VERSION,
"rack.input" => StringIO.new,
"rack.errors" => StringIO.new,
"rack.multithread" => true,
"rack.multiprocess" => true,
"rack.run_once" => false,
}
def initialize(app)
@app = app
end
def get(uri, opts={}) request("GET", uri, opts) end
def post(uri, opts={}) request("POST", uri, opts) end
def put(uri, opts={}) request("PUT", uri, opts) end
def delete(uri, opts={}) request("DELETE", uri, opts) end
def request(method="GET", uri="", opts={})
env = self.class.env_for(uri, opts.merge(:method => method))
if opts[:lint]
app = Rack::Lint.new(@app)
else
app = @app
end
errors = env["rack.errors"]
MockResponse.new(*(app.call(env) + [errors]))
end
# Return the Rack environment used for a request to +uri+.
def self.env_for(uri="", opts={})
uri = URI(uri)
uri.path = "/#{uri.path}" unless uri.path[0] == ?/
env = DEFAULT_ENV.dup
env["REQUEST_METHOD"] = opts[:method] ? opts[:method].to_s.upcase : "GET"
env["SERVER_NAME"] = uri.host || "example.org"
env["SERVER_PORT"] = uri.port ? uri.port.to_s : "80"
env["QUERY_STRING"] = uri.query.to_s
env["PATH_INFO"] = (!uri.path || uri.path.empty?) ? "/" : uri.path
env["rack.url_scheme"] = uri.scheme || "http"
env["HTTPS"] = env["rack.url_scheme"] == "https" ? "on" : "off"
env["SCRIPT_NAME"] = opts[:script_name] || ""
if opts[:fatal]
env["rack.errors"] = FatalWarner.new
else
env["rack.errors"] = StringIO.new
end
if params = opts[:params]
if env["REQUEST_METHOD"] == "GET"
params = Utils.parse_nested_query(params) if params.is_a?(String)
params.update(Utils.parse_nested_query(env["QUERY_STRING"]))
env["QUERY_STRING"] = Utils.build_nested_query(params)
elsif !opts.has_key?(:input)
opts["CONTENT_TYPE"] = "application/x-www-form-urlencoded"
if params.is_a?(Hash)
if data = Utils::Multipart.build_multipart(params)
opts[:input] = data
opts["CONTENT_LENGTH"] ||= data.length.to_s
opts["CONTENT_TYPE"] = "multipart/form-data; boundary=#{Utils::Multipart::MULTIPART_BOUNDARY}"
else
opts[:input] = Utils.build_nested_query(params)
end
else
opts[:input] = params
end
end
end
empty_str = ""
empty_str.force_encoding("ASCII-8BIT") if empty_str.respond_to? :force_encoding
opts[:input] ||= empty_str
if String === opts[:input]
rack_input = StringIO.new(opts[:input])
else
rack_input = opts[:input]
end
rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
env['rack.input'] = rack_input
env["CONTENT_LENGTH"] ||= env["rack.input"].length.to_s
opts.each { |field, value|
env[field] = value if String === field
}
env
end
end
# Rack::MockResponse provides useful helpers for testing your apps.
# Usually, you don't create the MockResponse on your own, but use
# MockRequest.
class MockResponse
def initialize(status, headers, body, errors=StringIO.new(""))
@status = status.to_i
@original_headers = headers
@headers = Rack::Utils::HeaderHash.new
headers.each { |field, values|
@headers[field] = values
@headers[field] = "" if values.empty?
}
@body = ""
body.each { |part| @body << part }
@errors = errors.string if errors.respond_to?(:string)
end
# Status
attr_reader :status
# Headers
attr_reader :headers, :original_headers
def [](field)
headers[field]
end
# Body
attr_reader :body
def =~(other)
@body =~ other
end
def match(other)
@body.match other
end
# Errors
attr_accessor :errors
include Response::Helpers
end
end

View file

@ -1,18 +0,0 @@
module Rack
class NullLogger
def initialize(app)
@app = app
end
def call(env)
env['rack.logger'] = self
@app.call(env)
end
def info(progname = nil, &block); end
def debug(progname = nil, &block); end
def warn(progname = nil, &block); end
def error(progname = nil, &block); end
def fatal(progname = nil, &block); end
end
end

View file

@ -1,61 +0,0 @@
require 'uri'
module Rack
# Rack::ForwardRequest gets caught by Rack::Recursive and redirects
# the current request to the app at +url+.
#
# raise ForwardRequest.new("/not-found")
#
class ForwardRequest < Exception
attr_reader :url, :env
def initialize(url, env={})
@url = URI(url)
@env = env
@env["PATH_INFO"] = @url.path
@env["QUERY_STRING"] = @url.query if @url.query
@env["HTTP_HOST"] = @url.host if @url.host
@env["HTTP_PORT"] = @url.port if @url.port
@env["rack.url_scheme"] = @url.scheme if @url.scheme
super "forwarding to #{url}"
end
end
# Rack::Recursive allows applications called down the chain to
# include data from other applications (by using
# <tt>rack['rack.recursive.include'][...]</tt> or raise a
# ForwardRequest to redirect internally.
class Recursive
def initialize(app)
@app = app
end
def call(env)
dup._call(env)
end
def _call(env)
@script_name = env["SCRIPT_NAME"]
@app.call(env.merge('rack.recursive.include' => method(:include)))
rescue ForwardRequest => req
call(env.merge(req.env))
end
def include(env, path)
unless path.index(@script_name) == 0 && (path[@script_name.size] == ?/ ||
path[@script_name.size].nil?)
raise ArgumentError, "can only include below #{@script_name}, not #{path}"
end
env = env.merge("PATH_INFO" => path, "SCRIPT_NAME" => @script_name,
"REQUEST_METHOD" => "GET",
"CONTENT_LENGTH" => "0", "CONTENT_TYPE" => "",
"rack.input" => StringIO.new(""))
@app.call(env)
end
end
end

View file

@ -1,109 +0,0 @@
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
# Rack::Reloader is subject to the terms of an MIT-style license.
# See COPYING or http://www.opensource.org/licenses/mit-license.php.
require 'pathname'
module Rack
# High performant source reloader
#
# This class acts as Rack middleware.
#
# What makes it especially suited for use in a production environment is that
# any file will only be checked once and there will only be made one system
# call stat(2).
#
# Please note that this will not reload files in the background, it does so
# only when actively called.
#
# It is performing a check/reload cycle at the start of every request, but
# also respects a cool down time, during which nothing will be done.
class Reloader
def initialize(app, cooldown = 10, backend = Stat)
@app = app
@cooldown = cooldown
@last = (Time.now - cooldown)
@cache = {}
@mtimes = {}
extend backend
end
def call(env)
if @cooldown and Time.now > @last + @cooldown
if Thread.list.size > 1
Thread.exclusive{ reload! }
else
reload!
end
@last = Time.now
end
@app.call(env)
end
def reload!(stderr = $stderr)
rotation do |file, mtime|
previous_mtime = @mtimes[file] ||= mtime
safe_load(file, mtime, stderr) if mtime > previous_mtime
end
end
# A safe Kernel::load, issuing the hooks depending on the results
def safe_load(file, mtime, stderr = $stderr)
load(file)
stderr.puts "#{self.class}: reloaded `#{file}'"
file
rescue LoadError, SyntaxError => ex
stderr.puts ex
ensure
@mtimes[file] = mtime
end
module Stat
def rotation
files = [$0, *$LOADED_FEATURES].uniq
paths = ['./', *$LOAD_PATH].uniq
files.map{|file|
next if file =~ /\.(so|bundle)$/ # cannot reload compiled files
found, stat = figure_path(file, paths)
next unless found && stat && mtime = stat.mtime
@cache[file] = found
yield(found, mtime)
}.compact
end
# Takes a relative or absolute +file+ name, a couple possible +paths+ that
# the +file+ might reside in. Returns the full path and File::Stat for the
# path.
def figure_path(file, paths)
found = @cache[file]
found = file if !found and Pathname.new(file).absolute?
found, stat = safe_stat(found)
return found, stat if found
paths.find do |possible_path|
path = ::File.join(possible_path, file)
found, stat = safe_stat(path)
return ::File.expand_path(found), stat if found
end
return false, false
end
def safe_stat(file)
return unless file
stat = ::File.stat(file)
return file, stat if stat.file?
rescue Errno::ENOENT, Errno::ENOTDIR
@cache.delete(file) and false
end
end
end
end

View file

@ -1,273 +0,0 @@
require 'rack/utils'
module Rack
# Rack::Request provides a convenient interface to a Rack
# environment. It is stateless, the environment +env+ passed to the
# constructor will be directly modified.
#
# req = Rack::Request.new(env)
# req.post?
# req.params["data"]
#
# The environment hash passed will store a reference to the Request object
# instantiated so that it will only instantiate if an instance of the Request
# object doesn't already exist.
class Request
# The environment of the request.
attr_reader :env
def initialize(env)
@env = env
end
def body; @env["rack.input"] end
def scheme; @env["rack.url_scheme"] end
def script_name; @env["SCRIPT_NAME"].to_s end
def path_info; @env["PATH_INFO"].to_s end
def port; @env["SERVER_PORT"].to_i end
def request_method; @env["REQUEST_METHOD"] end
def query_string; @env["QUERY_STRING"].to_s end
def content_length; @env['CONTENT_LENGTH'] end
def content_type; @env['CONTENT_TYPE'] end
def session; @env['rack.session'] ||= {} end
def session_options; @env['rack.session.options'] ||= {} end
def logger; @env['rack.logger'] end
# The media type (type/subtype) portion of the CONTENT_TYPE header
# without any media type parameters. e.g., when CONTENT_TYPE is
# "text/plain;charset=utf-8", the media-type is "text/plain".
#
# For more information on the use of media types in HTTP, see:
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
def media_type
content_type && content_type.split(/\s*[;,]\s*/, 2).first.downcase
end
# The media type parameters provided in CONTENT_TYPE as a Hash, or
# an empty Hash if no CONTENT_TYPE or media-type parameters were
# provided. e.g., when the CONTENT_TYPE is "text/plain;charset=utf-8",
# this method responds with the following Hash:
# { 'charset' => 'utf-8' }
def media_type_params
return {} if content_type.nil?
content_type.split(/\s*[;,]\s*/)[1..-1].
collect { |s| s.split('=', 2) }.
inject({}) { |hash,(k,v)| hash[k.downcase] = v ; hash }
end
# The character set of the request body if a "charset" media type
# parameter was given, or nil if no "charset" was specified. Note
# that, per RFC2616, text/* media types that specify no explicit
# charset are to be considered ISO-8859-1.
def content_charset
media_type_params['charset']
end
def host_with_port
if forwarded = @env["HTTP_X_FORWARDED_HOST"]
forwarded.split(/,\s?/).last
else
@env['HTTP_HOST'] || "#{@env['SERVER_NAME'] || @env['SERVER_ADDR']}:#{@env['SERVER_PORT']}"
end
end
def host
# Remove port number.
host_with_port.to_s.gsub(/:\d+\z/, '')
end
def script_name=(s); @env["SCRIPT_NAME"] = s.to_s end
def path_info=(s); @env["PATH_INFO"] = s.to_s end
def delete?; request_method == "DELETE" end
def get?; request_method == "GET" end
def head?; request_method == "HEAD" end
def options?; request_method == "OPTIONS" end
def post?; request_method == "POST" end
def put?; request_method == "PUT" end
def trace?; request_method == "TRACE" end
# The set of form-data media-types. Requests that do not indicate
# one of the media types presents in this list will not be eligible
# for form-data / param parsing.
FORM_DATA_MEDIA_TYPES = [
'application/x-www-form-urlencoded',
'multipart/form-data'
]
# The set of media-types. Requests that do not indicate
# one of the media types presents in this list will not be eligible
# for param parsing like soap attachments or generic multiparts
PARSEABLE_DATA_MEDIA_TYPES = [
'multipart/related',
'multipart/mixed'
]
# Determine whether the request body contains form-data by checking
# the request Content-Type for one of the media-types:
# "application/x-www-form-urlencoded" or "multipart/form-data". The
# list of form-data media types can be modified through the
# +FORM_DATA_MEDIA_TYPES+ array.
#
# A request body is also assumed to contain form-data when no
# Content-Type header is provided and the request_method is POST.
def form_data?
type = media_type
meth = env["rack.methodoverride.original_method"] || env['REQUEST_METHOD']
(meth == 'POST' && type.nil?) || FORM_DATA_MEDIA_TYPES.include?(type)
end
# Determine whether the request body contains data by checking
# the request media_type against registered parse-data media-types
def parseable_data?
PARSEABLE_DATA_MEDIA_TYPES.include?(media_type)
end
# Returns the data recieved in the query string.
def GET
if @env["rack.request.query_string"] == query_string
@env["rack.request.query_hash"]
else
@env["rack.request.query_string"] = query_string
@env["rack.request.query_hash"] = parse_query(query_string)
end
end
# Returns the data recieved in the request body.
#
# This method support both application/x-www-form-urlencoded and
# multipart/form-data.
def POST
if @env["rack.input"].nil?
raise "Missing rack.input"
elsif @env["rack.request.form_input"].eql? @env["rack.input"]
@env["rack.request.form_hash"]
elsif form_data? || parseable_data?
@env["rack.request.form_input"] = @env["rack.input"]
unless @env["rack.request.form_hash"] = parse_multipart(env)
form_vars = @env["rack.input"].read
# Fix for Safari Ajax postings that always append \0
form_vars.sub!(/\0\z/, '')
@env["rack.request.form_vars"] = form_vars
@env["rack.request.form_hash"] = parse_query(form_vars)
@env["rack.input"].rewind
end
@env["rack.request.form_hash"]
else
{}
end
end
# The union of GET and POST data.
def params
self.GET.update(self.POST)
rescue EOFError => e
self.GET
end
# shortcut for request.params[key]
def [](key)
params[key.to_s]
end
# shortcut for request.params[key] = value
def []=(key, value)
params[key.to_s] = value
end
# like Hash#values_at
def values_at(*keys)
keys.map{|key| params[key] }
end
# the referer of the client or '/'
def referer
@env['HTTP_REFERER'] || '/'
end
alias referrer referer
def user_agent
@env['HTTP_USER_AGENT']
end
def cookies
return {} unless @env["HTTP_COOKIE"]
if @env["rack.request.cookie_string"] == @env["HTTP_COOKIE"]
@env["rack.request.cookie_hash"]
else
@env["rack.request.cookie_string"] = @env["HTTP_COOKIE"]
# According to RFC 2109:
# If multiple cookies satisfy the criteria above, they are ordered in
# the Cookie header such that those with more specific Path attributes
# precede those with less specific. Ordering with respect to other
# attributes (e.g., Domain) is unspecified.
@env["rack.request.cookie_hash"] =
Utils.parse_query(@env["rack.request.cookie_string"], ';,').inject({}) {|h,(k,v)|
h[k] = Array === v ? v.first : v
h
}
end
end
def xhr?
@env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
end
# Tries to return a remake of the original request URL as a string.
def url
url = scheme + "://"
url << host
if scheme == "https" && port != 443 ||
scheme == "http" && port != 80
url << ":#{port}"
end
url << fullpath
url
end
def path
script_name + path_info
end
def fullpath
query_string.empty? ? path : "#{path}?#{query_string}"
end
def accept_encoding
@env["HTTP_ACCEPT_ENCODING"].to_s.split(/,\s*/).map do |part|
m = /^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$/.match(part) # From WEBrick
if m
[m[1], (m[2] || 1.0).to_f]
else
raise "Invalid value for Accept-Encoding: #{part.inspect}"
end
end
end
def ip
if addr = @env['HTTP_X_FORWARDED_FOR']
(addr.split(',').grep(/\d\./).first || @env['REMOTE_ADDR']).to_s.strip
else
@env['REMOTE_ADDR']
end
end
protected
def parse_query(qs)
Utils.parse_nested_query(qs)
end
def parse_multipart(env)
Utils::Multipart.parse_multipart(env)
end
end
end

View file

@ -1,150 +0,0 @@
require 'rack/request'
require 'rack/utils'
require 'time'
module Rack
# Rack::Response provides a convenient interface to create a Rack
# response.
#
# It allows setting of headers and cookies, and provides useful
# defaults (a OK response containing HTML).
#
# You can use Response#write to iteratively generate your response,
# but note that this is buffered by Rack::Response until you call
# +finish+. +finish+ however can take a block inside which calls to
# +write+ are syncronous with the Rack response.
#
# Your application's +call+ should end returning Response#finish.
class Response
attr_accessor :length
def initialize(body=[], status=200, header={}, &block)
@status = status.to_i
@header = Utils::HeaderHash.new({"Content-Type" => "text/html"}.
merge(header))
@writer = lambda { |x| @body << x }
@block = nil
@length = 0
@body = []
if body.respond_to? :to_str
write body.to_str
elsif body.respond_to?(:each)
body.each { |part|
write part.to_s
}
else
raise TypeError, "stringable or iterable required"
end
yield self if block_given?
end
attr_reader :header
attr_accessor :status, :body
def [](key)
header[key]
end
def []=(key, value)
header[key] = value
end
def set_cookie(key, value)
Utils.set_cookie_header!(header, key, value)
end
def delete_cookie(key, value={})
Utils.delete_cookie_header!(header, key, value)
end
def redirect(target, status=302)
self.status = status
self["Location"] = target
end
def finish(&block)
@block = block
if [204, 304].include?(status.to_i)
header.delete "Content-Type"
[status.to_i, header, []]
else
[status.to_i, header, self]
end
end
alias to_a finish # For *response
def each(&callback)
@body.each(&callback)
@writer = callback
@block.call(self) if @block
end
# Append to body and update Content-Length.
#
# NOTE: Do not mix #write and direct #body access!
#
def write(str)
s = str.to_s
@length += Rack::Utils.bytesize(s)
@writer.call s
header["Content-Length"] = @length.to_s
str
end
def close
body.close if body.respond_to?(:close)
end
def empty?
@block == nil && @body.empty?
end
alias headers header
module Helpers
def invalid?; @status < 100 || @status >= 600; end
def informational?; @status >= 100 && @status < 200; end
def successful?; @status >= 200 && @status < 300; end
def redirection?; @status >= 300 && @status < 400; end
def client_error?; @status >= 400 && @status < 500; end
def server_error?; @status >= 500 && @status < 600; end
def ok?; @status == 200; end
def forbidden?; @status == 403; end
def not_found?; @status == 404; end
def redirect?; [301, 302, 303, 307].include? @status; end
def empty?; [201, 204, 304].include? @status; end
# Headers
attr_reader :headers, :original_headers
def include?(header)
!!headers[header]
end
def content_type
headers["Content-Type"]
end
def content_length
cl = headers["Content-Length"]
cl ? cl.to_i : cl
end
def location
headers["Location"]
end
end
include Helpers
end
end

View file

@ -1,104 +0,0 @@
# -*- encoding: binary -*-
require 'tempfile'
require 'rack/utils'
module Rack
# Class which can make any IO object rewindable, including non-rewindable ones. It does
# this by buffering the data into a tempfile, which is rewindable.
#
# rack.input is required to be rewindable, so if your input stream IO is non-rewindable
# by nature (e.g. a pipe or a socket) then you can wrap it in an object of this class
# to easily make it rewindable.
#
# Don't forget to call #close when you're done. This frees up temporary resources that
# RewindableInput uses, though it does *not* close the original IO object.
class RewindableInput
def initialize(io)
@io = io
@rewindable_io = nil
@unlinked = false
end
def gets
make_rewindable unless @rewindable_io
@rewindable_io.gets
end
def read(*args)
make_rewindable unless @rewindable_io
@rewindable_io.read(*args)
end
def each(&block)
make_rewindable unless @rewindable_io
@rewindable_io.each(&block)
end
def rewind
make_rewindable unless @rewindable_io
@rewindable_io.rewind
end
# Closes this RewindableInput object without closing the originally
# wrapped IO oject. Cleans up any temporary resources that this RewindableInput
# has created.
#
# This method may be called multiple times. It does nothing on subsequent calls.
def close
if @rewindable_io
if @unlinked
@rewindable_io.close
else
@rewindable_io.close!
end
@rewindable_io = nil
end
end
private
# Ruby's Tempfile class has a bug. Subclass it and fix it.
class Tempfile < ::Tempfile
def _close
@tmpfile.close if @tmpfile
@data[1] = nil if @data
@tmpfile = nil
end
end
def make_rewindable
# Buffer all data into a tempfile. Since this tempfile is private to this
# RewindableInput object, we chmod it so that nobody else can read or write
# it. On POSIX filesystems we also unlink the file so that it doesn't
# even have a file entry on the filesystem anymore, though we can still
# access it because we have the file handle open.
@rewindable_io = Tempfile.new('RackRewindableInput')
@rewindable_io.chmod(0000)
@rewindable_io.set_encoding(Encoding::BINARY) if @rewindable_io.respond_to?(:set_encoding)
@rewindable_io.binmode
if filesystem_has_posix_semantics?
# Use ::File.unlink as 1.9.1 Tempfile has a bug where unlink closes the file!
::File.unlink @rewindable_io.path
raise 'Unlink failed. IO closed.' if @rewindable_io.closed?
@unlinked = true
end
buffer = ""
while @io.read(1024 * 4, buffer)
entire_buffer_written_out = false
while !entire_buffer_written_out
written = @rewindable_io.write(buffer)
entire_buffer_written_out = written == Rack::Utils.bytesize(buffer)
if !entire_buffer_written_out
buffer.slice!(0 .. written - 1)
end
end
end
@rewindable_io.rewind
end
def filesystem_has_posix_semantics?
RUBY_PLATFORM !~ /(mswin|mingw|cygwin|java)/
end
end
end

View file

@ -1,27 +0,0 @@
module Rack
# Sets an "X-Runtime" response header, indicating the response
# time of the request, in seconds
#
# You can put it right before the application to see the processing
# time, or before all the other middlewares to include time for them,
# too.
class Runtime
def initialize(app, name = nil)
@app = app
@header_name = "X-Runtime"
@header_name << "-#{name}" if name
end
def call(env)
start_time = Time.now
status, headers, body = @app.call(env)
request_time = Time.now - start_time
if !headers.has_key?(@header_name)
headers[@header_name] = "%0.6f" % request_time
end
[status, headers, body]
end
end
end

View file

@ -1,144 +0,0 @@
require 'rack/file'
module Rack
class File #:nodoc:
unless instance_methods(false).include?('to_path')
alias :to_path :path
end
end
# = Sendfile
#
# The Sendfile middleware intercepts responses whose body is being
# served from a file and replaces it with a server specific X-Sendfile
# header. The web server is then responsible for writing the file contents
# to the client. This can dramatically reduce the amount of work required
# by the Ruby backend and takes advantage of the web server's optimized file
# delivery code.
#
# In order to take advantage of this middleware, the response body must
# respond to +to_path+ and the request must include an X-Sendfile-Type
# header. Rack::File and other components implement +to_path+ so there's
# rarely anything you need to do in your application. The X-Sendfile-Type
# header is typically set in your web servers configuration. The following
# sections attempt to document
#
# === Nginx
#
# Nginx supports the X-Accel-Redirect header. This is similar to X-Sendfile
# but requires parts of the filesystem to be mapped into a private URL
# hierarachy.
#
# The following example shows the Nginx configuration required to create
# a private "/files/" area, enable X-Accel-Redirect, and pass the special
# X-Sendfile-Type and X-Accel-Mapping headers to the backend:
#
# location ~ /files/(.*) {
# internal;
# alias /var/www/$1;
# }
#
# location / {
# proxy_redirect off;
#
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#
# proxy_set_header X-Sendfile-Type X-Accel-Redirect;
# proxy_set_header X-Accel-Mapping /files/=/var/www/;
#
# proxy_pass http://127.0.0.1:8080/;
# }
#
# Note that the X-Sendfile-Type header must be set exactly as shown above. The
# X-Accel-Mapping header should specify the name of the private URL pattern,
# followed by an equals sign (=), followed by the location on the file system
# that it maps to. The middleware performs a simple substitution on the
# resulting path.
#
# See Also: http://wiki.codemongers.com/NginxXSendfile
#
# === lighttpd
#
# Lighttpd has supported some variation of the X-Sendfile header for some
# time, although only recent version support X-Sendfile in a reverse proxy
# configuration.
#
# $HTTP["host"] == "example.com" {
# proxy-core.protocol = "http"
# proxy-core.balancer = "round-robin"
# proxy-core.backends = (
# "127.0.0.1:8000",
# "127.0.0.1:8001",
# ...
# )
#
# proxy-core.allow-x-sendfile = "enable"
# proxy-core.rewrite-request = (
# "X-Sendfile-Type" => (".*" => "X-Sendfile")
# )
# }
#
# See Also: http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModProxyCore
#
# === Apache
#
# X-Sendfile is supported under Apache 2.x using a separate module:
#
# http://tn123.ath.cx/mod_xsendfile/
#
# Once the module is compiled and installed, you can enable it using
# XSendFile config directive:
#
# RequestHeader Set X-Sendfile-Type X-Sendfile
# ProxyPassReverse / http://localhost:8001/
# XSendFile on
class Sendfile
F = ::File
def initialize(app, variation=nil)
@app = app
@variation = variation
end
def call(env)
status, headers, body = @app.call(env)
if body.respond_to?(:to_path)
case type = variation(env)
when 'X-Accel-Redirect'
path = F.expand_path(body.to_path)
if url = map_accel_path(env, path)
headers[type] = url
body = []
else
env['rack.errors'] << "X-Accel-Mapping header missing"
end
when 'X-Sendfile', 'X-Lighttpd-Send-File'
path = F.expand_path(body.to_path)
headers[type] = path
body = []
when '', nil
else
env['rack.errors'] << "Unknown x-sendfile variation: '#{variation}'.\n"
end
end
[status, headers, body]
end
private
def variation(env)
@variation ||
env['sendfile.type'] ||
env['HTTP_X_SENDFILE_TYPE']
end
def map_accel_path(env, file)
if mapping = env['HTTP_X_ACCEL_MAPPING']
internal, external = mapping.split('=', 2).map{ |p| p.strip }
file.sub(/^#{internal}/i, external)
end
end
end
end

View file

@ -1,271 +0,0 @@
require 'optparse'
module Rack
class Server
class Options
def parse!(args)
options = {}
opt_parser = OptionParser.new("", 24, ' ') do |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)") {
options[:debug] = true
}
opts.on("-w", "--warn", "turn warnings on for your script") {
options[:warn] = true
}
opts.on("-I", "--include PATH",
"specify $LOAD_PATH (may be used more than once)") { |path|
options[:include] = path.split(":")
}
opts.on("-r", "--require LIBRARY",
"require the library, before executing your script") { |library|
options[:require] = library
}
opts.separator ""
opts.separator "Rack options:"
opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s|
options[: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|
options[:environment] = e
}
opts.on("-D", "--daemonize", "run daemonized in the background") { |d|
options[:daemonize] = d ? true : false
}
opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f|
options[:pid] = 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
puts "Rack #{Rack.version} (Release: #{Rack.release})"
exit
end
end
opt_parser.parse! args
options[:config] = args.last if args.last
options
end
end
# Start a new rack server (like running rackup). This will parse ARGV and
# provide standard ARGV rackup options, defaulting to load 'config.ru'.
#
# Providing an options hash will prevent ARGV parsing and will not include
# any default options.
#
# This method can be used to very easily launch a CGI application, for
# example:
#
# Rack::Server.start(
# :app => lambda do |e|
# [200, {'Content-Type' => 'text/html'}, ['hello world']]
# end,
# :server => 'cgi'
# )
#
# Further options available here are documented on Rack::Server#initialize
def self.start(options = nil)
new(options).start
end
attr_writer :options
# Options may include:
# * :app
# a rack application to run (overrides :config)
# * :config
# a rackup configuration file path to load (.ru)
# * :environment
# this selects the middleware that will be wrapped around
# your application. Default options available are:
# - development: CommonLogger, ShowExceptions, and Lint
# - deployment: CommonLogger
# - none: no extra middleware
# note: when the server is a cgi server, CommonLogger is not included.
# * :server
# choose a specific Rack::Handler, e.g. cgi, fcgi, webrick
# * :daemonize
# if true, the server will daemonize itself (fork, detach, etc)
# * :pid
# path to write a pid file after daemonize
# * :Host
# the host address to bind to (used by supporting Rack::Handler)
# * :Port
# the port to bind to (used by supporting Rack::Handler)
# * :AccessLog
# webrick acess log options (or supporting Rack::Handler)
# * :debug
# turn on debug output ($DEBUG = true)
# * :warn
# turn on warnings ($-w = true)
# * :include
# add given paths to $LOAD_PATH
# * :require
# require the given libraries
def initialize(options = nil)
@options = options
end
def options
@options ||= parse_options(ARGV)
end
def default_options
{
:environment => ENV['RACK_ENV'] || "development",
:pid => nil,
:Port => 9292,
:Host => "0.0.0.0",
:AccessLog => [],
:config => "config.ru"
}
end
def app
@app ||= begin
if !::File.exist? options[:config]
abort "configuration #{options[:config]} not found"
end
app, options = Rack::Builder.parse_file(self.options[:config], opt_parser)
self.options.merge! options
app
end
end
def self.middleware
@middleware ||= begin
m = Hash.new {|h,k| h[k] = []}
m["deployment"].concat [lambda {|server| server.server.name =~ /CGI/ ? nil : [Rack::CommonLogger, $stderr] }]
m["development"].concat m["deployment"] + [[Rack::ShowExceptions], [Rack::Lint]]
m
end
end
def middleware
self.class.middleware
end
def start
if options[:debug]
$DEBUG = true
require 'pp'
p options[:server]
pp wrapped_app
pp app
end
if options[:warn]
$-w = true
end
if includes = options[:include]
$LOAD_PATH.unshift(*includes)
end
if library = options[:require]
require library
end
daemonize_app if options[:daemonize]
write_pid if options[:pid]
trap(:INT) do
if server.respond_to?(:shutdown)
server.shutdown
else
exit
end
end
server.run wrapped_app, options
end
def server
@_server ||= Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
end
private
def parse_options(args)
options = default_options
# Don't evaluate CGI ISINDEX parameters.
# http://hoohoo.ncsa.uiuc.edu/cgi/cl.html
args.clear if ENV.include?("REQUEST_METHOD")
options.merge! opt_parser.parse! args
ENV["RACK_ENV"] = options[:environment]
options
end
def opt_parser
Options.new
end
def build_app(app)
middleware[options[:environment]].reverse_each do |middleware|
middleware = middleware.call(self) if middleware.respond_to?(:call)
next unless middleware
klass = middleware.shift
app = klass.new(app, *middleware)
end
app
end
def wrapped_app
@wrapped_app ||= build_app app
end
def daemonize_app
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
end
def write_pid
::File.open(options[:pid], 'w'){ |f| f.write("#{Process.pid}") }
at_exit { ::File.delete(options[:pid]) if ::File.exist?(options[:pid]) }
end
end
end

View file

@ -1,140 +0,0 @@
# AUTHOR: blink <blinketje@gmail.com>; blink#ruby-lang@irc.freenode.net
# bugrep: Andreas Zehnder
require 'time'
require 'rack/request'
require 'rack/response'
module Rack
module Session
module Abstract
# ID sets up a basic framework for implementing an id based sessioning
# service. Cookies sent to the client for maintaining sessions will only
# contain an id reference. Only #get_session and #set_session are
# required to be overwritten.
#
# All parameters are optional.
# * :key determines the name of the cookie, by default it is
# 'rack.session'
# * :path, :domain, :expire_after, :secure, and :httponly set the related
# cookie options as by Rack::Response#add_cookie
# * :defer will not set a cookie in the response.
# * :renew (implementation dependent) will prompt the generation of a new
# session id, and migration of data to be referenced at the new id. If
# :defer is set, it will be overridden and the cookie will be set.
# * :sidbits sets the number of bits in length that a generated session
# id will be.
#
# These options can be set on a per request basis, at the location of
# env['rack.session.options']. Additionally the id of the session can be
# found within the options hash at the key :id. It is highly not
# recommended to change its value.
#
# Is Rack::Utils::Context compatible.
class ID
DEFAULT_OPTIONS = {
:path => '/',
:domain => nil,
:expire_after => nil,
:secure => false,
:httponly => true,
:defer => false,
:renew => false,
:sidbits => 128
}
attr_reader :key, :default_options
def initialize(app, options={})
@app = app
@key = options[:key] || "rack.session"
@default_options = self.class::DEFAULT_OPTIONS.merge(options)
end
def call(env)
context(env)
end
def context(env, app=@app)
load_session(env)
status, headers, body = app.call(env)
commit_session(env, status, headers, body)
end
private
# Generate a new session id using Ruby #rand. The size of the
# session id is controlled by the :sidbits option.
# Monkey patch this to use custom methods for session id generation.
def generate_sid
"%0#{@default_options[:sidbits] / 4}x" %
rand(2**@default_options[:sidbits] - 1)
end
# Extracts the session id from provided cookies and passes it and the
# environment to #get_session. It then sets the resulting session into
# 'rack.session', and places options and session metadata into
# 'rack.session.options'.
def load_session(env)
request = Rack::Request.new(env)
session_id = request.cookies[@key]
begin
session_id, session = get_session(env, session_id)
env['rack.session'] = session
rescue
env['rack.session'] = Hash.new
end
env['rack.session.options'] = @default_options.
merge(:id => session_id)
end
# Acquires the session from the environment and the session id from
# the session options and passes them to #set_session. If successful
# and the :defer option is not true, a cookie will be added to the
# response with the session's id.
def commit_session(env, status, headers, body)
session = env['rack.session']
options = env['rack.session.options']
session_id = options[:id]
if not session_id = set_session(env, session_id, session, options)
env["rack.errors"].puts("Warning! #{self.class.name} failed to save session. Content dropped.")
elsif options[:defer] and not options[:renew]
env["rack.errors"].puts("Defering cookie for #{session_id}") if $VERBOSE
else
cookie = Hash.new
cookie[:value] = session_id
cookie[:expires] = Time.now + options[:expire_after] unless options[:expire_after].nil?
Utils.set_cookie_header!(headers, @key, cookie.merge(options))
end
[status, headers, body]
end
# All thread safety and session retrival proceedures should occur here.
# Should return [session_id, session].
# If nil is provided as the session id, generation of a new valid id
# should occur within.
def get_session(env, sid)
raise '#get_session not implemented.'
end
# All thread safety and session storage proceedures should occur here.
# Should return true or false dependant on whether or not the session
# was saved or not.
def set_session(env, sid, session, options)
raise '#set_session not implemented.'
end
end
end
end
end

View file

@ -1,90 +0,0 @@
require 'openssl'
require 'rack/request'
require 'rack/response'
module Rack
module Session
# Rack::Session::Cookie 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.
#
# Example:
#
# use Rack::Session::Cookie, :key => 'rack.session',
# :domain => 'foo.com',
# :path => '/',
# :expire_after => 2592000,
# :secret => 'change_me'
#
# All parameters are optional.
class Cookie
def initialize(app, options={})
@app = app
@key = options[:key] || "rack.session"
@secret = options[:secret]
@default_options = {:domain => nil,
:path => "/",
:expire_after => nil}.merge(options)
end
def call(env)
load_session(env)
status, headers, body = @app.call(env)
commit_session(env, status, headers, body)
end
private
def load_session(env)
request = Rack::Request.new(env)
session_data = request.cookies[@key]
if @secret && session_data
session_data, digest = session_data.split("--")
session_data = nil unless digest == generate_hmac(session_data)
end
begin
session_data = session_data.unpack("m*").first
session_data = Marshal.load(session_data)
env["rack.session"] = session_data
rescue
env["rack.session"] = Hash.new
end
env["rack.session.options"] = @default_options.dup
end
def commit_session(env, status, headers, body)
session_data = Marshal.dump(env["rack.session"])
session_data = [session_data].pack("m*")
if @secret
session_data = "#{session_data}--#{generate_hmac(session_data)}"
end
if session_data.size > (4096 - @key.size)
env["rack.errors"].puts("Warning! Rack::Session::Cookie data size exceeds 4K. Content dropped.")
else
options = env["rack.session.options"]
cookie = Hash.new
cookie[:value] = session_data
cookie[:expires] = Time.now + options[:expire_after] unless options[:expire_after].nil?
Utils.set_cookie_header!(headers, @key, cookie.merge(options))
end
[status, headers, body]
end
def generate_hmac(data)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, @secret, data)
end
end
end
end

View file

@ -1,119 +0,0 @@
# AUTHOR: blink <blinketje@gmail.com>; blink#ruby-lang@irc.freenode.net
require 'rack/session/abstract/id'
require 'memcache'
module Rack
module Session
# Rack::Session::Memcache provides simple cookie based session management.
# Session data is stored in memcached. The corresponding session key is
# maintained in the cookie.
# You may treat Session::Memcache as you would Session::Pool with the
# following caveats.
#
# * Setting :expire_after to 0 would note to the Memcache server to hang
# onto the session data until it would drop it according to it's own
# specifications. However, the cookie sent to the client would expire
# immediately.
#
# Note that memcache does drop data before it may be listed to expire. For
# a full description of behaviour, please see memcache's documentation.
class Memcache < Abstract::ID
attr_reader :mutex, :pool
DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge \
:namespace => 'rack:session',
:memcache_server => 'localhost:11211'
def initialize(app, options={})
super
@mutex = Mutex.new
mserv = @default_options[:memcache_server]
mopts = @default_options.
reject{|k,v| !MemCache::DEFAULT_OPTIONS.include? k }
@pool = MemCache.new mserv, mopts
unless @pool.active? and @pool.servers.any?{|c| c.alive? }
raise 'No memcache servers'
end
end
def generate_sid
loop do
sid = super
break sid unless @pool.get(sid, true)
end
end
def get_session(env, session_id)
@mutex.lock if env['rack.multithread']
unless session_id and session = @pool.get(session_id)
session_id, session = generate_sid, {}
unless /^STORED/ =~ @pool.add(session_id, session)
raise "Session collision on '#{session_id.inspect}'"
end
end
session.instance_variable_set '@old', @pool.get(session_id, true)
return [session_id, session]
rescue MemCache::MemCacheError, Errno::ECONNREFUSED
# MemCache server cannot be contacted
warn "#{self} is unable to find memcached server."
warn $!.inspect
return [ nil, {} ]
ensure
@mutex.unlock if @mutex.locked?
end
def set_session(env, session_id, new_session, options)
expiry = options[:expire_after]
expiry = expiry.nil? ? 0 : expiry + 1
@mutex.lock if env['rack.multithread']
if options[:renew] or options[:drop]
@pool.delete session_id
return false if options[:drop]
session_id = generate_sid
@pool.add session_id, {} # so we don't worry about cache miss on #set
end
session = @pool.get(session_id) || {}
old_session = new_session.instance_variable_get '@old'
old_session = old_session ? Marshal.load(old_session) : {}
unless Hash === old_session and Hash === new_session
env['rack.errors'].
puts 'Bad old_session or new_session sessions provided.'
else # merge sessions
# alterations are either update or delete, making as few changes as
# possible to prevent possible issues.
# removed keys
delete = old_session.keys - new_session.keys
if $VERBOSE and not delete.empty?
env['rack.errors'].
puts "//@#{session_id}: delete #{delete*','}"
end
delete.each{|k| session.delete k }
# added or altered keys
update = new_session.keys.
select{|k| new_session[k] != old_session[k] }
if $VERBOSE and not update.empty?
env['rack.errors'].puts "//@#{session_id}: update #{update*','}"
end
update.each{|k| session[k] = new_session[k] }
end
@pool.set session_id, session, expiry
return session_id
rescue MemCache::MemCacheError, Errno::ECONNREFUSED
# MemCache server cannot be contacted
warn "#{self} is unable to find memcached server."
warn $!.inspect
return false
ensure
@mutex.unlock if @mutex.locked?
end
end
end
end

View file

@ -1,100 +0,0 @@
# AUTHOR: blink <blinketje@gmail.com>; blink#ruby-lang@irc.freenode.net
# THANKS:
# apeiros, for session id generation, expiry setup, and threadiness
# sergio, threadiness and bugreps
require 'rack/session/abstract/id'
require 'thread'
module Rack
module Session
# Rack::Session::Pool provides simple cookie based session management.
# Session 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.
#
# The :drop option is available in rack.session.options if you wish to
# explicitly remove the session from the session cache.
#
# Example:
# myapp = MyRackApp.new
# sessioned = Rack::Session::Pool.new(myapp,
# :domain => 'foo.com',
# :expire_after => 2592000
# )
# Rack::Handler::WEBrick.run sessioned
class Pool < Abstract::ID
attr_reader :mutex, :pool
DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge :drop => false
def initialize(app, options={})
super
@pool = Hash.new
@mutex = Mutex.new
end
def generate_sid
loop do
sid = super
break sid unless @pool.key? sid
end
end
def get_session(env, sid)
session = @pool[sid] if sid
@mutex.lock if env['rack.multithread']
unless sid and session
env['rack.errors'].puts("Session '#{sid.inspect}' not found, initializing...") if $VERBOSE and not sid.nil?
session = {}
sid = generate_sid
@pool.store sid, session
end
session.instance_variable_set('@old', {}.merge(session))
return [sid, session]
ensure
@mutex.unlock if env['rack.multithread']
end
def set_session(env, session_id, new_session, options)
@mutex.lock if env['rack.multithread']
session = @pool[session_id]
if options[:renew] or options[:drop]
@pool.delete session_id
return false if options[:drop]
session_id = generate_sid
@pool.store session_id, 0
end
old_session = new_session.instance_variable_get('@old') || {}
session = merge_sessions session_id, old_session, new_session, session
@pool.store session_id, session
return session_id
rescue
warn "#{new_session.inspect} has been lost."
warn $!.inspect
ensure
@mutex.unlock if env['rack.multithread']
end
private
def merge_sessions sid, old, new, cur=nil
cur ||= {}
unless Hash === old and Hash === new
warn 'Bad old or new sessions provided.'
return cur
end
delete = old.keys - new.keys
warn "//@#{sid}: dropping #{delete*','}" if $DEBUG and not delete.empty?
delete.each{|k| cur.delete k }
update = new.keys.select{|k| new[k] != old[k] }
warn "//@#{sid}: updating #{update*','}" if $DEBUG and not update.empty?
update.each{|k| cur[k] = new[k] }
cur
end
end
end
end

View file

@ -1,349 +0,0 @@
require 'ostruct'
require 'erb'
require 'rack/request'
require 'rack/utils'
module Rack
# Rack::ShowExceptions catches all exceptions raised from the app it
# wraps. It shows a useful backtrace with the sourcefile and
# clickable context, the whole Rack environment and the request
# data.
#
# Be careful when you use this on public-facing sites as it could
# reveal information helpful to attackers.
class ShowExceptions
CONTEXT = 7
def initialize(app)
@app = app
@template = ERB.new(TEMPLATE)
end
def call(env)
@app.call(env)
rescue StandardError, LoadError, SyntaxError => e
backtrace = pretty(env, e)
[500,
{"Content-Type" => "text/html",
"Content-Length" => backtrace.join.size.to_s},
backtrace]
end
def pretty(env, exception)
req = Rack::Request.new(env)
path = (req.script_name + req.path_info).squeeze("/")
frames = exception.backtrace.map { |line|
frame = OpenStruct.new
if line =~ /(.*?):(\d+)(:in `(.*)')?/
frame.filename = $1
frame.lineno = $2.to_i
frame.function = $4
begin
lineno = frame.lineno-1
lines = ::File.readlines(frame.filename)
frame.pre_context_lineno = [lineno-CONTEXT, 0].max
frame.pre_context = lines[frame.pre_context_lineno...lineno]
frame.context_line = lines[lineno].chomp
frame.post_context_lineno = [lineno+CONTEXT, lines.size].min
frame.post_context = lines[lineno+1..frame.post_context_lineno]
rescue
end
frame
else
nil
end
}.compact
env["rack.errors"].puts "#{exception.class}: #{exception.message}"
env["rack.errors"].puts exception.backtrace.map { |l| "\t" + l }
env["rack.errors"].flush
[@template.result(binding)]
end
def h(obj) # :nodoc:
case obj
when String
Utils.escape_html(obj)
else
Utils.escape_html(obj.inspect)
end
end
# :stopdoc:
# adapted from Django <djangoproject.com>
# Copyright (c) 2005, the Lawrence Journal-World
# Used under the modified BSD license:
# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
TEMPLATE = <<'HTML'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="NONE,NOARCHIVE" />
<title><%=h exception.class %> at <%=h path %></title>
<style type="text/css">
html * { padding:0; margin:0; }
body * { padding:10px 20px; }
body * * { padding:0; }
body { font:small sans-serif; }
body>div { border-bottom:1px solid #ddd; }
h1 { font-weight:normal; }
h2 { margin-bottom:.8em; }
h2 span { font-size:80%; color:#666; font-weight:normal; }
h3 { margin:1em 0 .5em 0; }
h4 { margin:0 0 .5em 0; font-weight: normal; }
table {
border:1px solid #ccc; border-collapse: collapse; background:white; }
tbody td, tbody th { vertical-align:top; padding:2px 3px; }
thead th {
padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
font-weight:normal; font-size:11px; border:1px solid #ddd; }
tbody th { text-align:right; color:#666; padding-right:.5em; }
table.vars { margin:5px 0 2px 40px; }
table.vars td, table.req td { font-family:monospace; }
table td.code { width:100%;}
table td.code div { overflow:hidden; }
table.source th { color:#666; }
table.source td {
font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }
ul.traceback { list-style-type:none; }
ul.traceback li.frame { margin-bottom:1em; }
div.context { margin: 10px 0; }
div.context ol {
padding-left:30px; margin:0 10px; list-style-position: inside; }
div.context ol li {
font-family:monospace; white-space:pre; color:#666; cursor:pointer; }
div.context ol.context-line li { color:black; background-color:#ccc; }
div.context ol.context-line li span { float: right; }
div.commands { margin-left: 40px; }
div.commands a { color:black; text-decoration:none; }
#summary { background: #ffc; }
#summary h2 { font-weight: normal; color: #666; }
#summary ul#quicklinks { list-style-type: none; margin-bottom: 2em; }
#summary ul#quicklinks li { float: left; padding: 0 1em; }
#summary ul#quicklinks>li+li { border-left: 1px #666 solid; }
#explanation { background:#eee; }
#template, #template-not-exist { background:#f6f6f6; }
#template-not-exist ul { margin: 0 0 0 20px; }
#traceback { background:#eee; }
#requestinfo { background:#f6f6f6; padding-left:120px; }
#summary table { border:none; background:transparent; }
#requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }
#requestinfo h3 { margin-bottom:-1em; }
.error { background: #ffc; }
.specific { color:#cc3300; font-weight:bold; }
</style>
<script type="text/javascript">
//<!--
function getElementsByClassName(oElm, strTagName, strClassName){
// Written by Jonathan Snook, http://www.snook.ca/jon;
// Add-ons by Robert Nyman, http://www.robertnyman.com
var arrElements = (strTagName == "*" && document.all)? document.all :
oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
function hideAll(elems) {
for (var e = 0; e < elems.length; e++) {
elems[e].style.display = 'none';
}
}
window.onload = function() {
hideAll(getElementsByClassName(document, 'table', 'vars'));
hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
hideAll(getElementsByClassName(document, 'ol', 'post-context'));
}
function toggle() {
for (var i = 0; i < arguments.length; i++) {
var e = document.getElementById(arguments[i]);
if (e) {
e.style.display = e.style.display == 'none' ? 'block' : 'none';
}
}
return false;
}
function varToggle(link, id) {
toggle('v' + id);
var s = link.getElementsByTagName('span')[0];
var uarr = String.fromCharCode(0x25b6);
var darr = String.fromCharCode(0x25bc);
s.innerHTML = s.innerHTML == uarr ? darr : uarr;
return false;
}
//-->
</script>
</head>
<body>
<div id="summary">
<h1><%=h exception.class %> at <%=h path %></h1>
<h2><%=h exception.message %></h2>
<table><tr>
<th>Ruby</th>
<td><code><%=h frames.first.filename %></code>: in <code><%=h frames.first.function %></code>, line <%=h frames.first.lineno %></td>
</tr><tr>
<th>Web</th>
<td><code><%=h req.request_method %> <%=h(req.host + path)%></code></td>
</tr></table>
<h3>Jump to:</h3>
<ul id="quicklinks">
<li><a href="#get-info">GET</a></li>
<li><a href="#post-info">POST</a></li>
<li><a href="#cookie-info">Cookies</a></li>
<li><a href="#env-info">ENV</a></li>
</ul>
</div>
<div id="traceback">
<h2>Traceback <span>(innermost first)</span></h2>
<ul class="traceback">
<% frames.each { |frame| %>
<li class="frame">
<code><%=h frame.filename %></code>: in <code><%=h frame.function %></code>
<% if frame.context_line %>
<div class="context" id="c<%=h frame.object_id %>">
<% if frame.pre_context %>
<ol start="<%=h frame.pre_context_lineno+1 %>" class="pre-context" id="pre<%=h frame.object_id %>">
<% frame.pre_context.each { |line| %>
<li onclick="toggle('pre<%=h frame.object_id %>', 'post<%=h frame.object_id %>')"><%=h line %></li>
<% } %>
</ol>
<% end %>
<ol start="<%=h frame.lineno %>" class="context-line">
<li onclick="toggle('pre<%=h frame.object_id %>', 'post<%=h frame.object_id %>')"><%=h frame.context_line %><span>...</span></li></ol>
<% if frame.post_context %>
<ol start='<%=h frame.lineno+1 %>' class="post-context" id="post<%=h frame.object_id %>">
<% frame.post_context.each { |line| %>
<li onclick="toggle('pre<%=h frame.object_id %>', 'post<%=h frame.object_id %>')"><%=h line %></li>
<% } %>
</ol>
<% end %>
</div>
<% end %>
</li>
<% } %>
</ul>
</div>
<div id="requestinfo">
<h2>Request information</h2>
<h3 id="get-info">GET</h3>
<% unless req.GET.empty? %>
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %>
<tr>
<td><%=h key %></td>
<td class="code"><div><%=h val.inspect %></div></td>
</tr>
<% } %>
</tbody>
</table>
<% else %>
<p>No GET data.</p>
<% end %>
<h3 id="post-info">POST</h3>
<% unless req.POST.empty? %>
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %>
<tr>
<td><%=h key %></td>
<td class="code"><div><%=h val.inspect %></div></td>
</tr>
<% } %>
</tbody>
</table>
<% else %>
<p>No POST data.</p>
<% end %>
<h3 id="cookie-info">COOKIES</h3>
<% unless req.cookies.empty? %>
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<% req.cookies.each { |key, val| %>
<tr>
<td><%=h key %></td>
<td class="code"><div><%=h val.inspect %></div></td>
</tr>
<% } %>
</tbody>
</table>
<% else %>
<p>No cookie data.</p>
<% end %>
<h3 id="env-info">Rack ENV</h3>
<table class="req">
<thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<% env.sort_by { |k, v| k.to_s }.each { |key, val| %>
<tr>
<td><%=h key %></td>
<td class="code"><div><%=h val %></div></td>
</tr>
<% } %>
</tbody>
</table>
</div>
<div id="explanation">
<p>
You're seeing this error because you use <code>Rack::ShowExceptions</code>.
</p>
</div>
</body>
</html>
HTML
# :startdoc:
end
end

View file

@ -1,106 +0,0 @@
require 'erb'
require 'rack/request'
require 'rack/utils'
module Rack
# Rack::ShowStatus catches all empty responses the app it wraps and
# replaces them with a site explaining the error.
#
# 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.
class ShowStatus
def initialize(app)
@app = app
@template = ERB.new(TEMPLATE)
end
def call(env)
status, headers, body = @app.call(env)
headers = Utils::HeaderHash.new(headers)
empty = headers['Content-Length'].to_i <= 0
# client or server error, or explicit message
if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"]
req = Rack::Request.new(env)
message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s
detail = env["rack.showstatus.detail"] || message
body = @template.result(binding)
size = Rack::Utils.bytesize(body)
[status, headers.merge("Content-Type" => "text/html", "Content-Length" => size.to_s), [body]]
else
[status, headers, body]
end
end
def h(obj) # :nodoc:
case obj
when String
Utils.escape_html(obj)
else
Utils.escape_html(obj.inspect)
end
end
# :stopdoc:
# adapted from Django <djangoproject.com>
# Copyright (c) 2005, the Lawrence Journal-World
# Used under the modified BSD license:
# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
TEMPLATE = <<'HTML'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><%=h message %> at <%=h req.script_name + req.path_info %></title>
<meta name="robots" content="NONE,NOARCHIVE" />
<style type="text/css">
html * { padding:0; margin:0; }
body * { padding:10px 20px; }
body * * { padding:0; }
body { font:small sans-serif; background:#eee; }
body>div { border-bottom:1px solid #ddd; }
h1 { font-weight:normal; margin-bottom:.4em; }
h1 span { font-size:60%; color:#666; font-weight:normal; }
table { border:none; border-collapse: collapse; width:100%; }
td, th { vertical-align:top; padding:2px 3px; }
th { width:12em; text-align:right; color:#666; padding-right:.5em; }
#info { background:#f6f6f6; }
#info ol { margin: 0.5em 4em; }
#info ol li { font-family: monospace; }
#summary { background: #ffc; }
#explanation { background:#eee; border-bottom: 0px none; }
</style>
</head>
<body>
<div id="summary">
<h1><%=h message %> <span>(<%= status.to_i %>)</span></h1>
<table class="meta">
<tr>
<th>Request Method:</th>
<td><%=h req.request_method %></td>
</tr>
<tr>
<th>Request URL:</th>
<td><%=h req.url %></td>
</tr>
</table>
</div>
<div id="info">
<p><%= detail %></p>
</div>
<div id="explanation">
<p>
You're seeing this error because you use <code>Rack::ShowStatus</code>.
</p>
</div>
</body>
</html>
HTML
# :startdoc:
end
end

View file

@ -1,38 +0,0 @@
module Rack
# The Rack::Static middleware intercepts requests for static files
# (javascript files, images, stylesheets, etc) based on the url prefixes
# passed in the options, and serves them using a Rack::File object. This
# allows a Rack stack to serve both static and dynamic content.
#
# Examples:
# use Rack::Static, :urls => ["/media"]
# will serve all requests beginning with /media from the "media" folder
# located in the current directory (ie media/*).
#
# use Rack::Static, :urls => ["/css", "/images"], :root => "public"
# will serve all requests beginning with /css or /images from the folder
# "public" in the current directory (ie public/css/* and public/images/*)
class Static
def initialize(app, options={})
@app = app
@urls = options[:urls] || ["/favicon.ico"]
root = options[:root] || Dir.pwd
@file_server = Rack::File.new(root)
end
def call(env)
path = env["PATH_INFO"]
can_serve = @urls.any? { |url| path.index(url) == 0 }
if can_serve
@file_server.call(env)
else
@app.call(env)
end
end
end
end

View file

@ -1,55 +0,0 @@
module Rack
# Rack::URLMap takes a hash mapping urls or paths to apps, and
# dispatches accordingly. Support for HTTP/1.1 host names exists if
# the URLs start with <tt>http://</tt> or <tt>https://</tt>.
#
# URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part
# relevant for dispatch is in the SCRIPT_NAME, and the rest in the
# PATH_INFO. This should be taken care of when you need to
# reconstruct the URL in order to create links.
#
# URLMap dispatches in such a way that the longest paths are tried
# first, since they are most specific.
class URLMap
def initialize(map = {})
remap(map)
end
def remap(map)
@mapping = map.map { |location, app|
if location =~ %r{\Ahttps?://(.*?)(/.*)}
host, location = $1, $2
else
host = nil
end
unless location[0] == ?/
raise ArgumentError, "paths need to start with /"
end
location = location.chomp('/')
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", nil, 'n')
[host, location, match, app]
}.sort_by { |(h, l, m, a)| [h ? -h.size : (-1.0 / 0.0), -l.size] } # Longest path first
end
def call(env)
path = env["PATH_INFO"]
script_name = env['SCRIPT_NAME']
hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT')
@mapping.each { |host, location, match, app|
next unless (hHost == host || sName == host \
|| (host.nil? && (hHost == sName || hHost == sName+':'+sPort)))
next unless path.to_s =~ match && rest = $1
next unless rest.empty? || rest[0] == ?/
env.merge!('SCRIPT_NAME' => (script_name + location), 'PATH_INFO' => rest)
return app.call(env)
}
[404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path}"]]
ensure
env.merge! 'PATH_INFO' => path, 'SCRIPT_NAME' => script_name
end
end
end

View file

@ -1,667 +0,0 @@
# -*- encoding: binary -*-
require 'fileutils'
require 'set'
require 'tempfile'
module Rack
# Rack::Utils contains a grab-bag of useful methods for writing web
# applications adopted from all kinds of Ruby libraries.
module Utils
# Performs URI escaping so that you can construct proper
# query strings faster. Use this rather than the cgi.rb
# version since it's faster. (Stolen from Camping).
def escape(s)
s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
'%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
}.tr(' ', '+')
end
module_function :escape
# Unescapes a URI escaped string. (Stolen from Camping).
def unescape(s)
s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){
[$1.delete('%')].pack('H*')
}
end
module_function :unescape
DEFAULT_SEP = /[&;] */n
# Stolen from Mongrel, with some small modifications:
# Parses a query string by breaking it up at the '&'
# and ';' characters. You can also use this to parse
# cookies by changing the characters used in the second
# parameter (which defaults to '&;').
def parse_query(qs, d = nil)
params = {}
(qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
k, v = p.split('=', 2).map { |x| unescape(x) }
if cur = params[k]
if cur.class == Array
params[k] << v
else
params[k] = [cur, v]
end
else
params[k] = v
end
end
return params
end
module_function :parse_query
def parse_nested_query(qs, d = nil)
params = {}
(qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
k, v = unescape(p).split('=', 2)
normalize_params(params, k, v)
end
return params
end
module_function :parse_nested_query
def normalize_params(params, name, v = nil)
name =~ %r(\A[\[\]]*([^\[\]]+)\]*)
k = $1 || ''
after = $' || ''
return if k.empty?
if after == ""
params[k] = v
elsif after == "[]"
params[k] ||= []
raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
params[k] << v
elsif after =~ %r(^\[\]\[([^\[\]]+)\]$) || after =~ %r(^\[\](.+)$)
child_key = $1
params[k] ||= []
raise TypeError, "expected Array (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Array)
if params[k].last.is_a?(Hash) && !params[k].last.key?(child_key)
normalize_params(params[k].last, child_key, v)
else
params[k] << normalize_params({}, child_key, v)
end
else
params[k] ||= {}
raise TypeError, "expected Hash (got #{params[k].class.name}) for param `#{k}'" unless params[k].is_a?(Hash)
params[k] = normalize_params(params[k], after, v)
end
return params
end
module_function :normalize_params
def build_query(params)
params.map { |k, v|
if v.class == Array
build_query(v.map { |x| [k, x] })
else
"#{escape(k)}=#{escape(v)}"
end
}.join("&")
end
module_function :build_query
def build_nested_query(value, prefix = nil)
case value
when Array
value.map { |v|
build_nested_query(v, "#{prefix}[]")
}.join("&")
when Hash
value.map { |k, v|
build_nested_query(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k))
}.join("&")
when String
raise ArgumentError, "value must be a Hash" if prefix.nil?
"#{prefix}=#{escape(value)}"
else
prefix
end
end
module_function :build_nested_query
ESCAPE_HTML = {
"&" => "&amp;",
"<" => "&lt;",
">" => "&gt;",
"'" => "&#39;",
'"' => "&quot;",
}
ESCAPE_HTML_PATTERN = Regexp.union(*ESCAPE_HTML.keys)
# Escape ampersands, brackets and quotes to their HTML/XML entities.
def escape_html(string)
string.to_s.gsub(ESCAPE_HTML_PATTERN){|c| ESCAPE_HTML[c] }
end
module_function :escape_html
def select_best_encoding(available_encodings, accept_encoding)
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
expanded_accept_encoding =
accept_encoding.map { |m, q|
if m == "*"
(available_encodings - accept_encoding.map { |m2, _| m2 }).map { |m2| [m2, q] }
else
[[m, q]]
end
}.inject([]) { |mem, list|
mem + list
}
encoding_candidates = expanded_accept_encoding.sort_by { |_, q| -q }.map { |m, _| m }
unless encoding_candidates.include?("identity")
encoding_candidates.push("identity")
end
expanded_accept_encoding.find_all { |m, q|
q == 0.0
}.each { |m, _|
encoding_candidates.delete(m)
}
return (encoding_candidates & available_encodings)[0]
end
module_function :select_best_encoding
def set_cookie_header!(header, key, value)
case value
when Hash
domain = "; domain=" + value[:domain] if value[:domain]
path = "; path=" + value[:path] if value[:path]
# According to RFC 2109, we need dashes here.
# N.B.: cgi.rb uses spaces...
expires = "; expires=" +
rfc2822(value[:expires].clone.gmtime) if value[:expires]
secure = "; secure" if value[:secure]
httponly = "; HttpOnly" if value[:httponly]
value = value[:value]
end
value = [value] unless Array === value
cookie = escape(key) + "=" +
value.map { |v| escape v }.join("&") +
"#{domain}#{path}#{expires}#{secure}#{httponly}"
case header["Set-Cookie"]
when nil, ''
header["Set-Cookie"] = cookie
when String
header["Set-Cookie"] = [header["Set-Cookie"], cookie].join("\n")
when Array
header["Set-Cookie"] = (header["Set-Cookie"] + [cookie]).join("\n")
end
nil
end
module_function :set_cookie_header!
def delete_cookie_header!(header, key, value = {})
case header["Set-Cookie"]
when nil, ''
cookies = []
when String
cookies = header["Set-Cookie"].split("\n")
when Array
cookies = header["Set-Cookie"]
end
cookies.reject! { |cookie|
if value[:domain]
cookie =~ /\A#{escape(key)}=.*domain=#{value[:domain]}/
else
cookie =~ /\A#{escape(key)}=/
end
}
header["Set-Cookie"] = cookies.join("\n")
set_cookie_header!(header, key,
{:value => '', :path => nil, :domain => nil,
:expires => Time.at(0) }.merge(value))
nil
end
module_function :delete_cookie_header!
# Return the bytesize of String; uses String#length under Ruby 1.8 and
# String#bytesize under 1.9.
if ''.respond_to?(:bytesize)
def bytesize(string)
string.bytesize
end
else
def bytesize(string)
string.size
end
end
module_function :bytesize
# Modified version of stdlib time.rb Time#rfc2822 to use '%d-%b-%Y' instead
# of '% %b %Y'.
# It assumes that the time is in GMT to comply to the RFC 2109.
#
# NOTE: I'm not sure the RFC says it requires GMT, but is ambigous enough
# that I'm certain someone implemented only that option.
# Do not use %a and %b from Time.strptime, it would use localized names for
# weekday and month.
#
def rfc2822(time)
wday = Time::RFC2822_DAY_NAME[time.wday]
mon = Time::RFC2822_MONTH_NAME[time.mon - 1]
time.strftime("#{wday}, %d-#{mon}-%Y %T GMT")
end
module_function :rfc2822
# Context allows the use of a compatible middleware at different points
# in a request handling stack. A compatible middleware must define
# #context which should take the arguments env and app. The first of which
# would be the request environment. The second of which would be the rack
# application that the request would be forwarded to.
class Context
attr_reader :for, :app
def initialize(app_f, app_r)
raise 'running context does not respond to #context' unless app_f.respond_to? :context
@for, @app = app_f, app_r
end
def call(env)
@for.context(env, @app)
end
def recontext(app)
self.class.new(@for, app)
end
def context(env, app=@app)
recontext(app).call(env)
end
end
# A case-insensitive Hash that preserves the original case of a
# header when set.
class HeaderHash < Hash
def self.new(hash={})
HeaderHash === hash ? hash : super(hash)
end
def initialize(hash={})
super()
@names = {}
hash.each { |k, v| self[k] = v }
end
def each
super do |k, v|
yield(k, v.respond_to?(:to_ary) ? v.to_ary.join("\n") : v)
end
end
def to_hash
inject({}) do |hash, (k,v)|
if v.respond_to? :to_ary
hash[k] = v.to_ary.join("\n")
else
hash[k] = v
end
hash
end
end
def [](k)
super(@names[k]) if @names[k]
super(@names[k.downcase])
end
def []=(k, v)
delete k
@names[k] = @names[k.downcase] = k
super k, v
end
def delete(k)
canonical = k.downcase
result = super @names.delete(canonical)
@names.delete_if { |name,| name.downcase == canonical }
result
end
def include?(k)
@names.include?(k) || @names.include?(k.downcase)
end
alias_method :has_key?, :include?
alias_method :member?, :include?
alias_method :key?, :include?
def merge!(other)
other.each { |k, v| self[k] = v }
self
end
def merge(other)
hash = dup
hash.merge! other
end
def replace(other)
clear
other.each { |k, v| self[k] = v }
self
end
end
# Every standard HTTP code mapped to the appropriate message.
# Generated with:
# curl -s http://www.iana.org/assignments/http-status-codes | \
# ruby -ane 'm = /^(\d{3}) +(\S[^\[(]+)/.match($_) and
# puts " #{m[1]} => \x27#{m[2].strip}x27,"'
HTTP_STATUS_CODES = {
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
207 => 'Multi-Status',
226 => 'IM Used',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => 'Reserved',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
422 => 'Unprocessable Entity',
423 => 'Locked',
424 => 'Failed Dependency',
426 => 'Upgrade Required',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported',
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
510 => 'Not Extended',
}
# Responses with HTTP status codes that should not have an entity body
STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 304)
SYMBOL_TO_STATUS_CODE = HTTP_STATUS_CODES.inject({}) { |hash, (code, message)|
hash[message.downcase.gsub(/\s|-/, '_').to_sym] = code
hash
}
def status_code(status)
if status.is_a?(Symbol)
SYMBOL_TO_STATUS_CODE[status] || 500
else
status.to_i
end
end
module_function :status_code
# A multipart form data parser, adapted from IOWA.
#
# Usually, Rack::Request#POST takes care of calling this.
module Multipart
class UploadedFile
# The filename, *not* including the path, of the "uploaded" file
attr_reader :original_filename
# The content type of the "uploaded" file
attr_accessor :content_type
def initialize(path, content_type = "text/plain", binary = false)
raise "#{path} file does not exist" unless ::File.exist?(path)
@content_type = content_type
@original_filename = ::File.basename(path)
@tempfile = Tempfile.new(@original_filename)
@tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
@tempfile.binmode if binary
FileUtils.copy_file(path, @tempfile.path)
end
def path
@tempfile.path
end
alias_method :local_path, :path
def method_missing(method_name, *args, &block) #:nodoc:
@tempfile.__send__(method_name, *args, &block)
end
end
EOL = "\r\n"
MULTIPART_BOUNDARY = "AaB03x"
def self.parse_multipart(env)
unless env['CONTENT_TYPE'] =~
%r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n
nil
else
boundary = "--#{$1}"
params = {}
buf = ""
content_length = env['CONTENT_LENGTH'].to_i
input = env['rack.input']
input.rewind
boundary_size = Utils.bytesize(boundary) + EOL.size
bufsize = 16384
content_length -= boundary_size
read_buffer = ''
status = input.read(boundary_size, read_buffer)
raise EOFError, "bad content body" unless status == boundary + EOL
rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/n
loop {
head = nil
body = ''
filename = content_type = name = nil
until head && buf =~ rx
if !head && i = buf.index(EOL+EOL)
head = buf.slice!(0, i+2) # First \r\n
buf.slice!(0, 2) # Second \r\n
token = /[^\s()<>,;:\\"\/\[\]?=]+/
condisp = /Content-Disposition:\s*#{token}\s*/i
dispparm = /;\s*(#{token})=("(?:\\"|[^"])*"|#{token})*/
rfc2183 = /^#{condisp}(#{dispparm})+$/i
broken_quoted = /^#{condisp}.*;\sfilename="(.*?)"(?:\s*$|\s*;\s*#{token}=)/i
broken_unquoted = /^#{condisp}.*;\sfilename=(#{token})/i
if head =~ rfc2183
filename = Hash[head.scan(dispparm)]['filename']
filename = $1 if filename and filename =~ /^"(.*)"$/
elsif head =~ broken_quoted
filename = $1
elsif head =~ broken_unquoted
filename = $1
end
if filename && filename !~ /\\[^\\"]/
filename = Utils.unescape(filename).gsub(/\\(.)/, '\1')
end
content_type = head[/Content-Type: (.*)#{EOL}/ni, 1]
name = head[/Content-Disposition:.*\s+name="?([^\";]*)"?/ni, 1] || head[/Content-ID:\s*([^#{EOL}]*)/ni, 1]
if filename
body = Tempfile.new("RackMultipart")
body.binmode if body.respond_to?(:binmode)
end
next
end
# Save the read body part.
if head && (boundary_size+4 < buf.size)
body << buf.slice!(0, buf.size - (boundary_size+4))
end
c = input.read(bufsize < content_length ? bufsize : content_length, read_buffer)
raise EOFError, "bad content body" if c.nil? || c.empty?
buf << c
content_length -= c.size
end
# Save the rest.
if i = buf.index(rx)
body << buf.slice!(0, i)
buf.slice!(0, boundary_size+2)
content_length = -1 if $1 == "--"
end
if filename == ""
# filename is blank which means no file has been selected
data = nil
elsif filename
body.rewind
# Take the basename of the upload's original filename.
# This handles the full Windows paths given by Internet Explorer
# (and perhaps other broken user agents) without affecting
# those which give the lone filename.
filename = filename.split(/[\/\\]/).last
data = {:filename => filename, :type => content_type,
:name => name, :tempfile => body, :head => head}
elsif !filename && content_type
body.rewind
# Generic multipart cases, not coming from a form
data = {:type => content_type,
:name => name, :tempfile => body, :head => head}
else
data = body
end
Utils.normalize_params(params, name, data) unless data.nil?
# break if we're at the end of a buffer, but not if it is the end of a field
break if (buf.empty? && $1 != EOL) || content_length == -1
}
input.rewind
params
end
end
def self.build_multipart(params, first = true)
if first
unless params.is_a?(Hash)
raise ArgumentError, "value must be a Hash"
end
multipart = false
query = lambda { |value|
case value
when Array
value.each(&query)
when Hash
value.values.each(&query)
when UploadedFile
multipart = true
end
}
params.values.each(&query)
return nil unless multipart
end
flattened_params = Hash.new
params.each do |key, value|
k = first ? key.to_s : "[#{key}]"
case value
when Array
value.map { |v|
build_multipart(v, false).each { |subkey, subvalue|
flattened_params["#{k}[]#{subkey}"] = subvalue
}
}
when Hash
build_multipart(value, false).each { |subkey, subvalue|
flattened_params[k + subkey] = subvalue
}
else
flattened_params[k] = value
end
end
if first
flattened_params.map { |name, file|
if file.respond_to?(:original_filename)
::File.open(file.path, "rb") do |f|
f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding)
<<-EOF
--#{MULTIPART_BOUNDARY}\r
Content-Disposition: form-data; name="#{name}"; filename="#{Utils.escape(file.original_filename)}"\r
Content-Type: #{file.content_type}\r
Content-Length: #{::File.stat(file.path).size}\r
\r
#{f.read}\r
EOF
end
else
<<-EOF
--#{MULTIPART_BOUNDARY}\r
Content-Disposition: form-data; name="#{name}"\r
\r
#{file}\r
EOF
end
}.join + "--#{MULTIPART_BOUNDARY}--\r"
else
flattened_params
end
end
end
end
end

View file

@ -1,38 +0,0 @@
Gem::Specification.new do |s|
s.name = "rack"
s.version = "1.2.1"
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 = Dir['{bin/*,contrib/*,example/*,lib/**/*,test/**/*}'] +
%w(COPYING KNOWN-ISSUES rack.gemspec README SPEC)
s.bindir = 'bin'
s.executables << 'rackup'
s.require_path = 'lib'
s.has_rdoc = true
s.extra_rdoc_files = ['README', 'SPEC', 'KNOWN-ISSUES']
s.test_files = Dir['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 'bacon'
s.add_development_dependency 'rake'
s.add_development_dependency 'fcgi'
s.add_development_dependency 'memcache-client'
s.add_development_dependency 'mongrel'
s.add_development_dependency 'thin'
end

View file

@ -1,25 +0,0 @@
server.modules = ("mod_fastcgi", "mod_cgi")
server.document-root = "."
server.errorlog = var.CWD + "/lighttpd.errors"
server.port = 9203
server.event-handler = "select"
cgi.assign = ("/test" => "",
# ".ru" => ""
)
fastcgi.server = (
"test.fcgi" => ("localhost" =>
("min-procs" => 1,
"socket" => "/tmp/rack-test-fcgi",
"bin-path" => "test.fcgi")),
"test.ru" => ("localhost" =>
("min-procs" => 1,
"socket" => "/tmp/rack-test-ru-fcgi",
"bin-path" => CWD + "/rackup_stub.rb test.ru")),
"sample_rackup.ru" => ("localhost" =>
("min-procs" => 1,
"socket" => "/tmp/rack-test-rackup-fcgi",
"bin-path" => CWD + "/rackup_stub.rb sample_rackup.ru")),
)

View file

@ -1,6 +0,0 @@
#!/usr/bin/env ruby
# -*- ruby -*-
$:.unshift '../../lib'
require 'rack'
Rack::Server.start

View file

@ -1,5 +0,0 @@
# -*- ruby -*-
require '../testrequest'
run TestRequest.new

View file

@ -1,9 +0,0 @@
#!/usr/bin/env ruby
# -*- ruby -*-
$: << File.join(File.dirname(__FILE__), "..", "..", "lib")
require 'rack'
require '../testrequest'
Rack::Handler::CGI.run(Rack::Lint.new(TestRequest.new))

View file

@ -1,8 +0,0 @@
#!/usr/bin/env ruby
# -*- ruby -*-
$:.unshift '../../lib'
require 'rack'
require '../testrequest'
Rack::Handler::FastCGI.run(Rack::Lint.new(TestRequest.new))

View file

@ -1,5 +0,0 @@
#!../../bin/rackup
# -*- ruby -*-
require '../testrequest'
run TestRequest.new

View file

@ -1,259 +0,0 @@
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="bbbbbbbbbbbbbbb"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="ccccccc"
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="file.name"
INPUTMSG.gz
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="file.content_type"
application/octet-stream
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="file.path"
/var/tmp/uploads/4/0001728414
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="file.md5"
aa73198feb4b4c1c3186f5e7466cbbcc
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="file.size"
13212
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="size"
80892
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="mail_server_id"
<1111111111.22222222.3333333333333.JavaMail.app@ffff-aaaa.dddd>
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="addresses"
{"campsy_programmer@pinkedum.com":{"domain":"pinkedum.com","name":"Campsy Programmer","type":["env_sender"],"mailbox":"campsy_programmer"},"tex@rapidcity.com":{"domain":"rapidcity.com","name":"Big Tex","type":["env_recipients","to"],"mailbox":"tex"},"group-digests@linkedin.com":{"domain":"linkedin.com","name":"Group Members","type":["from"],"mailbox":"group-digests"}}
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="received_on"
2009-11-15T14:21:11Z
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="id"
dbfd9804d26d11deab24e3037639bf77
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon
Content-Disposition: form-data; name="ip_address"
127.0.0.1
--1yy3laWhgX31qpiHinh67wJXqKalukEUTvqTzmon--

Binary file not shown.

View file

@ -1,10 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="submit-name"
Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain
--AaB03x--

View file

@ -1,814 +0,0 @@
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="_method"
put
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="authenticity_token"
XCUgSyYsZ+iHQunq/yCSKFzjeVmsXV/WcphHQ0J+05I=
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[SESE]"
BooBar
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[BBBBBBBBB]"
18
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[CCCCCCCCCCCCCCCCCCC]"
0
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[STARTFOO]"
2009-11-04
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[ENDFOO]"
2009-12-01
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[DDDDDDDD]"
0
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[DDDDDDDD]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[EEEEEEEEEE]"
10000
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[FFFFFFFFF]"
boskoizcool
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[GGGGGGGGGGG]"
0
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[GGGGGGGGGGG]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[YYYYYYYYYYYYYYY]"
5.00
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[ZZZZZZZZZZZZZ]"
mille
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[XXXXXXXXXXXXXXXXXXXXX]"
0
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][1][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][2][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][3][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][4][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][5][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][6][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][9]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][10]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][11]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][12]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][13]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][14]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][15]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][16]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][17]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][18]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][19]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][20]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][21]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][22]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][23]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][0]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][1]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][2]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][3]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][4]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][5]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][6]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][7]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[VVVVVVVVVVVVVVVVVVVVVVV][0][8]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[WWWWWWWWWWWWWWWWWWWWWWWWW][678][ZEZE]"
PLAPLAPLAINCINCINC
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[WWWWWWWWWWWWWWWWWWWWWWWWW][678][123412341234e]"
SITE
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[WWWWWWWWWWWWWWWWWWWWWWWWW][678][12345678901]"
56
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_type]"
none
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][has_hashashas_has]"
0
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][frefrefre_fre_freee]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][frefrefre_fre_frefre]"
forever
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][self_block]"
0
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][GGG_RULES][][COUCOUN]"
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][GGG_RULES][][REGREG]"
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_wizard][GGG_RULES][][c1c1]"
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA_TARTARTAR_wizard_rule"
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[TARTARTAR_rule]"
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[selection_selection]"
R
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[PLAPLAPLA_MEMMEMMEMM_ATTRATTRER][new][-1][selection_selection]"
1
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[PLAPLAPLA_MEMMEMMEMM_ATTRATTRER][new][-1][ba_unit_id]"
1015
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[PLAPLAPLA_MEMMEMMEMM_ATTRATTRER][new][-2][selection_selection]"
2
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[PLAPLAPLA_MEMMEMMEMM_ATTRATTRER][new][-2][ba_unit_id]"
1017
------WebKitFormBoundaryWsY0GnpbI5U7ztzo
Content-Disposition: form-data; name="AAAAAAAAAAAAAAAAAAA[tile_name]"
------WebKitFormBoundaryWsY0GnpbI5U7ztzo--

View file

@ -1 +0,0 @@
contents

View file

@ -1,7 +0,0 @@
--AaB03x
Content-Type: image/jpeg
Content-Disposition: attachment; name="files"; filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
Content-Description: a complete map of the human genome
contents
--AaB03x--

View file

@ -1,6 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="files"; filename="escape \"quotes"
Content-Type: application/octet-stream
contents
--AaB03x--

View file

@ -1,7 +0,0 @@
--AaB03x
Content-Type: image/jpeg
Content-Disposition: attachment; name="files"; filename=""human" genome.jpeg"; modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
Content-Description: a complete map of the human genome
contents
--AaB03x--

View file

@ -1,6 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="files"; filename="escape %22quotes"
Content-Type: application/octet-stream
contents
--AaB03x--

View file

@ -1,6 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="files"; filename="escape "quotes"
Content-Type: application/octet-stream
contents
--AaB03x--

View file

@ -1,6 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="files"; filename="C:\Documents and Settings\Administrator\Desktop\file1.txt"
Content-Type: text/plain
contents
--AaB03x--

View file

@ -1,10 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="foo[submit-name]"
Larry
--AaB03x
Content-Disposition: form-data; name="foo[files]"; filename="file1.txt"
Content-Type: text/plain
contents
--AaB03x--

View file

@ -1,9 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="submit-name"
Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename=""
--AaB03x--

View file

@ -1,6 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="files"; filename="fi;le1.txt"
Content-Type: text/plain
contents
--AaB03x--

View file

@ -1,10 +0,0 @@
--AaB03x
Content-Disposition: form-data; name="submit-name"
Larry
--AaB03x
Content-Disposition: form-data; name="files"; filename="file1.txt"
Content-Type: text/plain
contents
--AaB03x--

View file

@ -1 +0,0 @@
log_output

View file

@ -1,31 +0,0 @@
require "#{File.dirname(__FILE__)}/../testrequest"
$stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")
class EnvMiddleware
def initialize(app)
@app = app
end
def call(env)
# provides a way to test that lint is present
if env["PATH_INFO"] == "/broken_lint"
return [200, {}, ["Broken Lint"]]
# provides a way to kill the process without knowing the pid
elsif env["PATH_INFO"] == "/die"
exit!
end
env["test.$DEBUG"] = $DEBUG
env["test.$EVAL"] = BUKKIT if defined?(BUKKIT)
env["test.$VERBOSE"] = $VERBOSE
env["test.$LOAD_PATH"] = $LOAD_PATH
env["test.stderr"] = File.expand_path($stderr.path)
env["test.Ping"] = defined?(Ping)
env["test.pid"] = Process.pid
@app.call(env)
end
end
use EnvMiddleware
run TestRequest.new

View file

@ -1,70 +0,0 @@
require 'rack/auth/basic'
require 'rack/mock'
describe Rack::Auth::Basic do
def realm
'WallysWorld'
end
def unprotected_app
lambda { |env| [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] }
end
def protected_app
app = Rack::Auth::Basic.new(unprotected_app) { |username, password| 'Boss' == username }
app.realm = realm
app
end
before do
@request = Rack::MockRequest.new(protected_app)
end
def request_with_basic_auth(username, password, &block)
request 'HTTP_AUTHORIZATION' => 'Basic ' + ["#{username}:#{password}"].pack("m*"), &block
end
def request(headers = {})
yield @request.get('/', headers)
end
def assert_basic_auth_challenge(response)
response.should.be.a.client_error
response.status.should.equal 401
response.should.include 'WWW-Authenticate'
response.headers['WWW-Authenticate'].should =~ /Basic realm="#{Regexp.escape(realm)}"/
response.body.should.be.empty
end
should 'challenge correctly when no credentials are specified' do
request do |response|
assert_basic_auth_challenge response
end
end
should 'rechallenge if incorrect credentials are specified' do
request_with_basic_auth 'joe', 'password' do |response|
assert_basic_auth_challenge response
end
end
should 'return application output if correct credentials are specified' do
request_with_basic_auth 'Boss', 'password' do |response|
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Boss'
end
end
should 'return 400 Bad Request if different auth scheme used' do
request 'HTTP_AUTHORIZATION' => 'Digest params' do |response|
response.should.be.a.client_error
response.status.should.equal 400
response.should.not.include 'WWW-Authenticate'
end
end
it 'takes realm as optional constructor arg' do
app = Rack::Auth::Basic.new(unprotected_app, realm) { true }
realm.should == app.realm
end
end

View file

@ -1,223 +0,0 @@
require 'rack/auth/digest/md5'
require 'rack/mock'
describe Rack::Auth::Digest::MD5 do
def realm
'WallysWorld'
end
def unprotected_app
lambda do |env|
[ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ]
end
end
def protected_app
app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username|
{ 'Alice' => 'correct-password' }[username]
end
app.realm = realm
app.opaque = 'this-should-be-secret'
app
end
def protected_app_with_hashed_passwords
app = Rack::Auth::Digest::MD5.new(unprotected_app) do |username|
username == 'Alice' ? Digest::MD5.hexdigest("Alice:#{realm}:correct-password") : nil
end
app.realm = realm
app.opaque = 'this-should-be-secret'
app.passwords_hashed = true
app
end
def partially_protected_app
Rack::URLMap.new({
'/' => unprotected_app,
'/protected' => protected_app
})
end
def protected_app_with_method_override
Rack::MethodOverride.new(protected_app)
end
before do
@request = Rack::MockRequest.new(protected_app)
end
def request(method, path, headers = {}, &block)
response = @request.request(method, path, headers)
block.call(response) if block
return response
end
class MockDigestRequest
def initialize(params)
@params = params
end
def method_missing(sym)
if @params.has_key? k = sym.to_s
return @params[k]
end
super
end
def method
@params['method']
end
def response(password)
Rack::Auth::Digest::MD5.new(nil).send :digest, self, password
end
end
def request_with_digest_auth(method, path, username, password, options = {}, &block)
request_options = {}
request_options[:input] = options.delete(:input) if options.include? :input
response = request(method, path, request_options)
return response unless response.status == 401
if wait = options.delete(:wait)
sleep wait
end
challenge = response['WWW-Authenticate'].split(' ', 2).last
params = Rack::Auth::Digest::Params.parse(challenge)
params['username'] = username
params['nc'] = '00000001'
params['cnonce'] = 'nonsensenonce'
params['uri'] = path
params['method'] = method
params.update options
params['response'] = MockDigestRequest.new(params).response(password)
request(method, path, request_options.merge('HTTP_AUTHORIZATION' => "Digest #{params}"), &block)
end
def assert_digest_auth_challenge(response)
response.should.be.a.client_error
response.status.should.equal 401
response.should.include 'WWW-Authenticate'
response.headers['WWW-Authenticate'].should =~ /^Digest /
response.body.should.be.empty
end
def assert_bad_request(response)
response.should.be.a.client_error
response.status.should.equal 400
response.should.not.include 'WWW-Authenticate'
end
should 'challenge when no credentials are specified' do
request 'GET', '/' do |response|
assert_digest_auth_challenge response
end
end
should 'return application output if correct credentials given' do
request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response|
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Alice'
end
end
should 'return application output if correct credentials given (hashed passwords)' do
@request = Rack::MockRequest.new(protected_app_with_hashed_passwords)
request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response|
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Alice'
end
end
should 'rechallenge if incorrect username given' do
request_with_digest_auth 'GET', '/', 'Bob', 'correct-password' do |response|
assert_digest_auth_challenge response
end
end
should 'rechallenge if incorrect password given' do
request_with_digest_auth 'GET', '/', 'Alice', 'wrong-password' do |response|
assert_digest_auth_challenge response
end
end
should 'rechallenge with stale parameter if nonce is stale' do
begin
Rack::Auth::Digest::Nonce.time_limit = 1
request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', :wait => 2 do |response|
assert_digest_auth_challenge response
response.headers['WWW-Authenticate'].should =~ /\bstale=true\b/
end
ensure
Rack::Auth::Digest::Nonce.time_limit = nil
end
end
should 'return 400 Bad Request if incorrect qop given' do
request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'qop' => 'auth-int' do |response|
assert_bad_request response
end
end
should 'return 400 Bad Request if incorrect uri given' do
request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'uri' => '/foo' do |response|
assert_bad_request response
end
end
should 'return 400 Bad Request if different auth scheme used' do
request 'GET', '/', 'HTTP_AUTHORIZATION' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' do |response|
assert_bad_request response
end
end
should 'not require credentials for unprotected path' do
@request = Rack::MockRequest.new(partially_protected_app)
request 'GET', '/' do |response|
response.should.be.ok
end
end
should 'challenge when no credentials are specified for protected path' do
@request = Rack::MockRequest.new(partially_protected_app)
request 'GET', '/protected' do |response|
assert_digest_auth_challenge response
end
end
should 'return application output if correct credentials given for protected path' do
@request = Rack::MockRequest.new(partially_protected_app)
request_with_digest_auth 'GET', '/protected', 'Alice', 'correct-password' do |response|
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Alice'
end
end
should 'return application output if correct credentials given for POST' do
request_with_digest_auth 'POST', '/', 'Alice', 'correct-password' do |response|
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Alice'
end
end
should 'return application output if correct credentials given for PUT (using method override of POST)' do
@request = Rack::MockRequest.new(protected_app_with_method_override)
request_with_digest_auth 'POST', '/', 'Alice', 'correct-password', :input => "_method=put" do |response|
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Alice'
end
end
it 'takes realm as optional constructor arg' do
app = Rack::Auth::Digest::MD5.new(unprotected_app, realm) { true }
realm.should == app.realm
end
end

View file

@ -1,123 +0,0 @@
require 'rack/builder'
require 'rack/mock'
require 'rack/showexceptions'
require 'rack/urlmap'
class NothingMiddleware
def initialize(app)
@app = app
end
def call(env)
@@env = env
response = @app.call(env)
response
end
def self.env
@@env
end
end
describe Rack::Builder do
it "supports mapping" do
app = Rack::Builder.new do
map '/' do |outer_env|
run lambda { |inner_env| [200, {}, ['root']] }
end
map '/sub' do
run lambda { |inner_env| [200, {}, ['sub']] }
end
end.to_app
Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
Rack::MockRequest.new(app).get("/sub").body.to_s.should.equal 'sub'
end
it "doesn't dupe env even when mapping" do
app = Rack::Builder.new do
use NothingMiddleware
map '/' do |outer_env|
run lambda { |inner_env|
inner_env['new_key'] = 'new_value'
[200, {}, ['root']]
}
end
end.to_app
Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
NothingMiddleware.env['new_key'].should.equal 'new_value'
end
it "chains apps by default" do
app = Rack::Builder.new do
use Rack::ShowExceptions
run lambda { |env| raise "bzzzt" }
end.to_app
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
end
it "has implicit #to_app" do
app = Rack::Builder.new do
use Rack::ShowExceptions
run lambda { |env| raise "bzzzt" }
end
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
end
it "supports blocks on use" do
app = Rack::Builder.new do
use Rack::ShowExceptions
use Rack::Auth::Basic do |username, password|
'secret' == password
end
run lambda { |env| [200, {}, ['Hi Boss']] }
end
response = Rack::MockRequest.new(app).get("/")
response.should.be.client_error
response.status.should.equal 401
# with auth...
response = Rack::MockRequest.new(app).get("/",
'HTTP_AUTHORIZATION' => 'Basic ' + ["joe:secret"].pack("m*"))
response.status.should.equal 200
response.body.to_s.should.equal 'Hi Boss'
end
it "has explicit #to_app" do
app = Rack::Builder.app do
use Rack::ShowExceptions
run lambda { |env| raise "bzzzt" }
end
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
Rack::MockRequest.new(app).get("/").should.be.server_error
end
should "initialize apps once" do
app = Rack::Builder.new do
class AppClass
def initialize
@called = 0
end
def call(env)
raise "bzzzt" if @called > 0
@called += 1
[200, {'Content-Type' => 'text/plain'}, ['OK']]
end
end
use Rack::ShowExceptions
run AppClass.new
end
Rack::MockRequest.new(app).get("/").status.should.equal 200
Rack::MockRequest.new(app).get("/").should.be.server_error
end
end

View file

@ -1,45 +0,0 @@
require 'rack/cascade'
require 'rack/file'
require 'rack/urlmap'
require 'rack/mock'
describe Rack::Cascade do
docroot = File.expand_path(File.dirname(__FILE__))
app1 = Rack::File.new(docroot)
app2 = Rack::URLMap.new("/crash" => lambda { |env| raise "boom" })
app3 = Rack::URLMap.new("/foo" => lambda { |env|
[200, { "Content-Type" => "text/plain"}, [""]]})
should "dispatch onward on 404 by default" do
cascade = Rack::Cascade.new([app1, app2, app3])
Rack::MockRequest.new(cascade).get("/cgi/test").should.be.ok
Rack::MockRequest.new(cascade).get("/foo").should.be.ok
Rack::MockRequest.new(cascade).get("/toobad").should.be.not_found
Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.forbidden
end
should "dispatch onward on whatever is passed" do
cascade = Rack::Cascade.new([app1, app2, app3], [404, 403])
Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.not_found
end
should "return 404 if empty" do
Rack::MockRequest.new(Rack::Cascade.new([])).get('/').should.be.not_found
end
should "append new app" do
cascade = Rack::Cascade.new([], [404, 403])
Rack::MockRequest.new(cascade).get('/').should.be.not_found
cascade << app2
Rack::MockRequest.new(cascade).get('/cgi/test').should.be.not_found
Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.not_found
cascade << app1
Rack::MockRequest.new(cascade).get('/cgi/test').should.be.ok
Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.forbidden
Rack::MockRequest.new(cascade).get('/foo').should.be.not_found
cascade << app3
Rack::MockRequest.new(cascade).get('/foo').should.be.ok
end
end

View file

@ -1,100 +0,0 @@
begin
require File.expand_path('../testrequest', __FILE__)
require 'rack/handler/cgi'
describe Rack::Handler::CGI do
extend TestRequest::Helpers
@host = '0.0.0.0'
@port = 9203
if `which lighttpd` && !$?.success?
raise "lighttpd not found"
end
# Keep this first.
$pid = fork {
ENV['RACK_ENV'] = 'deployment'
ENV['RUBYLIB'] = [
File.expand_path('../../lib', __FILE__),
ENV['RUBYLIB'],
].compact.join(':')
Dir.chdir(File.expand_path("../cgi", __FILE__)) do
exec "lighttpd -D -f lighttpd.conf"
end
}
should "respond" do
sleep 1
GET("/test")
response.should.not.be.nil
end
should "be a lighttpd" do
GET("/test")
status.should.equal 200
response["SERVER_SOFTWARE"].should =~ /lighttpd/
response["HTTP_VERSION"].should.equal "HTTP/1.1"
response["SERVER_PROTOCOL"].should.equal "HTTP/1.1"
response["SERVER_PORT"].should.equal @port.to_s
response["SERVER_NAME"].should.equal @host
end
should "have rack headers" do
GET("/test")
response["rack.version"].should.equal([1,1])
response["rack.multithread"].should.be.false
response["rack.multiprocess"].should.be.true
response["rack.run_once"].should.be.true
end
should "have CGI headers on GET" do
GET("/test")
response["REQUEST_METHOD"].should.equal "GET"
response["SCRIPT_NAME"].should.equal "/test"
response["REQUEST_PATH"].should.equal "/"
response["PATH_INFO"].should.be.nil
response["QUERY_STRING"].should.equal ""
response["test.postdata"].should.equal ""
GET("/test/foo?quux=1")
response["REQUEST_METHOD"].should.equal "GET"
response["SCRIPT_NAME"].should.equal "/test"
response["REQUEST_PATH"].should.equal "/"
response["PATH_INFO"].should.equal "/foo"
response["QUERY_STRING"].should.equal "quux=1"
end
should "have CGI headers on POST" do
POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'})
status.should.equal 200
response["REQUEST_METHOD"].should.equal "POST"
response["SCRIPT_NAME"].should.equal "/test"
response["REQUEST_PATH"].should.equal "/"
response["QUERY_STRING"].should.equal ""
response["HTTP_X_TEST_HEADER"].should.equal "42"
response["test.postdata"].should.equal "rack-form-data=23"
end
should "support HTTP auth" do
GET("/test", {:user => "ruth", :passwd => "secret"})
response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ="
end
should "set status" do
GET("/test?secret")
status.should.equal 403
response["rack.url_scheme"].should.equal "http"
end
# Keep this last.
should "shutdown" do
Process.kill 15, $pid
Process.wait($pid).should == $pid
end
end
rescue RuntimeError
$stderr.puts "Skipping Rack::Session::FastCGI tests (lighttpd is required). Install lighttpd and try again."
end

View file

@ -1,60 +0,0 @@
require 'rack/chunked'
require 'rack/mock'
describe Rack::Chunked do
before do
@env = Rack::MockRequest.
env_for('/', 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET')
end
should 'chunk responses with no Content-Length' do
app = lambda { |env| [200, {}, ['Hello', ' ', 'World!']] }
response = Rack::MockResponse.new(*Rack::Chunked.new(app).call(@env))
response.headers.should.not.include 'Content-Length'
response.headers['Transfer-Encoding'].should.equal 'chunked'
response.body.should.equal "5\r\nHello\r\n1\r\n \r\n6\r\nWorld!\r\n0\r\n\r\n"
end
should 'chunks empty bodies properly' do
app = lambda { |env| [200, {}, []] }
response = Rack::MockResponse.new(*Rack::Chunked.new(app).call(@env))
response.headers.should.not.include 'Content-Length'
response.headers['Transfer-Encoding'].should.equal 'chunked'
response.body.should.equal "0\r\n\r\n"
end
should 'not modify response when Content-Length header present' do
app = lambda { |env| [200, {'Content-Length'=>'12'}, ['Hello', ' ', 'World!']] }
status, headers, body = Rack::Chunked.new(app).call(@env)
status.should.equal 200
headers.should.not.include 'Transfer-Encoding'
headers.should.include 'Content-Length'
body.join.should.equal 'Hello World!'
end
should 'not modify response when client is HTTP/1.0' do
app = lambda { |env| [200, {}, ['Hello', ' ', 'World!']] }
@env['HTTP_VERSION'] = 'HTTP/1.0'
status, headers, body = Rack::Chunked.new(app).call(@env)
status.should.equal 200
headers.should.not.include 'Transfer-Encoding'
body.join.should.equal 'Hello World!'
end
should 'not modify response when Transfer-Encoding header already present' do
app = lambda { |env| [200, {'Transfer-Encoding' => 'identity'}, ['Hello', ' ', 'World!']] }
status, headers, body = Rack::Chunked.new(app).call(@env)
status.should.equal 200
headers['Transfer-Encoding'].should.equal 'identity'
body.join.should.equal 'Hello World!'
end
[100, 204, 304].each do |status_code|
should "not modify response when status code is #{status_code}" do
app = lambda { |env| [status_code, {}, []] }
status, headers, body = Rack::Chunked.new(app).call(@env)
status.should.equal status_code
headers.should.not.include 'Transfer-Encoding'
end
end
end

View file

@ -1,56 +0,0 @@
require 'rack/commonlogger'
require 'rack/mock'
describe Rack::CommonLogger do
obj = 'foobar'
length = obj.size
app = lambda { |env|
[200,
{"Content-Type" => "text/html", "Content-Length" => length.to_s},
[obj]]}
app_without_length = lambda { |env|
[200,
{"Content-Type" => "text/html"},
[]]}
app_with_zero_length = lambda { |env|
[200,
{"Content-Type" => "text/html", "Content-Length" => "0"},
[]]}
should "log to rack.errors by default" do
res = Rack::MockRequest.new(Rack::CommonLogger.new(app)).get("/")
res.errors.should.not.be.empty
res.errors.should =~ /"GET \/ " 200 #{length} /
end
should "log to anything with +write+" do
log = StringIO.new
res = Rack::MockRequest.new(Rack::CommonLogger.new(app, log)).get("/")
log.string.should =~ /"GET \/ " 200 #{length} /
end
should "log - content length if header is missing" do
res = Rack::MockRequest.new(Rack::CommonLogger.new(app_without_length)).get("/")
res.errors.should.not.be.empty
res.errors.should =~ /"GET \/ " 200 - /
end
should "log - content length if header is zero" do
res = Rack::MockRequest.new(Rack::CommonLogger.new(app_with_zero_length)).get("/")
res.errors.should.not.be.empty
res.errors.should =~ /"GET \/ " 200 - /
end
def length
123
end
def self.obj
"hello world"
end
end

View file

@ -1,39 +0,0 @@
require 'time'
require 'rack/conditionalget'
require 'rack/mock'
describe Rack::ConditionalGet do
should "set a 304 status and truncate body when If-Modified-Since hits" do
timestamp = Time.now.httpdate
app = Rack::ConditionalGet.new(lambda { |env|
[200, {'Last-Modified'=>timestamp}, ['TEST']] })
response = Rack::MockRequest.new(app).
get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp)
response.status.should.equal 304
response.body.should.be.empty
end
should "set a 304 status and truncate body when If-None-Match hits" do
app = Rack::ConditionalGet.new(lambda { |env|
[200, {'Etag'=>'1234'}, ['TEST']] })
response = Rack::MockRequest.new(app).
get("/", 'HTTP_IF_NONE_MATCH' => '1234')
response.status.should.equal 304
response.body.should.be.empty
end
should "not affect non-GET/HEAD requests" do
app = Rack::ConditionalGet.new(lambda { |env|
[200, {'Etag'=>'1234'}, ['TEST']] })
response = Rack::MockRequest.new(app).
post("/", 'HTTP_IF_NONE_MATCH' => '1234')
response.status.should.equal 200
response.body.should.equal 'TEST'
end
end

View file

@ -1,23 +0,0 @@
require 'rack/builder'
require 'rack/config'
require 'rack/content_length'
require 'rack/lint'
require 'rack/mock'
describe Rack::Config do
should "accept a block that modifies the environment" do
app = Rack::Builder.new do
use Rack::Lint
use Rack::ContentLength
use Rack::Config do |env|
env['greeting'] = 'hello'
end
run lambda { |env|
[200, {'Content-Type' => 'text/plain'}, [env['greeting'] || '']]
}
end
response = Rack::MockRequest.new(app).get('/')
response.body.should.equal('hello')
end
end

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