ry / ebb fork watch download tarball
public
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
Search Repo:
Move version into ebb.h and other misc cleanups
Ryan Dahl (author)
Wed Mar 12 18:02:12 -0700 2008
commit  0b99f32b9ab81caeded14787715248be370b3b22
tree    fec1fad101d7b74fe409e792d025d4f4efaa5423
parent  16283806a21a4989aae8bbc8cbc3558f6a36db90
...
81
82
83
84
 
85
86
87
...
101
102
103
104
105
106
107
108
109
 
110
...
81
82
83
 
84
85
86
87
...
101
102
103
 
 
 
 
 
 
104
105
0
@@ -81,7 +81,7 @@
0
   s.author = 'ry dahl'
0
   s.email = 'ry at tiny clouds dot org'
0
   s.homepage = 'http://ebb.rubyforge.org'
0
- s.version = File.read(dir("VERSION")).gsub(/\s/,'')
0
+ s.version = `grep EBB_VERSION #{dir('src/ebb.h')}`.match(/\d.\d.\d/)[0]
0
   s.rubyforge_project = 'ebb'
0
   
0
   s.add_dependency('rack')
0
@@ -101,11 +101,6 @@
0
 
0
 ## Compile
0
 file('src/parser.c' => 'src/parser.rl') do
0
- #sh "ragel src/parser.rl | rlgen-cd -G2 -o src/parser.c" # ragel 5
0
- sh 'ragel -G2 src/parser.rl' # ragel 6
0
-end
0
-
0
-file('test/parser_test' => ['src/parser.c', 'src/parser.h']) do
0
- sh "gcc -g -Wall -I#{dir('src')} -DPARSER_TEST #{dir('src/parser.c')} -o #{dir('test/parser_test')}"
0
+ sh 'ragel -s -G2 src/parser.rl'
0
 end
...
1
...
 
0
@@ -1,2 +1 @@
0
-0.0.5
...
73
74
75
 
 
 
76
77
78
...
73
74
75
76
77
78
79
80
81
0
@@ -73,6 +73,9 @@
0
 
0
 
0
 if $0 == __FILE__
0
+ require 'rubygems'
0
+ require 'ruby-debug'
0
+ Debugger.start
0
   require DIR + '/../ruby_lib/ebb'
0
   server = Ebb::start_server(SimpleApp.new, :port => 4001)
0
 end
...
3
4
5
6
7
8
9
...
3
4
5
 
6
7
8
0
@@ -3,7 +3,6 @@
0
 # See README file for details.
0
 module Ebb
0
   LIBDIR = File.dirname(__FILE__)
0
- VERSION = File.read(LIBDIR + "/../VERSION").gsub(/\s/,'')
0
   require Ebb::LIBDIR + '/../src/ebb_ext'
0
   autoload :Runner, LIBDIR + '/ebb/runner'
0
   
...
13
14
15
16
 
17
18
19
...
13
14
15
 
16
17
18
19
0
@@ -13,7 +13,7 @@
0
 
0
 typedef struct ebb_server ebb_server;
0
 typedef struct ebb_client ebb_client;
0
-
0
+#define EBB_VERSION "0.1.0"
0
 #define EBB_BUFFERSIZE (1024 * (80 + 33))
0
 #define EBB_MAX_CLIENTS 200
0
 #define EBB_TIMEOUT 30.0
...
122
123
124
125
 
126
127
128
129
130
 
 
 
131
132
133
134
135
 
 
 
 
 
 
136
 
137
138
139
...
219
220
221
 
 
222
223
224
...
231
232
233
234
 
235
236
237
...
122
123
124
 
125
126
 
 
 
 
127
128
129
130
 
 
 
 
131
132
133
134
135
136
137
138
139
140
141
...
221
222
223
224
225
226
227
228
...
235
236
237
 
238
239
240
241
0
@@ -122,18 +122,20 @@
0
 }
0
 
0
 
0
-VALUE client_env(VALUE _, VALUE client)
0
+VALUE client_env(VALUE _, VALUE rb_client)
0
 {
0
- ebb_client *_client;
0
- VALUE hash = rb_hash_new();
0
- int i;
0
- Data_Get_Struct(client, ebb_client, _client);
0
+ ebb_client *client;
0
+ VALUE field, value, hash = rb_hash_new();
0
+ int i;
0
   
0
- for(i=0; i < _client->env_size; i++) {
0
- rb_hash_aset(hash, env_field(&_client->env[i])
0
- , env_value(&_client->env[i])
0
- );
0
+ Data_Get_Struct(rb_client, ebb_client, client);
0
+ for(i=0; i < client->env_size; i++) {
0
+ field = env_field(&client->env[i]);
0
+ value = env_value(&client->env[i]);
0
+ rb_hash_aset(hash, field, value);
0
+ //printf("(%s, %s)\n", StringValuePtr(field), StringValuePtr(value));
0
   }
0
+ //printf("\n\n");
0
   rb_hash_aset(hash, global_path_info, rb_hash_aref(hash, global_request_path));
0
   return hash;
0
 }
0
@@ -219,6 +221,8 @@
0
   VALUE mEbb = rb_define_module("Ebb");
0
   VALUE mFFI = rb_define_module_under(mEbb, "FFI");
0
   
0
+ rb_define_const(mEbb, "VERSION", rb_str_new2(EBB_VERSION));
0
+
0
   /** Defines global strings in the init method. */
0
 #define DEF_GLOBAL(N, val) global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N)
0
   DEF_GLOBAL(http_prefix, "HTTP_");
0
@@ -231,7 +235,7 @@
0
   DEF_GLOBAL(request_body, "REQUEST_BODY");
0
   DEF_GLOBAL(server_port, "SERVER_PORT");
0
   DEF_GLOBAL(path_info, "PATH_INFO");
0
- DEF_GLOBAL(content_length, "CONTENT_LENGTH");
0
+ DEF_GLOBAL(content_length, "HTTP_CONTENT_LENGTH");
0
   DEF_GLOBAL(http_host, "HTTP_HOST");
0
   
0
   rb_define_singleton_method(mFFI, "server_process_connections", server_process_connections, 0);
...
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
99
100
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
104
105
106
107
108
 
 
 
 
 
 
 
 
 
 
 
 
109
0
@@ -99,75 +99,12 @@
0
   end
0
 end
0
 
0
-class EnvTest < Test::Unit::TestCase
0
- def call(env)
0
- env.delete('rack.input')
0
- env.delete('rack.errors')
0
- [200, {'Content-Type' => 'text/json'}, env.to_json]
0
- end
0
-
0
- def setup
0
- @pid = fork do
0
- server = Ebb::start_server(self, :port => PORT)
0
- STDOUT.reopen "/dev/null", "a"
0
- server.start
0
- end
0
- sleep 0.5
0
- end
0
-
0
- def teardown
0
- Process.kill('KILL', @pid)
0
- sleep 0.5
0
- end
0
-
0
-
0
- ### Tests from Mongrel http11
0
-
0
- def request(request_string)
0
- socket = TCPSocket.new("0.0.0.0", PORT)
0
- socket.write(request_string)
0
- lines = []
0
- socket.read(500000).each_line { |l| lines << l }
0
- env = JSON.parse(lines.last)
0
- end
0
-
0
- def assert_drops_connection(request_string)
0
- socket = TCPSocket.new("0.0.0.0", PORT)
0
- socket.write(request_string)
0
- assert socket.closed?
0
- end
0
-
0
-
0
- def test_parse_simple
0
- env = request("GET / HTTP/1.1\r\n\r\n")
0
- assert_equal 'HTTP/1.1', env['SERVER_PROTOCOL']
0
- assert_equal '/', env['REQUEST_PATH']
0
- assert_equal 'HTTP/1.1', env['HTTP_VERSION']
0
- assert_equal '/', env['REQUEST_URI']
0
- assert_equal 'GET', env['REQUEST_METHOD']
0
- assert_nil env['FRAGMENT']
0
- assert_nil env['QUERY_STRING']
0
- end
0
-end
0
 
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
-
0
- # def get(path)
0
- # Net::HTTP.get_response(URI.parse("http://0.0.0.0:4043#{path}"))
0
- # end
0
- #
0
- # def test_starting_with_many_options
0
- # %x{cd /tmp && rails ebb_test && ruby #{Ebb::LIBDIR}/../bin/ebb_rails start -d -e development -c /tmp/ebb_test -u www -g www -P /tmp/ebb.1.pid -p 4043 &}
0
- # response = get('/')
0
- # assert_equal 200, response.code
0
- # ensure
0
- # Process.kill('KILL', %x{cat /tmp/ebb.1.pid})
0
- # end
0
 end

Comments

    No one has commented yet.