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:
Add ACCEPT header, slight parser cleanup
Ryan Dahl (author)
Sat Mar 22 09:45:12 -0700 2008
commit  d478f914fae8664eadf84f7a2fe438ab0dc99d62
tree    9d55bdc820417a934d390b3657df42729ca3efe4
parent  9d81073a9238c892c39ca51b05ebb22a05fe0675
...
29
30
31
32
 
33
34
35
...
29
30
31
 
32
33
34
35
0
@@ -29,7 +29,7 @@
0
 
0
 task(:default => [:compile, :test])
0
 
0
-task(:compile => ['src/Makefile', 'src/ebb.c', 'src/ebb.h', 'src/ebb_ruby.c', 'src/parser.c'']) do
0
+task(:compile => ['src/Makefile', 'src/ebb.c', 'src/ebb.h', 'src/ebb_ruby.c', 'src/parser.c', 'src/parser.h']) do
0
   sh "cd #{dir('src')} && make"
0
 end
0
 
...
100
101
102
103
104
105
 
 
 
 
 
106
107
108
...
100
101
102
 
 
 
103
104
105
106
107
108
109
110
0
@@ -100,9 +100,11 @@
0
     }
0
     
0
     def env
0
- env = FFI::client_env(self).update(BASE_ENV)
0
- env['rack.input'] = RequestBody.new(self)
0
- env
0
+ @env ||= begin
0
+ env = FFI::client_env(self).update(BASE_ENV)
0
+ env['rack.input'] = RequestBody.new(self)
0
+ env
0
+ end
0
     end
0
     
0
     def write_status(status)
...
21
22
23
24
25
26
 
 
 
 
27
28
29
...
140
141
142
143
144
 
 
 
145
146
147
...
253
254
255
256
257
258
 
 
 
259
260
261
...
21
22
23
 
 
 
24
25
26
27
28
29
30
...
141
142
143
 
 
144
145
146
147
148
149
...
255
256
257
 
 
 
258
259
260
261
262
263
0
@@ -21,9 +21,10 @@
0
 static VALUE global_request_body;
0
 static VALUE global_server_port;
0
 static VALUE global_path_info;
0
-static VALUE global_content_length;
0
-static VALUE global_content_type;
0
-static VALUE global_http_host;
0
+static VALUE global_http_content_length;
0
+static VALUE global_http_content_type;
0
+static VALUE global_http_content_type;
0
+static VALUE global_http_accept;
0
 
0
 /* You don't want to run more than one server per Ruby VM. Really
0
  * I'm making this explicit by not defining a Ebb::Server class but instead
0
@@ -140,8 +141,9 @@
0
     case MONGREL_QUERY_STRING: return global_query_string;
0
     case MONGREL_HTTP_VERSION: return global_http_version;
0
     case MONGREL_SERVER_PORT: return global_server_port;
0
- case MONGREL_CONTENT_LENGTH: return global_content_length;
0
- case MONGREL_CONTENT_TYPE: return global_content_type;
0
+ case MONGREL_ACCEPT: return global_http_accept;
0
+ case MONGREL_CONTENT_LENGTH: return global_http_content_length;
0
+ case MONGREL_CONTENT_TYPE: return global_http_content_type;
0
   }
0
   fprintf(stderr, "Unknown environ type: %d", item->type);
0
   assert(FALSE);
0
@@ -253,9 +255,9 @@
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, "HTTP_CONTENT_LENGTH");
0
- DEF_GLOBAL(content_type, "HTTP_CONTENT_TYPE");
0
- DEF_GLOBAL(http_host, "HTTP_HOST");
0
+ DEF_GLOBAL(http_content_length, "HTTP_CONTENT_LENGTH");
0
+ DEF_GLOBAL(http_content_type, "HTTP_CONTENT_TYPE");
0
+ DEF_GLOBAL(http_accept, "HTTP_ACCEPT");
0
   
0
   rb_define_singleton_method(mFFI, "server_process_connections", server_process_connections, 0);
0
   rb_define_singleton_method(mFFI, "server_listen_on_port", server_listen_on_port, 1);
...
21
22
23
 
24
25
26
...
21
22
23
24
25
26
27
0
@@ -21,6 +21,7 @@
0
      , MONGREL_HTTP_VERSION
0
      , MONGREL_CONTENT_LENGTH
0
      , MONGREL_CONTENT_TYPE
0
+ , MONGREL_ACCEPT
0
      /* below - not used in the parser but often used by users of parser */
0
      , MONGREL_SERVER_PORT
0
      };
...
38
39
40
41
 
 
 
 
 
 
42
43
44
45
46
47
 
48
49
50
51
...
143
144
145
146
147
148
 
 
 
 
149
150
151
 
152
153
154
...
38
39
40
 
41
42
43
44
45
46
47
48
49
50
51
 
52
53
54
55
56
...
148
149
150
 
 
 
151
152
153
154
155
156
 
157
158
159
160
0
@@ -38,13 +38,18 @@
0
     }
0
   }
0
   
0
- action content_length {
0
+ action http_accept {
0
+ if(LEN(mark, fpc) > 1024) { parser->overflow_error = TRUE; fbreak; }
0
+ parser->on_element(parser->data, MONGREL_ACCEPT, PTR_TO(mark), LEN(mark, fpc));
0
+ }
0
+
0
+ action http_content_length {
0
     if(LEN(mark, fpc) > 20) { parser->overflow_error = TRUE; fbreak; }
0
     set_content_length(parser, PTR_TO(mark), LEN(mark, fpc));
0
     parser->on_element(parser->data, MONGREL_CONTENT_LENGTH, PTR_TO(mark), LEN(mark, fpc));
0
   }
0
   
0
- action content_type {
0
+ action http_content_type {
0
     if(LEN(mark, fpc) > 1024) { parser->overflow_error = TRUE; fbreak; }
0
     parser->on_element(parser->data, MONGREL_CONTENT_TYPE, PTR_TO(mark), LEN(mark, fpc));
0
   }
0
0
@@ -143,12 +148,13 @@
0
 
0
   field_value = any* >start_value %write_value;
0
   
0
- known_header = ("Content-Length:"i " "* (digit+ >mark %content_length) :> CRLF)
0
- | ("Content-Type:"i " "* (any* >mark %content_type) :> CRLF)
0
- ;
0
+ known_header = ( ("Accept:"i " "* (any* >mark %http_accept))
0
+ | ("Content-Length:"i " "* (digit+ >mark %http_content_length))
0
+ | ("Content-Type:"i " "* (any* >mark %http_content_type))
0
+ ) :> CRLF;
0
   unknown_header = (field_name ":" " "* field_value :> CRLF) -- known_header;
0
   
0
- Request = Request_Line (known_header | unknown_header )* ( CRLF @done );
0
+ Request = Request_Line (known_header | unknown_header)* ( CRLF @done );
0
 
0
 main := Request;
0
 

Comments

    No one has commented yet.