passenger 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (160) hide show
  1. data/NEWS +40 -0
  2. data/Rakefile +1 -1
  3. data/bin/passenger-install-apache2-module +1 -0
  4. data/bin/passenger-install-nginx-module +2 -0
  5. data/doc/Architectural overview.html +173 -138
  6. data/doc/Security of user switching support.html +147 -109
  7. data/doc/Users guide Apache.html +4 -43
  8. data/doc/Users guide Nginx.html +4 -43
  9. data/doc/cxxapi/Bucket_8h-source.html +1 -1
  10. data/doc/cxxapi/Configuration_8h-source.html +1 -1
  11. data/doc/cxxapi/DirectoryMapper_8h-source.html +1 -1
  12. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  13. data/doc/cxxapi/annotated.html +1 -1
  14. data/doc/cxxapi/classHooks-members.html +1 -1
  15. data/doc/cxxapi/classHooks.html +1 -1
  16. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +1 -1
  17. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +1 -1
  18. data/doc/cxxapi/classes.html +1 -1
  19. data/doc/cxxapi/definitions_8h-source.html +1 -1
  20. data/doc/cxxapi/files.html +1 -1
  21. data/doc/cxxapi/functions.html +1 -1
  22. data/doc/cxxapi/functions_func.html +1 -1
  23. data/doc/cxxapi/graph_legend.html +1 -1
  24. data/doc/cxxapi/group__Configuration.html +1 -1
  25. data/doc/cxxapi/group__Core.html +1 -1
  26. data/doc/cxxapi/group__Hooks.html +1 -1
  27. data/doc/cxxapi/group__Support.html +1 -1
  28. data/doc/cxxapi/main.html +1 -1
  29. data/doc/cxxapi/modules.html +1 -1
  30. data/doc/rdoc/classes/GC.html +4 -4
  31. data/doc/rdoc/classes/PhusionPassenger.html +2 -1
  32. data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +8 -8
  33. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +26 -26
  34. data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +98 -98
  35. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +61 -61
  36. data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +4 -4
  37. data/doc/rdoc/classes/PhusionPassenger/Application.html +14 -14
  38. data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +12 -12
  39. data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +4 -4
  40. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +12 -12
  41. data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +5 -5
  42. data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +42 -42
  43. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +33 -33
  44. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +59 -59
  45. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +3 -3
  46. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +7 -7
  47. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +23 -23
  48. data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +4 -4
  49. data/doc/rdoc/classes/PhusionPassenger/Utils.html +2 -0
  50. data/doc/rdoc/classes/PhusionPassenger/Utils/PseudoIO.html +16 -16
  51. data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +4 -4
  52. data/doc/rdoc/classes/PlatformInfo.html +1 -1
  53. data/doc/rdoc/classes/Signal.html +23 -15
  54. data/doc/rdoc/created.rid +1 -1
  55. data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
  56. data/doc/rdoc/files/README.html +1 -1
  57. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +1 -1
  58. data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +1 -1
  59. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +1 -1
  60. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +1 -1
  61. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +1 -1
  62. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +1 -1
  63. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +1 -1
  64. data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +1 -1
  65. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +1 -1
  66. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +1 -1
  67. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +1 -1
  68. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +1 -1
  69. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +1 -1
  70. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +1 -1
  71. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +1 -1
  72. data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +1 -1
  73. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +1 -1
  74. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +2 -2
  75. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +2 -2
  76. data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +1 -1
  77. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +1 -1
  78. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +1 -1
  79. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +1 -1
  80. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +1 -1
  81. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +1 -1
  82. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +9 -9
  83. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +1 -1
  84. data/doc/rdoc/files/misc/rake/extensions_rb.html +1 -1
  85. data/doc/rdoc/fr_class_index.html +2 -0
  86. data/doc/rdoc/fr_file_index.html +1 -0
  87. data/doc/rdoc/fr_method_index.html +79 -72
  88. data/ext/apache2/Hooks.cpp +4 -2
  89. data/ext/common/StandardApplicationPool.h +4 -2
  90. data/ext/common/Version.h +1 -1
  91. data/ext/nginx/Configuration.c +1 -1
  92. data/ext/oxt/system_calls.cpp +11 -0
  93. data/ext/oxt/system_calls.hpp +2 -1
  94. data/ext/oxt/thread.hpp +97 -1
  95. data/lib/phusion_passenger/constants.rb +1 -1
  96. data/lib/phusion_passenger/dependencies.rb +32 -0
  97. data/lib/phusion_passenger/platform_info.rb +1 -1
  98. data/lib/phusion_passenger/rack/application_spawner.rb +4 -4
  99. data/lib/phusion_passenger/rack/request_handler.rb +2 -5
  100. data/lib/phusion_passenger/railz/application_spawner.rb +13 -2
  101. data/lib/phusion_passenger/utils.rb +12 -4
  102. data/{vendor/rack-1.0.0-git/lib/rack → lib/phusion_passenger/utils}/rewindable_input.rb +19 -3
  103. data/test/ApplicationPoolTest.cpp +1 -1
  104. metadata +13 -59
  105. data/vendor/README +0 -13
  106. data/vendor/README_FOR_PACKAGERS +0 -1
  107. data/vendor/rack-1.0.0-git/COPYING +0 -18
  108. data/vendor/rack-1.0.0-git/KNOWN-ISSUES +0 -18
  109. data/vendor/rack-1.0.0-git/README +0 -353
  110. data/vendor/rack-1.0.0-git/Rakefile +0 -164
  111. data/vendor/rack-1.0.0-git/lib/rack.rb +0 -90
  112. data/vendor/rack-1.0.0-git/lib/rack/adapter/camping.rb +0 -22
  113. data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/handler.rb +0 -37
  114. data/vendor/rack-1.0.0-git/lib/rack/auth/abstract/request.rb +0 -37
  115. data/vendor/rack-1.0.0-git/lib/rack/auth/basic.rb +0 -58
  116. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/md5.rb +0 -124
  117. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/nonce.rb +0 -51
  118. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/params.rb +0 -55
  119. data/vendor/rack-1.0.0-git/lib/rack/auth/digest/request.rb +0 -40
  120. data/vendor/rack-1.0.0-git/lib/rack/auth/openid.rb +0 -487
  121. data/vendor/rack-1.0.0-git/lib/rack/builder.rb +0 -63
  122. data/vendor/rack-1.0.0-git/lib/rack/cascade.rb +0 -41
  123. data/vendor/rack-1.0.0-git/lib/rack/chunked.rb +0 -49
  124. data/vendor/rack-1.0.0-git/lib/rack/commonlogger.rb +0 -52
  125. data/vendor/rack-1.0.0-git/lib/rack/conditionalget.rb +0 -47
  126. data/vendor/rack-1.0.0-git/lib/rack/content_length.rb +0 -29
  127. data/vendor/rack-1.0.0-git/lib/rack/content_type.rb +0 -23
  128. data/vendor/rack-1.0.0-git/lib/rack/deflater.rb +0 -96
  129. data/vendor/rack-1.0.0-git/lib/rack/directory.rb +0 -153
  130. data/vendor/rack-1.0.0-git/lib/rack/file.rb +0 -88
  131. data/vendor/rack-1.0.0-git/lib/rack/handler.rb +0 -69
  132. data/vendor/rack-1.0.0-git/lib/rack/handler/cgi.rb +0 -61
  133. data/vendor/rack-1.0.0-git/lib/rack/handler/evented_mongrel.rb +0 -8
  134. data/vendor/rack-1.0.0-git/lib/rack/handler/fastcgi.rb +0 -88
  135. data/vendor/rack-1.0.0-git/lib/rack/handler/lsws.rb +0 -55
  136. data/vendor/rack-1.0.0-git/lib/rack/handler/mongrel.rb +0 -84
  137. data/vendor/rack-1.0.0-git/lib/rack/handler/scgi.rb +0 -59
  138. data/vendor/rack-1.0.0-git/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  139. data/vendor/rack-1.0.0-git/lib/rack/handler/thin.rb +0 -18
  140. data/vendor/rack-1.0.0-git/lib/rack/handler/webrick.rb +0 -67
  141. data/vendor/rack-1.0.0-git/lib/rack/head.rb +0 -19
  142. data/vendor/rack-1.0.0-git/lib/rack/lint.rb +0 -537
  143. data/vendor/rack-1.0.0-git/lib/rack/lobster.rb +0 -65
  144. data/vendor/rack-1.0.0-git/lib/rack/lock.rb +0 -16
  145. data/vendor/rack-1.0.0-git/lib/rack/methodoverride.rb +0 -27
  146. data/vendor/rack-1.0.0-git/lib/rack/mime.rb +0 -204
  147. data/vendor/rack-1.0.0-git/lib/rack/mock.rb +0 -184
  148. data/vendor/rack-1.0.0-git/lib/rack/recursive.rb +0 -57
  149. data/vendor/rack-1.0.0-git/lib/rack/reloader.rb +0 -106
  150. data/vendor/rack-1.0.0-git/lib/rack/request.rb +0 -248
  151. data/vendor/rack-1.0.0-git/lib/rack/response.rb +0 -183
  152. data/vendor/rack-1.0.0-git/lib/rack/session/abstract/id.rb +0 -142
  153. data/vendor/rack-1.0.0-git/lib/rack/session/cookie.rb +0 -91
  154. data/vendor/rack-1.0.0-git/lib/rack/session/memcache.rb +0 -109
  155. data/vendor/rack-1.0.0-git/lib/rack/session/pool.rb +0 -100
  156. data/vendor/rack-1.0.0-git/lib/rack/showexceptions.rb +0 -349
  157. data/vendor/rack-1.0.0-git/lib/rack/showstatus.rb +0 -106
  158. data/vendor/rack-1.0.0-git/lib/rack/static.rb +0 -38
  159. data/vendor/rack-1.0.0-git/lib/rack/urlmap.rb +0 -55
  160. data/vendor/rack-1.0.0-git/lib/rack/utils.rb +0 -522
@@ -1,65 +0,0 @@
1
- require 'zlib'
2
-
3
- require 'rack/request'
4
- require 'rack/response'
5
-
6
- module Rack
7
- # Paste has a Pony, Rack has a Lobster!
8
- class Lobster
9
- LobsterString = Zlib::Inflate.inflate("eJx9kEEOwyAMBO99xd7MAcytUhPlJyj2
10
- P6jy9i4k9EQyGAnBarEXeCBqSkntNXsi/ZCvC48zGQoZKikGrFMZvgS5ZHd+aGWVuWwhVF0
11
- t1drVmiR42HcWNz5w3QanT+2gIvTVCiE1lm1Y0eU4JGmIIbaKwextKn8rvW+p5PIwFl8ZWJ
12
- I8jyiTlhTcYXkekJAzTyYN6E08A+dk8voBkAVTJQ==".delete("\n ").unpack("m*")[0])
13
-
14
- LambdaLobster = lambda { |env|
15
- if env["QUERY_STRING"].include?("flip")
16
- lobster = LobsterString.split("\n").
17
- map { |line| line.ljust(42).reverse }.
18
- join("\n")
19
- href = "?"
20
- else
21
- lobster = LobsterString
22
- href = "?flip"
23
- end
24
-
25
- content = ["<title>Lobstericious!</title>",
26
- "<pre>", lobster, "</pre>",
27
- "<a href='#{href}'>flip!</a>"]
28
- length = content.inject(0) { |a,e| a+e.size }.to_s
29
- [200, {"Content-Type" => "text/html", "Content-Length" => length}, content]
30
- }
31
-
32
- def call(env)
33
- req = Request.new(env)
34
- if req.GET["flip"] == "left"
35
- lobster = LobsterString.split("\n").
36
- map { |line| line.ljust(42).reverse }.
37
- join("\n")
38
- href = "?flip=right"
39
- elsif req.GET["flip"] == "crash"
40
- raise "Lobster crashed"
41
- else
42
- lobster = LobsterString
43
- href = "?flip=left"
44
- end
45
-
46
- res = Response.new
47
- res.write "<title>Lobstericious!</title>"
48
- res.write "<pre>"
49
- res.write lobster
50
- res.write "</pre>"
51
- res.write "<p><a href='#{href}'>flip!</a></p>"
52
- res.write "<p><a href='?flip=crash'>crash!</a></p>"
53
- res.finish
54
- end
55
-
56
- end
57
- end
58
-
59
- if $0 == __FILE__
60
- require 'rack'
61
- require 'rack/showexceptions'
62
- Rack::Handler::WEBrick.run \
63
- Rack::ShowExceptions.new(Rack::Lint.new(Rack::Lobster.new)),
64
- :Port => 9292
65
- end
@@ -1,16 +0,0 @@
1
- module Rack
2
- class Lock
3
- FLAG = 'rack.multithread'.freeze
4
-
5
- def initialize(app, lock = Mutex.new)
6
- @app, @lock = app, lock
7
- end
8
-
9
- def call(env)
10
- old, env[FLAG] = env[FLAG], false
11
- @lock.synchronize { @app.call(env) }
12
- ensure
13
- env[FLAG] = old
14
- end
15
- end
16
- end
@@ -1,27 +0,0 @@
1
- module Rack
2
- class MethodOverride
3
- HTTP_METHODS = %w(GET HEAD PUT POST DELETE OPTIONS)
4
-
5
- METHOD_OVERRIDE_PARAM_KEY = "_method".freeze
6
- HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze
7
-
8
- def initialize(app)
9
- @app = app
10
- end
11
-
12
- def call(env)
13
- if env["REQUEST_METHOD"] == "POST"
14
- req = Request.new(env)
15
- method = req.POST[METHOD_OVERRIDE_PARAM_KEY] ||
16
- env[HTTP_METHOD_OVERRIDE_HEADER]
17
- method = method.to_s.upcase
18
- if HTTP_METHODS.include?(method)
19
- env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
20
- env["REQUEST_METHOD"] = method
21
- end
22
- end
23
-
24
- @app.call(env)
25
- end
26
- end
27
- end
@@ -1,204 +0,0 @@
1
- module Rack
2
- module Mime
3
- # Returns String with mime type if found, otherwise use +fallback+.
4
- # +ext+ should be filename extension in the '.ext' format that
5
- # File.extname(file) returns.
6
- # +fallback+ may be any object
7
- #
8
- # Also see the documentation for MIME_TYPES
9
- #
10
- # Usage:
11
- # Rack::Mime.mime_type('.foo')
12
- #
13
- # This is a shortcut for:
14
- # Rack::Mime::MIME_TYPES.fetch('.foo', 'application/octet-stream')
15
-
16
- def mime_type(ext, fallback='application/octet-stream')
17
- MIME_TYPES.fetch(ext, fallback)
18
- end
19
- module_function :mime_type
20
-
21
- # List of most common mime-types, selected various sources
22
- # according to their usefulness in a webserving scope for Ruby
23
- # users.
24
- #
25
- # To amend this list with your local mime.types list you can use:
26
- #
27
- # require 'webrick/httputils'
28
- # list = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types')
29
- # Rack::Mime::MIME_TYPES.merge!(list)
30
- #
31
- # To add the list mongrel provides, use:
32
- #
33
- # require 'mongrel/handlers'
34
- # Rack::Mime::MIME_TYPES.merge!(Mongrel::DirHandler::MIME_TYPES)
35
-
36
- MIME_TYPES = {
37
- ".3gp" => "video/3gpp",
38
- ".a" => "application/octet-stream",
39
- ".ai" => "application/postscript",
40
- ".aif" => "audio/x-aiff",
41
- ".aiff" => "audio/x-aiff",
42
- ".asc" => "application/pgp-signature",
43
- ".asf" => "video/x-ms-asf",
44
- ".asm" => "text/x-asm",
45
- ".asx" => "video/x-ms-asf",
46
- ".atom" => "application/atom+xml",
47
- ".au" => "audio/basic",
48
- ".avi" => "video/x-msvideo",
49
- ".bat" => "application/x-msdownload",
50
- ".bin" => "application/octet-stream",
51
- ".bmp" => "image/bmp",
52
- ".bz2" => "application/x-bzip2",
53
- ".c" => "text/x-c",
54
- ".cab" => "application/vnd.ms-cab-compressed",
55
- ".cc" => "text/x-c",
56
- ".chm" => "application/vnd.ms-htmlhelp",
57
- ".class" => "application/octet-stream",
58
- ".com" => "application/x-msdownload",
59
- ".conf" => "text/plain",
60
- ".cpp" => "text/x-c",
61
- ".crt" => "application/x-x509-ca-cert",
62
- ".css" => "text/css",
63
- ".csv" => "text/csv",
64
- ".cxx" => "text/x-c",
65
- ".deb" => "application/x-debian-package",
66
- ".der" => "application/x-x509-ca-cert",
67
- ".diff" => "text/x-diff",
68
- ".djv" => "image/vnd.djvu",
69
- ".djvu" => "image/vnd.djvu",
70
- ".dll" => "application/x-msdownload",
71
- ".dmg" => "application/octet-stream",
72
- ".doc" => "application/msword",
73
- ".dot" => "application/msword",
74
- ".dtd" => "application/xml-dtd",
75
- ".dvi" => "application/x-dvi",
76
- ".ear" => "application/java-archive",
77
- ".eml" => "message/rfc822",
78
- ".eps" => "application/postscript",
79
- ".exe" => "application/x-msdownload",
80
- ".f" => "text/x-fortran",
81
- ".f77" => "text/x-fortran",
82
- ".f90" => "text/x-fortran",
83
- ".flv" => "video/x-flv",
84
- ".for" => "text/x-fortran",
85
- ".gem" => "application/octet-stream",
86
- ".gemspec" => "text/x-script.ruby",
87
- ".gif" => "image/gif",
88
- ".gz" => "application/x-gzip",
89
- ".h" => "text/x-c",
90
- ".hh" => "text/x-c",
91
- ".htm" => "text/html",
92
- ".html" => "text/html",
93
- ".ico" => "image/vnd.microsoft.icon",
94
- ".ics" => "text/calendar",
95
- ".ifb" => "text/calendar",
96
- ".iso" => "application/octet-stream",
97
- ".jar" => "application/java-archive",
98
- ".java" => "text/x-java-source",
99
- ".jnlp" => "application/x-java-jnlp-file",
100
- ".jpeg" => "image/jpeg",
101
- ".jpg" => "image/jpeg",
102
- ".js" => "application/javascript",
103
- ".json" => "application/json",
104
- ".log" => "text/plain",
105
- ".m3u" => "audio/x-mpegurl",
106
- ".m4v" => "video/mp4",
107
- ".man" => "text/troff",
108
- ".mathml" => "application/mathml+xml",
109
- ".mbox" => "application/mbox",
110
- ".mdoc" => "text/troff",
111
- ".me" => "text/troff",
112
- ".mid" => "audio/midi",
113
- ".midi" => "audio/midi",
114
- ".mime" => "message/rfc822",
115
- ".mml" => "application/mathml+xml",
116
- ".mng" => "video/x-mng",
117
- ".mov" => "video/quicktime",
118
- ".mp3" => "audio/mpeg",
119
- ".mp4" => "video/mp4",
120
- ".mp4v" => "video/mp4",
121
- ".mpeg" => "video/mpeg",
122
- ".mpg" => "video/mpeg",
123
- ".ms" => "text/troff",
124
- ".msi" => "application/x-msdownload",
125
- ".odp" => "application/vnd.oasis.opendocument.presentation",
126
- ".ods" => "application/vnd.oasis.opendocument.spreadsheet",
127
- ".odt" => "application/vnd.oasis.opendocument.text",
128
- ".ogg" => "application/ogg",
129
- ".p" => "text/x-pascal",
130
- ".pas" => "text/x-pascal",
131
- ".pbm" => "image/x-portable-bitmap",
132
- ".pdf" => "application/pdf",
133
- ".pem" => "application/x-x509-ca-cert",
134
- ".pgm" => "image/x-portable-graymap",
135
- ".pgp" => "application/pgp-encrypted",
136
- ".pkg" => "application/octet-stream",
137
- ".pl" => "text/x-script.perl",
138
- ".pm" => "text/x-script.perl-module",
139
- ".png" => "image/png",
140
- ".pnm" => "image/x-portable-anymap",
141
- ".ppm" => "image/x-portable-pixmap",
142
- ".pps" => "application/vnd.ms-powerpoint",
143
- ".ppt" => "application/vnd.ms-powerpoint",
144
- ".ps" => "application/postscript",
145
- ".psd" => "image/vnd.adobe.photoshop",
146
- ".py" => "text/x-script.python",
147
- ".qt" => "video/quicktime",
148
- ".ra" => "audio/x-pn-realaudio",
149
- ".rake" => "text/x-script.ruby",
150
- ".ram" => "audio/x-pn-realaudio",
151
- ".rar" => "application/x-rar-compressed",
152
- ".rb" => "text/x-script.ruby",
153
- ".rdf" => "application/rdf+xml",
154
- ".roff" => "text/troff",
155
- ".rpm" => "application/x-redhat-package-manager",
156
- ".rss" => "application/rss+xml",
157
- ".rtf" => "application/rtf",
158
- ".ru" => "text/x-script.ruby",
159
- ".s" => "text/x-asm",
160
- ".sgm" => "text/sgml",
161
- ".sgml" => "text/sgml",
162
- ".sh" => "application/x-sh",
163
- ".sig" => "application/pgp-signature",
164
- ".snd" => "audio/basic",
165
- ".so" => "application/octet-stream",
166
- ".svg" => "image/svg+xml",
167
- ".svgz" => "image/svg+xml",
168
- ".swf" => "application/x-shockwave-flash",
169
- ".t" => "text/troff",
170
- ".tar" => "application/x-tar",
171
- ".tbz" => "application/x-bzip-compressed-tar",
172
- ".tcl" => "application/x-tcl",
173
- ".tex" => "application/x-tex",
174
- ".texi" => "application/x-texinfo",
175
- ".texinfo" => "application/x-texinfo",
176
- ".text" => "text/plain",
177
- ".tif" => "image/tiff",
178
- ".tiff" => "image/tiff",
179
- ".torrent" => "application/x-bittorrent",
180
- ".tr" => "text/troff",
181
- ".txt" => "text/plain",
182
- ".vcf" => "text/x-vcard",
183
- ".vcs" => "text/x-vcalendar",
184
- ".vrml" => "model/vrml",
185
- ".war" => "application/java-archive",
186
- ".wav" => "audio/x-wav",
187
- ".wma" => "audio/x-ms-wma",
188
- ".wmv" => "video/x-ms-wmv",
189
- ".wmx" => "video/x-ms-wmx",
190
- ".wrl" => "model/vrml",
191
- ".wsdl" => "application/wsdl+xml",
192
- ".xbm" => "image/x-xbitmap",
193
- ".xhtml" => "application/xhtml+xml",
194
- ".xls" => "application/vnd.ms-excel",
195
- ".xml" => "application/xml",
196
- ".xpm" => "image/x-xpixmap",
197
- ".xsl" => "application/xml",
198
- ".xslt" => "application/xslt+xml",
199
- ".yaml" => "text/yaml",
200
- ".yml" => "text/yaml",
201
- ".zip" => "application/zip",
202
- }
203
- end
204
- end
@@ -1,184 +0,0 @@
1
- require 'uri'
2
- require 'stringio'
3
- require 'rack/lint'
4
- require 'rack/utils'
5
- require 'rack/response'
6
-
7
- module Rack
8
- # Rack::MockRequest helps testing your Rack application without
9
- # actually using HTTP.
10
- #
11
- # After performing a request on a URL with get/post/put/delete, it
12
- # returns a MockResponse with useful helper methods for effective
13
- # testing.
14
- #
15
- # You can pass a hash with additional configuration to the
16
- # get/post/put/delete.
17
- # <tt>:input</tt>:: A String or IO-like to be used as rack.input.
18
- # <tt>:fatal</tt>:: Raise a FatalWarning if the app writes to rack.errors.
19
- # <tt>:lint</tt>:: If true, wrap the application in a Rack::Lint.
20
-
21
- class MockRequest
22
- class FatalWarning < RuntimeError
23
- end
24
-
25
- class FatalWarner
26
- def puts(warning)
27
- raise FatalWarning, warning
28
- end
29
-
30
- def write(warning)
31
- raise FatalWarning, warning
32
- end
33
-
34
- def flush
35
- end
36
-
37
- def string
38
- ""
39
- end
40
- end
41
-
42
- DEFAULT_ENV = {
43
- "rack.version" => [1,0],
44
- "rack.input" => StringIO.new,
45
- "rack.errors" => StringIO.new,
46
- "rack.multithread" => true,
47
- "rack.multiprocess" => true,
48
- "rack.run_once" => false,
49
- }
50
-
51
- def initialize(app)
52
- @app = app
53
- end
54
-
55
- def get(uri, opts={}) request("GET", uri, opts) end
56
- def post(uri, opts={}) request("POST", uri, opts) end
57
- def put(uri, opts={}) request("PUT", uri, opts) end
58
- def delete(uri, opts={}) request("DELETE", uri, opts) end
59
-
60
- def request(method="GET", uri="", opts={})
61
- env = self.class.env_for(uri, opts.merge(:method => method))
62
-
63
- if opts[:lint]
64
- app = Rack::Lint.new(@app)
65
- else
66
- app = @app
67
- end
68
-
69
- errors = env["rack.errors"]
70
- MockResponse.new(*(app.call(env) + [errors]))
71
- end
72
-
73
- # Return the Rack environment used for a request to +uri+.
74
- def self.env_for(uri="", opts={})
75
- uri = URI(uri)
76
- uri.path = "/#{uri.path}" unless uri.path[0] == ?/
77
-
78
- env = DEFAULT_ENV.dup
79
-
80
- env["REQUEST_METHOD"] = opts[:method] ? opts[:method].to_s.upcase : "GET"
81
- env["SERVER_NAME"] = uri.host || "example.org"
82
- env["SERVER_PORT"] = uri.port ? uri.port.to_s : "80"
83
- env["QUERY_STRING"] = uri.query.to_s
84
- env["PATH_INFO"] = (!uri.path || uri.path.empty?) ? "/" : uri.path
85
- env["rack.url_scheme"] = uri.scheme || "http"
86
- env["HTTPS"] = env["rack.url_scheme"] == "https" ? "on" : "off"
87
-
88
- env["SCRIPT_NAME"] = opts[:script_name] || ""
89
-
90
- if opts[:fatal]
91
- env["rack.errors"] = FatalWarner.new
92
- else
93
- env["rack.errors"] = StringIO.new
94
- end
95
-
96
- if params = opts[:params]
97
- if env["REQUEST_METHOD"] == "GET"
98
- params = Utils.parse_nested_query(params) if params.is_a?(String)
99
- params.update(Utils.parse_nested_query(env["QUERY_STRING"]))
100
- env["QUERY_STRING"] = Utils.build_nested_query(params)
101
- elsif !opts.has_key?(:input)
102
- opts["CONTENT_TYPE"] = "application/x-www-form-urlencoded"
103
- if params.is_a?(Hash)
104
- if data = Utils::Multipart.build_multipart(params)
105
- opts[:input] = data
106
- opts["CONTENT_LENGTH"] ||= data.length.to_s
107
- opts["CONTENT_TYPE"] = "multipart/form-data; boundary=#{Utils::Multipart::MULTIPART_BOUNDARY}"
108
- else
109
- opts[:input] = Utils.build_nested_query(params)
110
- end
111
- else
112
- opts[:input] = params
113
- end
114
- end
115
- end
116
-
117
- opts[:input] ||= ""
118
- if String === opts[:input]
119
- env["rack.input"] = StringIO.new(opts[:input])
120
- else
121
- env["rack.input"] = opts[:input]
122
- end
123
-
124
- env["CONTENT_LENGTH"] ||= env["rack.input"].length.to_s
125
-
126
- opts.each { |field, value|
127
- env[field] = value if String === field
128
- }
129
-
130
- env
131
- end
132
- end
133
-
134
- # Rack::MockResponse provides useful helpers for testing your apps.
135
- # Usually, you don't create the MockResponse on your own, but use
136
- # MockRequest.
137
-
138
- class MockResponse
139
- def initialize(status, headers, body, errors=StringIO.new(""))
140
- @status = status.to_i
141
-
142
- @original_headers = headers
143
- @headers = Rack::Utils::HeaderHash.new
144
- headers.each { |field, values|
145
- @headers[field] = values
146
- @headers[field] = "" if values.empty?
147
- }
148
-
149
- @body = ""
150
- body.each { |part| @body << part }
151
-
152
- @errors = errors.string if errors.respond_to?(:string)
153
- end
154
-
155
- # Status
156
- attr_reader :status
157
-
158
- # Headers
159
- attr_reader :headers, :original_headers
160
-
161
- def [](field)
162
- headers[field]
163
- end
164
-
165
-
166
- # Body
167
- attr_reader :body
168
-
169
- def =~(other)
170
- @body =~ other
171
- end
172
-
173
- def match(other)
174
- @body.match other
175
- end
176
-
177
-
178
- # Errors
179
- attr_accessor :errors
180
-
181
-
182
- include Response::Helpers
183
- end
184
- end