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
small fixes - clean up - tests

added a test for the env object. was forced to marshalling though a 
request
to get access to it. isn't there a better way to do this?
Ryan Dahl (author)
2 months ago
commit  9c5ab1c13e9097b4f25bd84a4d25c563a51a4eba
tree    47d8433728ff80568c415f6d3a27084790742708
parent  833f936c0f410b9c66edcccbceb177f0058bb722
...
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
...
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
0
@@ -13,28 +13,25 @@ Connections are processed as follows:
0
 2. When Ebb can read from a client socket, it passes the buffer into the
0
    mongrel state machine which parses the headers into name value pairs.
0
 
0
-3. Ebb starts passes the request information and peer socket to a user
0
+3. Ebb handles any file uploads
0
+
0
+4. Ebb passes the request information and peer socket to a user
0
    supplied callback.
0
 
0
-4. The included Ruby binding, supplying this callback transforms the request
0
- into a Rack compatible "env" variable and passes it on a Rack adapter.
0
+5. The Ruby binding, ebb_ruby.c, supplying this callback transforms the
0
+ request into a Rack compatible "env" hash and passes it on a Rack
0
+ adapter.
0
 
0
-Because Ebb is written entirely in C, other language bindings can be added to
0
-make it useful to Non-Ruby frameworks. For example a Python WSGI interface is
0
+Because Ebb is written mostly in C, other language bindings can be added to
0
+make it useful to Non-Ruby frameworks. For example, a Python WSGI interface is
0
 forthcoming.
0
 
0
 Ebb aims to be the smallest and fastest web server possible specifically for
0
 doing the processing for web frameworks like Rails.
0
 
0
-It's less than 1000 lines of C code!
0
-
0
-= TODO, ordered
0
-* Log levels
0
+= TODO
0
 * Option to listen on unix sockets instead of tcp
0
-* ebb_merb executable
0
 * Python binding
0
-* Better build system - using scon? (http://www.scons.org/)
0
- Not autoconf.
0
 
0
 = License
0
 
...
1
2
3
4
5
6
 
7
8
9
...
37
38
39
 
 
 
 
 
 
40
41
42
...
94
95
96
 
 
 
 
 
 
 
 
 
 
 
 
97
98
99
...
1
2
3
 
 
 
4
5
6
7
...
35
36
37
38
39
40
41
42
43
44
45
46
...
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
0
@@ -1,9 +1,7 @@
0
 require File.dirname(__FILE__) + '/../ruby_lib/ebb'
0
 require 'test/unit'
0
 require 'net/http'
0
-require 'rubygems'
0
-require 'ruby-debug'
0
-Debugger.start
0
+require 'base64'
0
 
0
 
0
 class EbbTest < Test::Unit::TestCase
0
@@ -37,6 +35,12 @@ class EbbTest < Test::Unit::TestCase
0
       raise "bytes called with n <= 0" if n <= 0
0
       body = @@responses[n] || "C"*n
0
       status = 200
0
+
0
+ elsif commands.include?('env')
0
+ env.delete('rack.input') # delete this because it's hard to marshal
0
+ env.delete('rack.errors')
0
+ body = Base64.encode64(Marshal.dump(env))
0
+ status = 200
0
       
0
     elsif commands.include?('test_post_length')
0
       input_body = ""
0
@@ -94,6 +98,18 @@ class EbbTest < Test::Unit::TestCase
0
     response = post("/test_post_length", 'C'*1024*15)
0
     assert_equal 200, response.code.to_i, response.body
0
   end
0
+
0
+ def test_env
0
+ response = get('/env')
0
+ env = Marshal.load(Base64.decode64(response.body))
0
+ assert_equal '/env', env['PATH_INFO']
0
+ assert_equal '/env', env['REQUEST_PATH']
0
+ assert_equal 'HTTP/1.1', env['SERVER_PROTOCOL']
0
+ assert_equal 'CGI/1.2', env['GATEWAY_INTERFACE']
0
+ assert_equal '0.0.0.0', env['SERVER_NAME']
0
+ assert_equal '4044', env['SERVER_PORT']
0
+ assert_equal 'GET', env['REQUEST_METHOD']
0
+ end
0
 end
0
 
0
 #
...
1
2
 
3
4
5
...
1
2
3
4
5
6
0
@@ -1,5 +1,6 @@
0
 #!/usr/bin/env ruby
0
 require File.dirname(__FILE__) + '/../ruby_lib/ebb'
0
+require File.dirname(__FILE__) + '/../ruby_lib/rails_adapter'
0
 require 'optparse'
0
 
0
 options = {
...
2
3
4
5
 
6
7
8
9
10
11
 
12
13
14
...
171
172
173
174
175
176
177
178
179
180
 
181
...
2
3
4
 
5
6
7
8
 
9
 
10
11
12
13
...
170
171
172
 
 
 
 
 
 
 
173
174
0
@@ -2,13 +2,12 @@
0
 # Copyright (c) 2007 Ry Dahl <ry.d4hl@gmail.com>
0
 # This software is released under the "MIT License". See README file for details.
0
 module Ebb
0
- LIBDIR = File.expand_path(File.dirname(__FILE__))
0
+ LIBDIR = File.dirname(__FILE__)
0
   VERSION = File.read(LIBDIR + "/../VERSION").gsub(/\s/,'')
0
 end
0
 
0
-$: << Ebb::LIBDIR
0
 require Ebb::LIBDIR + '/../src/ebb_ext'
0
-require 'daemonizable'
0
+require Ebb::LIBDIR + '/daemonizable'
0
 
0
 module Ebb
0
   class Client
0
@@ -171,10 +170,4 @@ module Ebb
0
     504 => 'Gateway Time-out',
0
     505 => 'HTTP Version not supported'
0
   }.freeze
0
-end
0
-
0
-module Rack
0
- module Adapter
0
- autoload :Rails, 'rails_adapter'
0
- end
0
-end
0
+end
0
\ No newline at end of file
...
155
156
157
158
 
159
160
161
...
155
156
157
 
158
159
160
161
0
@@ -155,7 +155,7 @@ void dispatch(ebb_client *client)
0
   if(server->port) {
0
     env_add_const(client, EBB_SERVER_NAME
0
                         , localhost_str
0
- , 8
0
+ , 7
0
                         );
0
     env_add_const(client, EBB_SERVER_PORT
0
                         , server->port

Comments

    No one has commented yet.