serverside 0.4.5.1 → 0.4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'fileutils'
6
6
  include FileUtils
7
7
 
8
8
  NAME = "serverside"
9
- VERS = "0.4.5.1"
9
+ VERS = "0.4.5.2"
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",
@@ -93,7 +93,7 @@ module ServerSide::HTTP
93
93
  # Parses the request body.
94
94
  def parse_body(body)
95
95
  @body = body
96
- case @headers[:content_type]
96
+ case content_type
97
97
  when MULTIPART_FORM_DATA_RE:
98
98
  parse_multi_part(body, BOUNDARY_FIX + $1) # body.dup so we keep the original request body?
99
99
  when FORM_URL_ENCODED:
@@ -71,7 +71,9 @@ module ServerSide::HTTP
71
71
  end
72
72
 
73
73
  def content_type
74
- @headers[:content_type]
74
+ if t = @headers[:content_type]
75
+ t =~ /(.*);/ ? $1.strip : t
76
+ end
75
77
  end
76
78
  end
77
79
  end
data/spec/request_spec.rb CHANGED
@@ -52,7 +52,6 @@ context "A Request" do
52
52
  end
53
53
 
54
54
  MOCK_GET_PARAMS = "GET /?q=state&f=xml HTTP/1.1\r\n\r\n"
55
- MOCK_POST_PARAMS = "POST / HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 12\r\n\r\nq=state&f=js"
56
55
 
57
56
  specify "should provide the parameters" do
58
57
  @server.receive_data(MOCK_GET1)
@@ -61,12 +60,25 @@ context "A Request" do
61
60
  @server.set_state(:state_initial)
62
61
  @server.receive_data(MOCK_GET_PARAMS)
63
62
  @server.request.params.should == {:q => 'state', :f => 'xml'}
63
+ end
64
+
65
+ MOCK_POST_PARAMS = "POST / HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 12\r\n\r\nq=state&f=js"
64
66
 
67
+ specify "should provide parameters for POST requests with URL-encoded parameters" do
65
68
  @server.set_state(:state_initial)
66
69
  @server.receive_data(MOCK_POST_PARAMS)
67
70
  @server.request.params.should == {:q => 'state', :f => 'js'}
68
71
  end
69
72
 
73
+ MOCK_POST_CHARSET_PARAMS = "POST / HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nContent-Length: 12\r\n\r\nq=state&f=js"
74
+
75
+ specify "should provide parameters for POST requests with URL-encoded parameters and charset" do
76
+ @server.set_state(:state_initial)
77
+ @server.receive_data(MOCK_POST_CHARSET_PARAMS)
78
+ @server.request.content_type.should == 'application/x-www-form-urlencoded'
79
+ @server.request.params.should == {:q => 'state', :f => 'js'}
80
+ end
81
+
70
82
  MOCK_GET2 = "GET /xxx HTTP/1.0\r\nHost: reality-scada.net\r\n\r\n"
71
83
  MOCK_GET3 = "GET /xxx HTTP/1.0\r\nHost: abc.net:443\r\n\r\n"
72
84
  MOCK_GET4 = "GET /xxx HTTP/1.0\r\nHost: xyz.net:3321\r\n\r\n"
@@ -163,6 +163,12 @@ context "Response.add_header" do
163
163
  end
164
164
  end
165
165
 
166
+ class Time
167
+ def to_s_expiration
168
+ strftime(ServerSide::HTTP::Response::EXPIRATION_FORMAT)
169
+ end
170
+ end
171
+
166
172
  context "Response.set_cookie" do
167
173
  setup do
168
174
  @res = Response.new
@@ -171,25 +177,25 @@ context "Response.set_cookie" do
171
177
  specify "should add a cookie header" do
172
178
  t = Time.now + 1000
173
179
  @res.set_cookie(:abc, '2 3 4', :expires => t)
174
- @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.rfc2822}\r\n"]
180
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.to_s_expiration}\r\n"]
175
181
  end
176
182
 
177
183
  specify "should accept a path option" do
178
184
  t = Time.now + 1000
179
185
  @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.rfc2822}\r\n"]
186
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/def; expires=#{t.to_s_expiration}\r\n"]
181
187
  end
182
188
 
183
189
  specify "should accept a domain option" do
184
190
  t = Time.now + 1000
185
191
  @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.rfc2822}; domain=test.net\r\n"]
192
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.to_s_expiration}; domain=test.net\r\n"]
187
193
  end
188
194
 
189
195
  specify "should accept a ttl option" do
190
196
  t = Time.now + 1000
191
197
  @res.set_cookie(:abc, '2 3 4', :ttl => 1000)
192
- @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.rfc2822}\r\n"]
198
+ @res.headers.should == ["Set-Cookie: abc=2+3+4; path=/; expires=#{t.to_s_expiration}\r\n"]
193
199
  end
194
200
  end
195
201
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverside
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5.1
4
+ version: 0.4.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-18 00:00:00 +02:00
12
+ date: 2008-03-12 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,33 +53,33 @@ files:
53
53
  - README
54
54
  - Rakefile
55
55
  - bin/serverside
56
- - spec/core_ext_spec.rb
57
56
  - spec/daemon_spec.rb
57
+ - spec/core_ext_spec.rb
58
+ - spec/template_spec.rb
58
59
  - spec/http_spec.rb
59
- - spec/js_spec.rb
60
60
  - spec/request_spec.rb
61
+ - spec/js_spec.rb
61
62
  - spec/response_spec.rb
62
63
  - spec/spec_helper.rb
63
- - spec/template_spec.rb
64
64
  - spec/xml_spec.rb
65
65
  - lib/serverside
66
- - lib/serverside/cluster.rb
67
- - lib/serverside/core_ext.rb
68
- - lib/serverside/daemon.rb
69
66
  - lib/serverside/http
70
67
  - lib/serverside/http/caching.rb
71
68
  - lib/serverside/http/const.rb
72
69
  - lib/serverside/http/error.rb
73
70
  - lib/serverside/http/parsing.rb
74
- - lib/serverside/http/request.rb
75
71
  - lib/serverside/http/response.rb
76
72
  - lib/serverside/http/server.rb
77
73
  - lib/serverside/http/static.rb
74
+ - lib/serverside/http/request.rb
78
75
  - lib/serverside/http.rb
79
- - lib/serverside/js.rb
76
+ - lib/serverside/xml.rb
77
+ - lib/serverside/cluster.rb
80
78
  - lib/serverside/log.rb
79
+ - lib/serverside/daemon.rb
80
+ - lib/serverside/core_ext.rb
81
81
  - lib/serverside/template.rb
82
- - lib/serverside/xml.rb
82
+ - lib/serverside/js.rb
83
83
  - lib/serverside.rb
84
84
  has_rdoc: true
85
85
  homepage: http://code.google.com/p/serverside/