ry / ebb fork watch download tarball
public this repo is viewable by everyone
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
a few changes to get ebb_rails working again
Ryan Dahl (author)
2 months ago
commit  85308837b343711aa4fbd9777bf7fb2bd8f5a033
tree    e8eba3698f96ac4c60515b96cc891d8d5f6e2370
parent  9c5ab1c13e9097b4f25bd84a4d25c563a51a4eba
...
42
43
44
 
45
46
47
...
42
43
44
45
46
47
48
0
@@ -42,6 +42,7 @@ spec = Gem::Specification.new do |s|
0
                          'ruby_lib/*',
0
                          'benchmark/*.rb',
0
                          'bin/ebb_rails',
0
+ 'VERSION',
0
                          'README')
0
 end
0
 
...
112
113
114
 
 
 
 
 
 
 
 
 
115
116
117
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
0
@@ -112,6 +112,15 @@ class EbbTest < Test::Unit::TestCase
0
   end
0
 end
0
 
0
+class EbbRailsTest < Test::Unit::TestCase
0
+ # just to make sure there isn't some load error
0
+ def test_ebb_rails_version
0
+ out = %x{ruby #{Ebb::LIBDIR}/../bin/ebb_rails -v}
0
+ assert_match %r{Ebb #{Ebb::VERSION}}, out
0
+ end
0
+end
0
+
0
+
0
 #
0
 # class SocketTest < Test::Unit::TestCase
0
 # def test_socket_creation
...
52
53
54
55
 
56
57
58
...
52
53
54
 
55
56
57
58
0
@@ -52,7 +52,7 @@ end
0
 case ARGV[0]
0
   
0
 when 'start'
0
- app = Rack::Adapter::Rails.new(options)
0
+ app = RailsAdapter.new(options)
0
   server = Ebb::Server.new(app, options)
0
   
0
   server.pid_file = options[:pid_file]
...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
 
 
 
 
 
 
 
 
 
 
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
50
 
 
51
52
53
 
 
 
 
 
 
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
63
64
65
 
 
 
 
 
 
 
 
66
67
68
69
70
71
72
73
74
75
76
77
 
 
 
 
 
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 
 
 
94
95
96
97
98
 
 
 
 
 
 
 
 
 
 
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
 
 
124
 
125
126
127
128
129
130
131
132
133
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
136
137
138
 
...
12
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
17
18
19
20
21
22
23
24
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
45
46
47
 
 
48
49
50
51
52
53
54
 
 
 
 
 
 
 
 
55
56
57
58
59
60
61
 
 
62
63
64
65
66
67
68
69
70
 
 
 
 
 
 
 
 
 
 
 
71
72
73
74
75
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
78
79
80
 
 
 
 
81
82
83
84
85
86
87
88
89
90
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
 
 
93
94
95
96
97
98
 
 
 
 
 
 
 
 
 
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 
133
134
135
0
@@ -12,127 +12,124 @@ require 'rack'
0
 # root: Root directory of the Rails app
0
 # env: Rails environment to run in (development, production or test)
0
 # Based on http://fuzed.rubyforge.org/ Rails adapter
0
-module Rack
0
- module Adapter
0
- class Rails
0
- def initialize(options={})
0
- @root = options[:root] || Dir.pwd
0
- @env = options[:env] || 'development'
0
-
0
- load_application
0
-
0
- @file_server = Rack::File.new(::File.join(RAILS_ROOT, "public"))
0
- end
0
-
0
- def load_application
0
- ENV['RAILS_ENV'] = @env
0
+class RailsAdapter
0
+ def initialize(options={})
0
+ @root = options[:root] || Dir.pwd
0
+ @env = options[:env] || 'development'
0
+
0
+ load_application
0
+
0
+ @file_server = Rack::File.new(::File.join(RAILS_ROOT, "public"))
0
+ end
0
+
0
+ def load_application
0
+ ENV['RAILS_ENV'] = @env
0
 
0
- require "#{@root}/config/environment"
0
- require 'dispatcher'
0
- end
0
-
0
- # TODO refactor this in File#can_serve?(path) ??
0
- def file?(path)
0
- full_path = ::File.join(@file_server.root, Utils.unescape(path))
0
- ::File.file?(full_path) && ::File.readable?(full_path)
0
- end
0
-
0
- def call(env)
0
- # Serve the file if it's there
0
- return @file_server.call(env) if file?(env['PATH_INFO'])
0
-
0
- request = Request.new(env)
0
- response = Response.new
0
-
0
- session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
0
- cgi = CGIWrapper.new(request, response)
0
+ require "#{@root}/config/environment"
0
+ require 'dispatcher'
0
+ end
0
+
0
+ # TODO refactor this in File#can_serve?(path) ??
0
+ def file?(path)
0
+ full_path = ::File.join(@file_server.root, Utils.unescape(path))
0
+ ::File.file?(full_path) && ::File.readable?(full_path)
0
+ end
0
+
0
+ def call(env)
0
+ # Serve the file if it's there
0
+ return @file_server.call(env) if file?(env['PATH_INFO'])
0
+
0
+ request = Request.new(env)
0
+ response = Response.new
0
     
0
- Dispatcher.dispatch(cgi, session_options, response)
0
+ session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
0
+ cgi = CGIWrapper.new(request, response)
0
 
0
- response.finish
0
- end
0
+ Dispatcher.dispatch(cgi, session_options, response)
0
+
0
+ response.finish
0
+ end
0
+
0
+ protected
0
     
0
- protected
0
-
0
- class CGIWrapper < ::CGI
0
- def initialize(request, response, *args)
0
- @request = request
0
- @response = response
0
- @args = *args
0
- @input = request.body
0
+ class CGIWrapper < ::CGI
0
+ def initialize(request, response, *args)
0
+ @request = request
0
+ @response = response
0
+ @args = *args
0
+ @input = request.body
0
 
0
- super *args
0
- end
0
+ super *args
0
+ end
0
+
0
+ def header(options = "text/html")
0
+ if options.is_a?(String)
0
+ @response['Content-Type'] = options unless @response['Content-Type']
0
+ else
0
+ @response['Content-Length'] = options.delete('Content-Length').to_s if options['Content-Length']
0
         
0
- def header(options = "text/html")
0
- if options.is_a?(String)
0
- @response['Content-Type'] = options unless @response['Content-Type']
0
- else
0
- @response['Content-Length'] = options.delete('Content-Length').to_s if options['Content-Length']
0
-
0
- @response['Content-Type'] = options.delete('type') || "text/html"
0
- @response['Content-Type'] += "; charset=" + options.delete('charset') if options['charset']
0
-
0
- @response['Content-Language'] = options.delete('language') if options['language']
0
- @response['Expires'] = options.delete('expires') if options['expires']
0
+ @response['Content-Type'] = options.delete('type') || "text/html"
0
+ @response['Content-Type'] += "; charset=" + options.delete('charset') if options['charset']
0
+
0
+ @response['Content-Language'] = options.delete('language') if options['language']
0
+ @response['Expires'] = options.delete('expires') if options['expires']
0
 
0
- @response.status = options.delete('Status') if options['Status']
0
-
0
- options.each { |k,v| @response[k] = v }
0
-
0
- # Convert 'cookie' header to 'Set-Cookie' headers.
0
- # According to http://www.faqs.org/rfcs/rfc2109.html:
0
- # the Set-Cookie response header comprises the token
0
- # Set-Cookie:, followed by a comma-separated list of
0
- # one or more cookies.
0
- if cookie = @response.header.delete('Cookie')
0
- cookies = case cookie
0
- when Array then cookie.collect { |c| c.to_s }.join(', ')
0
- when Hash then cookie.collect { |_, c| c.to_s }.join(', ')
0
- else cookie.to_s
0
- end
0
+ @response.status = options.delete('Status') if options['Status']
0
+
0
+ options.each { |k,v| @response[k] = v }
0
         
0
- cookies << ', ' + @output_cookies.each { |c| c.to_s }.join(', ') if @output_cookies
0
-
0
- @response['Set-Cookie'] = cookies
0
- end
0
+ # Convert 'cookie' header to 'Set-Cookie' headers.
0
+ # According to http://www.faqs.org/rfcs/rfc2109.html:
0
+ # the Set-Cookie response header comprises the token
0
+ # Set-Cookie:, followed by a comma-separated list of
0
+ # one or more cookies.
0
+ if cookie = @response.header.delete('Cookie')
0
+ cookies = case cookie
0
+ when Array then cookie.collect { |c| c.to_s }.join(', ')
0
+ when Hash then cookie.collect { |_, c| c.to_s }.join(', ')
0
+ else cookie.to_s
0
             end
0
-
0
- ""
0
- end
0
-
0
- def params
0
- @params ||= @request.params
0
- end
0
-
0
- def cookies
0
- @request.cookies
0
- end
0
-
0
- def query_string
0
- @request.query_string
0
- end
0
-
0
- # Used to wrap the normal args variable used inside CGI.
0
- def args
0
- @args
0
- end
0
     
0
- # Used to wrap the normal env_table variable used inside CGI.
0
- def env_table
0
- @request.env
0
+ cookies << ', ' + @output_cookies.each { |c| c.to_s }.join(', ') if @output_cookies
0
+
0
+ @response['Set-Cookie'] = cookies
0
           end
0
+ end
0
     
0
- # Used to wrap the normal stdinput variable used inside CGI.
0
- def stdinput
0
- @input
0
- end
0
-
0
- def stdoutput
0
- STDERR.puts "stdoutput should not be used."
0
- @response.body
0
- end
0
+ ""
0
+ end
0
+
0
+ def params
0
+ @params ||= @request.params
0
+ end
0
+
0
+ def cookies
0
+ @request.cookies
0
+ end
0
+
0
+ def query_string
0
+ @request.query_string
0
+ end
0
+
0
+ # Used to wrap the normal args variable used inside CGI.
0
+ def args
0
+ @args
0
+ end
0
+
0
+ # Used to wrap the normal env_table variable used inside CGI.
0
+ def env_table
0
+ @request.env
0
+ end
0
+
0
+ # Used to wrap the normal stdinput variable used inside CGI.
0
+ def stdinput
0
+ @input
0
+ end
0
+
0
+ def stdoutput
0
+ STDERR.puts "stdoutput should not be used."
0
+ @response.body
0
       end
0
- end
0
   end
0
 end
0
+

Comments

    No one has commented yet.