serverside 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'fileutils'
6
6
  include FileUtils
7
7
 
8
8
  NAME = "serverside"
9
- VERS = "0.4.3"
9
+ VERS = "0.4.4"
10
10
  CLEAN.include ['**/.*.sw?', 'pkg/*', '.config', 'doc/*', 'coverage/*']
11
11
  RDOC_OPTS = ['--quiet', '--title', "ServerSide: a Fast Ruby Web Framework",
12
12
  "--opname", "index.html",
@@ -109,11 +109,10 @@ task :stats do
109
109
  end
110
110
 
111
111
  ##############################################################################
112
- # SVN
112
+ # gem and rdoc release
113
113
  ##############################################################################
114
-
115
- desc "Add new files to subversion"
116
- task :svn_add do
117
- system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
118
- end
119
-
114
+ task :release => [:package] do
115
+ sh %{rubyforge login}
116
+ sh %{rubyforge add_release #{NAME} #{NAME} #{VERS} pkg/#{NAME}-#{VERS}.tgz}
117
+ sh %{rubyforge add_file #{NAME} #{NAME} #{VERS} pkg/#{NAME}-#{VERS}.gem}
118
+ end
@@ -7,7 +7,7 @@ module ServerSide::HTTP
7
7
  def parse_request_line(line)
8
8
  if line =~ REQUEST_LINE_RE
9
9
  @request_line = line
10
- @method, @path, @query, @http_version = $1.downcase.to_sym, $2, $3, $4
10
+ @method, @path, @query, @http_version = $1.downcase.to_sym, $2.uri_unescape, $3, $4
11
11
  @params = @query ? parse_query_parameters(@query) : {}
12
12
 
13
13
  # HTTP 1.1 connections are persistent by default.
@@ -1,3 +1,5 @@
1
+ require 'socket'
2
+
1
3
  module ServerSide::HTTP
2
4
  class Request
3
5
  include ServerSide::HTTP::Parsing
@@ -24,14 +24,6 @@ module ServerSide::HTTP
24
24
  end
25
25
  end
26
26
 
27
- def disable_response
28
- @disable_response = true
29
- end
30
-
31
- def enable_response
32
- @disable_response = false
33
- end
34
-
35
27
  def persistent?
36
28
  !@close && !@stream_proc && @body
37
29
  end
@@ -50,7 +42,7 @@ module ServerSide::HTTP
50
42
  expires = opts[:expires] || (opts[:ttl] && (Time.now + opts[:ttl])) || \
51
43
  (Time.now + 86400) # if no expiry is specified we assume one day
52
44
 
53
- v = "#{name}=#{value.to_s.uri_escape}; path=#{path}; expires=#{expires.httpdate}"
45
+ v = "#{name}=#{value.to_s.uri_escape}; path=#{path}; expires=#{expires.rfc2822}"
54
46
  if domain = opts[:domain]
55
47
  v << "; domain=#{domain}"
56
48
  end
@@ -62,20 +54,19 @@ module ServerSide::HTTP
62
54
  set_cookie(name, nil, opts.merge(:expires => COOKIE_EXPIRED_TIME))
63
55
  end
64
56
 
65
- EMPTY = ''.freeze
66
-
67
57
  def to_s
68
- if @disable_response
69
- EMPTY
70
- else
71
- if !streaming? && (content_length = @body && @body.size)
72
- add_header(CONTENT_LENGTH, content_length)
73
- end
74
- "HTTP/1.1 #{@status}\r\nDate: #{Time.now.httpdate}\r\n#{@headers.join}\r\n#{@body}"
58
+ if @body && (content_length = @body.size) && !streaming?
59
+ add_header(CONTENT_LENGTH, content_length)
75
60
  end
61
+ "HTTP/1.1 #{@status}\r\nDate: #{Time.now.httpdate}\r\n#{@headers.join}\r\n#{@body}"
62
+ end
63
+
64
+ def should_render?
65
+ !@stream_proc || @stream_render_upfront
76
66
  end
77
67
 
78
- def stream(period, &block)
68
+ def stream(period, render_upfront = false, &block)
69
+ @stream_render_upfront = render_upfront
79
70
  @stream_period = period
80
71
  @stream_proc = block
81
72
  self
@@ -138,16 +138,16 @@ module ServerSide::HTTP
138
138
  end
139
139
 
140
140
  def send_response(resp)
141
- persistent = @request.persistent && resp.persistent?
142
- if !persistent
141
+ unless persist = @request.persistent && resp.persistent?
143
142
  resp.headers << CONNECTION_CLOSE
144
143
  end
145
- send_data(resp.to_s)
146
- @response_sent = true
144
+ if resp.should_render?
145
+ send_data(resp.to_s)
146
+ end
147
147
  if resp.streaming?
148
148
  start_stream_loop(resp.stream_period, resp.stream_proc)
149
149
  else
150
- set_state(persistent ? :state_initial : :state_done)
150
+ set_state(persist ? :state_initial : :state_done)
151
151
  end
152
152
  end
153
153
 
data/lib/serverside/js.rb CHANGED
@@ -29,7 +29,12 @@ module ServerSide
29
29
  value = args.first
30
30
  value = value.__content if value.respond_to?(:__content)
31
31
  end
32
- @stack.last.__add_hash_value(key, value)
32
+
33
+ if key == :__item
34
+ @stack.last.__add_array_value(value)
35
+ else
36
+ @stack.last.__add_hash_value(key, value)
37
+ end
33
38
  self
34
39
  end
35
40
 
@@ -171,25 +171,25 @@ context "Response.set_cookie" do
171
171
  specify "should add a cookie header" do
172
172
  t = Time.now + 1000
173
173
  @res.set_cookie(:abc, '2 3 4', :expires => t)
174
- @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.httpdate}\r\n"]
174
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.rfc2822}\r\n"]
175
175
  end
176
176
 
177
177
  specify "should accept a path option" do
178
178
  t = Time.now + 1000
179
179
  @res.set_cookie(:abc, '2 3 4', :path => '/def', :expires => t)
180
- @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/def; expires=#{t.httpdate}\r\n"]
180
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/def; expires=#{t.rfc2822}\r\n"]
181
181
  end
182
182
 
183
183
  specify "should accept a domain option" do
184
184
  t = Time.now + 1000
185
185
  @res.set_cookie(:abc, '2 3 4', :domain => 'test.net', :expires => t)
186
- @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.httpdate}; domain=test.net\r\n"]
186
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.rfc2822}; domain=test.net\r\n"]
187
187
  end
188
188
 
189
189
  specify "should accept a ttl option" do
190
190
  t = Time.now + 1000
191
191
  @res.set_cookie(:abc, '2 3 4', :ttl => 1000)
192
- @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.httpdate}\r\n"]
192
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.rfc2822}\r\n"]
193
193
  end
194
194
  end
195
195
 
metadata CHANGED
@@ -1,68 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: serverside
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.4.3
7
- date: 2007-09-16 00:00:00 +03:00
8
- summary: Fast Ruby HTTP Server.
9
- require_paths:
10
- - lib
11
- email: ciconia@gmail.com
12
- homepage: http://code.google.com/p/serverside/
13
- rubyforge_project:
14
- description: Fast Ruby HTTP Server.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.5
24
- version:
4
+ version: 0.4.4
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Sharon Rosner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-01-20 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: eventmachine
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: erubis
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: metaid
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ description: Fast Ruby HTTP Server.
43
+ email: ciconia@gmail.com
44
+ executables:
45
+ - serverside
46
+ extensions: []
47
+
48
+ extra_rdoc_files:
49
+ - README
50
+ - COPYING
31
51
  files:
32
52
  - COPYING
33
53
  - README
34
54
  - Rakefile
35
55
  - bin/serverside
36
- - spec/core_ext_spec.rb
37
56
  - spec/daemon_spec.rb
57
+ - spec/core_ext_spec.rb
58
+ - spec/template_spec.rb
38
59
  - spec/http_spec.rb
39
- - spec/js_spec.rb
40
60
  - spec/request_spec.rb
61
+ - spec/js_spec.rb
41
62
  - spec/response_spec.rb
42
63
  - spec/spec_helper.rb
43
- - spec/template_spec.rb
44
64
  - spec/xml_spec.rb
45
65
  - lib/serverside
46
- - lib/serverside.rb
47
- - lib/serverside/cluster.rb
48
- - lib/serverside/core_ext.rb
49
- - lib/serverside/daemon.rb
50
66
  - lib/serverside/http
51
- - lib/serverside/http.rb
52
- - lib/serverside/js.rb
53
- - lib/serverside/log.rb
54
- - lib/serverside/template.rb
55
- - lib/serverside/xml.rb
56
67
  - lib/serverside/http/caching.rb
57
68
  - lib/serverside/http/const.rb
58
69
  - lib/serverside/http/error.rb
59
70
  - lib/serverside/http/parsing.rb
60
- - lib/serverside/http/request.rb
61
71
  - lib/serverside/http/response.rb
62
72
  - lib/serverside/http/server.rb
63
73
  - lib/serverside/http/static.rb
64
- test_files: []
65
-
74
+ - lib/serverside/http/request.rb
75
+ - lib/serverside/http.rb
76
+ - lib/serverside/xml.rb
77
+ - lib/serverside/cluster.rb
78
+ - lib/serverside/log.rb
79
+ - lib/serverside/daemon.rb
80
+ - lib/serverside/core_ext.rb
81
+ - lib/serverside/template.rb
82
+ - lib/serverside/js.rb
83
+ - lib/serverside.rb
84
+ has_rdoc: true
85
+ homepage: http://code.google.com/p/serverside/
86
+ post_install_message:
66
87
  rdoc_options:
67
88
  - --quiet
68
89
  - --title
@@ -77,40 +98,26 @@ rdoc_options:
77
98
  - ^(examples|extras)\/
78
99
  - --exclude
79
100
  - lib/serverside.rb
80
- extra_rdoc_files:
81
- - README
82
- - COPYING
83
- executables:
84
- - serverside
85
- extensions: []
86
-
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 1.8.5
108
+ version:
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
87
115
  requirements: []
88
116
 
89
- dependencies:
90
- - !ruby/object:Gem::Dependency
91
- name: eventmachine
92
- version_requirement:
93
- version_requirements: !ruby/object:Gem::Version::Requirement
94
- requirements:
95
- - - ">"
96
- - !ruby/object:Gem::Version
97
- version: 0.0.0
98
- version:
99
- - !ruby/object:Gem::Dependency
100
- name: erubis
101
- version_requirement:
102
- version_requirements: !ruby/object:Gem::Version::Requirement
103
- requirements:
104
- - - ">"
105
- - !ruby/object:Gem::Version
106
- version: 0.0.0
107
- version:
108
- - !ruby/object:Gem::Dependency
109
- name: metaid
110
- version_requirement:
111
- version_requirements: !ruby/object:Gem::Version::Requirement
112
- requirements:
113
- - - ">"
114
- - !ruby/object:Gem::Version
115
- version: 0.0.0
116
- version:
117
+ rubyforge_project:
118
+ rubygems_version: 1.0.1
119
+ signing_key:
120
+ specification_version: 2
121
+ summary: Fast Ruby HTTP Server.
122
+ test_files: []
123
+