• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂22 (tree)
時間2007-10-14 22:38:36
作者junkikuchi

Log Message

changed variable name contents to content.
added alias body to content.

Change Summary

差異

--- trunk/test/test_cgi_response.rb (revision 21)
+++ trunk/test/test_cgi_response.rb (revision 22)
@@ -14,7 +14,7 @@
1414
1515 out = ''
1616 response = Tenarai::CGI::Response.new(out)
17- response.contents = 'Hello World'
17+ response.content = 'Hello World'
1818 response.flush
1919 assert_equal("Status: 200 OK\r\n\r\nHello World", out)
2020
@@ -21,7 +21,7 @@
2121 out = ''
2222 response = Tenarai::CGI::Response.new(out)
2323 response['content-type'] = 'text/html'
24- response.contents = 'Foo Bar'
24+ response.content = 'Foo Bar'
2525 response.flush
2626 assert_equal(
2727 "Status: 200 OK\r\nContent-Type: text/html\r\n\r\nFoo Bar",
--- trunk/test/test_cgi_request.rb (revision 21)
+++ trunk/test/test_cgi_request.rb (revision 22)
@@ -44,8 +44,8 @@
4444 )
4545 assert_equal('123', req.query['a'])
4646 assert_equal('456', req.query['b'])
47- assert_equal('789', req.contents['c'])
48- assert_equal('aaa', req.contents['d'])
47+ assert_equal('789', req.content['c'])
48+ assert_equal('aaa', req.content['d'])
4949 end
5050
5151 def test_post_upload
@@ -101,6 +101,6 @@
101101 )
102102 assert_equal('111', req.query['a'])
103103 assert_equal('22222', req.query['b'])
104- assert_equal('123', req.contents['a'])
104+ assert_equal('123', req.content['a'])
105105 end
106106 end
--- trunk/lib/tenarai/webrick.rb (revision 21)
+++ trunk/lib/tenarai/webrick.rb (revision 22)
@@ -27,7 +27,7 @@
2727 cookie.secure = val.secure if val.secure
2828 @out.cookies << cookie
2929 end
30- @out.body << @contents
30+ @out.body << @content
3131 end
3232 end
3333
--- trunk/lib/tenarai/cgi/response.rb (revision 21)
+++ trunk/lib/tenarai/cgi/response.rb (revision 22)
@@ -100,14 +100,16 @@
100100 attr_accessor :code
101101 attr_reader :header
102102 attr_reader :cookie
103- attr_accessor :contents
103+ attr_accessor :content
104104
105+ alias :body :content
106+
105107 def initialize(out)
106- @code = 200
107- @header = {}
108- @cookie = Container.new
109- @contents = ''
110- @out = out
108+ @code = 200
109+ @header = {}
110+ @cookie = Container.new
111+ @content = ''
112+ @out = out
111113 end
112114
113115 def fetch(key)
@@ -145,7 +147,7 @@
145147 @header.sort.each do |key, val| @out << _h(key, val) end
146148 @cookie.sort.each do |val| @out << _h('set-cookie', val) end
147149 @out << CRLF
148- @out << @contents
150+ @out << @content
149151 end
150152 end
151153 end
--- trunk/lib/tenarai/cgi/request.rb (revision 21)
+++ trunk/lib/tenarai/cgi/request.rb (revision 22)
@@ -59,8 +59,10 @@
5959 attr_reader :method
6060 attr_reader :cookie
6161 attr_reader :query
62- attr_reader :contents
62+ attr_reader :content
6363
64+ alias :body :content
65+
6466 def initialize(stdin, env, params={})
6567 @params = params
6668
@@ -80,12 +82,12 @@
8082 else
8183 nil
8284 end
83- @contents = HANDLER[content_type].new(@params).decode(@header, stdin)
85+ @content = HANDLER[content_type].new(@params).decode(@header, stdin)
8486
8587 @method.freeze
8688 @cookie.freeze
8789 @query.freeze
88- @contents.freeze
90+ @content.freeze
8991 end
9092
9193 def fetch(key)
--- trunk/lib/tenarai/mongrel.rb (revision 21)
+++ trunk/lib/tenarai/mongrel.rb (revision 22)
@@ -24,7 +24,7 @@
2424 @out.start(@code.to_i) do |h, b|
2525 @header.sort.each do |key, val| h[_n(key)] = val end
2626 @cookie.sort.each do |val| h[_n('set-cookie')] = val end
27- b.write @contents
27+ b.write @content
2828 end
2929 end
3030 end
Show on old repository browser