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:
fix multiple cookie error

thanks Surendra.
Ryan Dahl (author)
Wed Mar 12 17:45:13 -0700 2008
commit  16283806a21a4989aae8bbc8cbc3558f6a36db90
tree    8834723328d28d19b523e54ce38a9090d573b4f3
parent  bfcf5b16915ba08d599b6248613d6e9a5e0f0cc9
...
38
39
40
 
41
42
43
...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
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
...
105
106
107
108
 
 
 
 
 
 
 
 
 
 
 
109
110
111
...
38
39
40
41
42
43
44
...
57
58
59
 
60
61
62
63
64
65
66
67
68
69
70
...
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
...
105
106
107
 
108
109
110
111
112
113
114
115
116
117
118
119
120
121
0
@@ -38,6 +38,7 @@
0
     FFI::server_unlisten()
0
   end
0
   
0
+ # This array is created and manipulated in the C extension.
0
   def FFI.waiting_clients
0
     @waiting_clients
0
   end
0
@@ -56,7 +57,6 @@
0
     }
0
     
0
     def process(app)
0
- #puts "Request: #{client.inspect}\n"
0
       begin
0
         status, headers, body = app.call(env)
0
       rescue
0
0
0
0
0
0
0
0
0
@@ -66,28 +66,28 @@
0
         body = "Internal Server Error\n"
0
       end
0
       
0
- FFI::client_write_status(self, status.to_i, HTTP_STATUS_CODES[status.to_i])
0
+ status = status.to_i
0
+ FFI::client_write_status(self, status, HTTP_STATUS_CODES[status])
0
       
0
- if body.respond_to? :length and status != 304
0
+ if headers.respond_to?(:[]=) and body.respond_to?(:length) and status != 304
0
         headers['Connection'] = 'close'
0
- headers['Content-Length'] = body.length
0
+ headers['Content-Length'] = body.length.to_s
0
       end
0
       
0
- headers.each { |k, v| write_header(k,v) }
0
-
0
+ headers.each { |field, value| write_header(field, value) }
0
       write("\r\n")
0
       
0
- # Not many apps use streaming yet so i'll hold off on that feature
0
- # until the rest of ebb is more developed.
0
       if body.kind_of?(String)
0
         write(body)
0
- FFI::client_set_body_written(self, true)
0
- FFI::client_begin_transmission(self)
0
+ body_written()
0
+ begin_transmission()
0
       else
0
- FFI::client_begin_transmission(self)
0
+ begin_transmission()
0
         body.each { |p| write(p) }
0
- FFI::client_set_body_written(self, true)
0
+ body_written()
0
       end
0
+ rescue => e
0
+ puts "Error! #{e.class} #{e.message}"
0
     ensure
0
       FFI::client_release(self)
0
     end
0
@@ -105,7 +105,17 @@
0
     end
0
     
0
     def write_header(field, value)
0
- FFI::client_write_header(self, field.to_s, value.to_s)
0
+ value.send(value.is_a?(String) ? :each_line : :each) do |v|
0
+ FFI::client_write_header(self, field, v.chomp)
0
+ end
0
+ end
0
+
0
+ def body_written
0
+ FFI::client_set_body_written(self, true)
0
+ end
0
+
0
+ def begin_transmission
0
+ FFI::client_begin_transmission(self)
0
     end
0
   end
0
   

Comments

    No one has commented yet.