thin 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/CHANGELOG +8 -0
  2. data/README.md +83 -0
  3. data/Rakefile +9 -32
  4. data/example/vlad.rake +1 -1
  5. data/lib/rack/adapter/loader.rb +0 -16
  6. data/lib/thin.rb +22 -24
  7. data/lib/thin/backends/base.rb +3 -1
  8. data/lib/thin/connection.rb +9 -8
  9. data/lib/thin/daemonizing.rb +3 -1
  10. data/lib/thin/logging.rb +1 -1
  11. data/lib/thin/runner.rb +36 -36
  12. data/lib/thin/server.rb +13 -0
  13. data/lib/thin/version.rb +3 -3
  14. metadata +5 -91
  15. data/README +0 -69
  16. data/benchmark/abc +0 -51
  17. data/benchmark/benchmarker.rb +0 -80
  18. data/benchmark/runner +0 -82
  19. data/spec/backends/swiftiply_client_spec.rb +0 -66
  20. data/spec/backends/tcp_server_spec.rb +0 -33
  21. data/spec/backends/unix_server_spec.rb +0 -37
  22. data/spec/command_spec.rb +0 -25
  23. data/spec/configs/cluster.yml +0 -9
  24. data/spec/configs/single.yml +0 -9
  25. data/spec/connection_spec.rb +0 -107
  26. data/spec/controllers/cluster_spec.rb +0 -267
  27. data/spec/controllers/controller_spec.rb +0 -129
  28. data/spec/controllers/service_spec.rb +0 -50
  29. data/spec/daemonizing_spec.rb +0 -200
  30. data/spec/headers_spec.rb +0 -40
  31. data/spec/logging_spec.rb +0 -52
  32. data/spec/perf/request_perf_spec.rb +0 -50
  33. data/spec/perf/response_perf_spec.rb +0 -19
  34. data/spec/perf/server_perf_spec.rb +0 -39
  35. data/spec/rack/loader_spec.rb +0 -42
  36. data/spec/rack/rails_adapter_spec.rb +0 -173
  37. data/spec/rails_app/app/controllers/application.rb +0 -10
  38. data/spec/rails_app/app/controllers/simple_controller.rb +0 -19
  39. data/spec/rails_app/app/helpers/application_helper.rb +0 -3
  40. data/spec/rails_app/app/views/simple/index.html.erb +0 -15
  41. data/spec/rails_app/config/boot.rb +0 -109
  42. data/spec/rails_app/config/environment.rb +0 -64
  43. data/spec/rails_app/config/environments/development.rb +0 -18
  44. data/spec/rails_app/config/environments/production.rb +0 -19
  45. data/spec/rails_app/config/environments/test.rb +0 -22
  46. data/spec/rails_app/config/initializers/inflections.rb +0 -10
  47. data/spec/rails_app/config/initializers/mime_types.rb +0 -5
  48. data/spec/rails_app/config/routes.rb +0 -35
  49. data/spec/rails_app/public/404.html +0 -30
  50. data/spec/rails_app/public/422.html +0 -30
  51. data/spec/rails_app/public/500.html +0 -30
  52. data/spec/rails_app/public/dispatch.cgi +0 -10
  53. data/spec/rails_app/public/dispatch.fcgi +0 -24
  54. data/spec/rails_app/public/dispatch.rb +0 -10
  55. data/spec/rails_app/public/favicon.ico +0 -0
  56. data/spec/rails_app/public/images/rails.png +0 -0
  57. data/spec/rails_app/public/index.html +0 -277
  58. data/spec/rails_app/public/javascripts/application.js +0 -2
  59. data/spec/rails_app/public/javascripts/controls.js +0 -963
  60. data/spec/rails_app/public/javascripts/dragdrop.js +0 -972
  61. data/spec/rails_app/public/javascripts/effects.js +0 -1120
  62. data/spec/rails_app/public/javascripts/prototype.js +0 -4225
  63. data/spec/rails_app/public/robots.txt +0 -5
  64. data/spec/rails_app/script/about +0 -3
  65. data/spec/rails_app/script/console +0 -3
  66. data/spec/rails_app/script/destroy +0 -3
  67. data/spec/rails_app/script/generate +0 -3
  68. data/spec/rails_app/script/performance/benchmarker +0 -3
  69. data/spec/rails_app/script/performance/profiler +0 -3
  70. data/spec/rails_app/script/performance/request +0 -3
  71. data/spec/rails_app/script/plugin +0 -3
  72. data/spec/rails_app/script/process/inspector +0 -3
  73. data/spec/rails_app/script/process/reaper +0 -3
  74. data/spec/rails_app/script/process/spawner +0 -3
  75. data/spec/rails_app/script/runner +0 -3
  76. data/spec/rails_app/script/server +0 -3
  77. data/spec/request/mongrel_spec.rb +0 -39
  78. data/spec/request/parser_spec.rb +0 -254
  79. data/spec/request/persistent_spec.rb +0 -35
  80. data/spec/request/processing_spec.rb +0 -50
  81. data/spec/response_spec.rb +0 -102
  82. data/spec/runner_spec.rb +0 -168
  83. data/spec/server/builder_spec.rb +0 -44
  84. data/spec/server/pipelining_spec.rb +0 -110
  85. data/spec/server/robustness_spec.rb +0 -34
  86. data/spec/server/stopping_spec.rb +0 -55
  87. data/spec/server/swiftiply.yml +0 -6
  88. data/spec/server/swiftiply_spec.rb +0 -32
  89. data/spec/server/tcp_spec.rb +0 -47
  90. data/spec/server/threaded_spec.rb +0 -27
  91. data/spec/server/unix_socket_spec.rb +0 -26
  92. data/spec/server_spec.rb +0 -100
  93. data/spec/spec_helper.rb +0 -234
  94. data/tasks/announce.rake +0 -22
  95. data/tasks/deploy.rake +0 -13
  96. data/tasks/email.erb +0 -27
  97. data/tasks/gem.rake +0 -65
  98. data/tasks/rdoc.rake +0 -25
  99. data/tasks/site.rake +0 -15
  100. data/tasks/spec.rake +0 -43
  101. data/tasks/stats.rake +0 -28
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/about'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/console'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/destroy'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/generate'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/benchmarker'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/profiler'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/request'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/plugin'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/inspector'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/reaper'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/spawner'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/runner'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/server'
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- require 'digest/sha1'
3
-
4
- describe Request, 'legacy Mongrel tests' do
5
- it 'should raise error on large header names' do
6
- proc { R("GET /#{rand_data(10,120)} HTTP/1.1\r\nX-#{rand_data(1024, 1024+(1024))}: Test\r\n\r\n") }.
7
- should raise_error(InvalidRequest)
8
- end
9
-
10
- it 'should raise error on large mangled field values' do
11
- proc { R("GET /#{rand_data(10,120)} HTTP/1.1\r\nX-Test: #{rand_data(1024, 1024*1024, false)}\r\n\r\n") }.
12
- should raise_error(InvalidRequest)
13
- end
14
-
15
- it 'should raise error on big fat ugly headers' do
16
- get = "GET /#{rand_data(10,120)} HTTP/1.1\r\n"
17
- get << "X-Test: test\r\n" * (80 * 1024)
18
- proc { R(get) }.should raise_error(InvalidRequest)
19
- end
20
-
21
- it 'should raise error on random garbage' do
22
- proc { R("GET #{rand_data(1024, 1024+(1024), false)} #{rand_data(1024, 1024+(1024), false)}\r\n\r\n") }.
23
- should raise_error(InvalidRequest)
24
- end
25
-
26
- private
27
- def rand_data(min, max, readable=true)
28
- count = min + ((rand(max)+1) *10).to_i
29
- res = count.to_s + "/"
30
-
31
- if readable
32
- res << Digest::SHA1.hexdigest(rand(count * 100).to_s) * (count / 40)
33
- else
34
- res << Digest::SHA1.digest(rand(count * 100).to_s) * (count / 20)
35
- end
36
-
37
- return res
38
- end
39
- end
@@ -1,254 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Require mongrel so we can test that Thin parser don't clash w/ Mongrel parser.
4
- begin
5
- require 'mongrel'
6
- rescue LoadError
7
- warn "Install mongrel to test compatibility w/ it"
8
- end
9
-
10
- describe Request, 'parser' do
11
- it 'should include basic headers' do
12
- request = R("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n")
13
- request.env['SERVER_PROTOCOL'].should == 'HTTP/1.1'
14
- request.env['REQUEST_PATH'].should == '/'
15
- request.env['HTTP_VERSION'].should == 'HTTP/1.1'
16
- request.env['REQUEST_URI'].should == '/'
17
- request.env['GATEWAY_INTERFACE'].should == 'CGI/1.2'
18
- request.env['REQUEST_METHOD'].should == 'GET'
19
- request.env["rack.url_scheme"].should == 'http'
20
- request.env['FRAGMENT'].to_s.should be_empty
21
- request.env['QUERY_STRING'].to_s.should be_empty
22
-
23
- request.should validate_with_lint
24
- end
25
-
26
- it 'should not prepend HTTP_ to Content-Type and Content-Length' do
27
- request = R("POST / HTTP/1.1\r\nHost: localhost\r\nContent-Type: text/html\r\nContent-Length: 2\r\n\r\naa")
28
- request.env.keys.should_not include('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH')
29
- request.env.keys.should include('CONTENT_TYPE', 'CONTENT_LENGTH')
30
-
31
- request.should validate_with_lint
32
- end
33
-
34
- it 'should raise error on invalid request line' do
35
- proc { R("GET / SsUTF/1.1") }.should raise_error(InvalidRequest)
36
- proc { R("GET / HTTP/1.1yousmelllikecheeze") }.should raise_error(InvalidRequest)
37
- end
38
-
39
- it 'should support fragment in uri' do
40
- request = R("GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\nHost: localhost\r\n\r\n")
41
-
42
- request.env['REQUEST_URI'].should == '/forums/1/topics/2375?page=1'
43
- request.env['PATH_INFO'].should == '/forums/1/topics/2375'
44
- request.env['QUERY_STRING'].should == 'page=1'
45
- request.env['FRAGMENT'].should == 'posts-17408'
46
-
47
- request.should validate_with_lint
48
- end
49
-
50
- it 'should parse path with query string' do
51
- request = R("GET /index.html?234235 HTTP/1.1\r\nHost: localhost\r\n\r\n")
52
- request.env['REQUEST_PATH'].should == '/index.html'
53
- request.env['QUERY_STRING'].should == '234235'
54
- request.env['FRAGMENT'].should be_nil
55
-
56
- request.should validate_with_lint
57
- end
58
-
59
- it 'should parse headers from GET request' do
60
- request = R(<<-EOS, true)
61
- GET / HTTP/1.1
62
- Host: myhost.com:3000
63
- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
64
- Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
65
- Accept-Language: en-us,en;q=0.5
66
- Accept-Encoding: gzip,deflate
67
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
68
- Cookie: mium=7
69
- Keep-Alive: 300
70
- Connection: keep-alive
71
-
72
- EOS
73
- request.env['HTTP_HOST'].should == 'myhost.com:3000'
74
- request.env['SERVER_NAME'].should == 'myhost.com'
75
- request.env['SERVER_PORT'].should == '3000'
76
- request.env['HTTP_COOKIE'].should == 'mium=7'
77
-
78
- request.should validate_with_lint
79
- end
80
-
81
- it 'should parse POST request with data' do
82
- request = R(<<-EOS.chomp, true)
83
- POST /postit HTTP/1.1
84
- Host: localhost:3000
85
- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9
86
- Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
87
- Accept-Language: en-us,en;q=0.5
88
- Accept-Encoding: gzip,deflate
89
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
90
- Keep-Alive: 300
91
- Connection: keep-alive
92
- Content-Type: text/html
93
- Content-Length: 37
94
-
95
- name=marc&email=macournoyer@gmail.com
96
- EOS
97
-
98
- request.env['REQUEST_METHOD'].should == 'POST'
99
- request.env['REQUEST_URI'].should == '/postit'
100
- request.env['CONTENT_TYPE'].should == 'text/html'
101
- request.env['CONTENT_LENGTH'].should == '37'
102
- request.env['HTTP_ACCEPT'].should == 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
103
- request.env['HTTP_ACCEPT_LANGUAGE'].should == 'en-us,en;q=0.5'
104
-
105
- request.body.rewind
106
- request.body.read.should == 'name=marc&email=macournoyer@gmail.com'
107
- request.body.class.should == StringIO
108
-
109
- request.should validate_with_lint
110
- end
111
-
112
- it 'should not fuck up on stupid fucked IE6 headers' do
113
- body = <<-EOS
114
- POST /codes/58-tracking-file-downloads-automatically-in-google-analytics-with-prototype/refactors HTTP/1.0
115
- X-Real-IP: 62.24.71.95
116
- X-Forwarded-For: 62.24.71.95
117
- Host: refactormycode.com
118
- Connection: close
119
- TE: deflate,gzip;q=0.3
120
- Accept: */*
121
- Range: bytes=0-499999
122
- Referer: http://refactormycode.com/codes/58-tracking-file-downloads-automatically-in-google-analytics-with-prototype
123
- User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
124
- Content-Length: 1
125
- Content-Type: application/x-www-form-urlencoded
126
- Cookie: _refactormycode_session_id=a1b2n3jk4k5; flash=%7B%7D
127
- Cookie2: $Version="1"
128
-
129
- a
130
- EOS
131
- request = R(body, true)
132
- request.env['HTTP_COOKIE2'].should == '$Version="1"'
133
-
134
- request.should validate_with_lint
135
- end
136
-
137
- it 'shoud accept long query string' do
138
- body = <<-EOS
139
- GET /session?open_id_complete=1&nonce=ytPOcwni&nonce=ytPOcwni&openid.assoc_handle=%7BHMAC-SHA1%7D%7B473e38fe%7D%7BJTjJxA%3D%3D%7D&openid.identity=http%3A%2F%2Fmacournoyer.myopenid.com%2F&openid.mode=id_res&openid.op_endpoint=http%3A%2F%2Fwww.myopenid.com%2Fserver&openid.response_nonce=2007-11-29T01%3A19%3A35ZGA5FUU&openid.return_to=http%3A%2F%2Flocalhost%3A3000%2Fsession%3Fopen_id_complete%3D1%26nonce%3DytPOcwni%26nonce%3DytPOcwni&openid.sig=lPIRgwpfR6JAdGGnb0ZjcY%2FWjr8%3D&openid.signed=assoc_handle%2Cidentity%2Cmode%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned%2Csreg.email%2Csreg.nickname&openid.sreg.email=macournoyer%40yahoo.ca&openid.sreg.nickname=macournoyer HTTP/1.1
140
- Host: localhost:3000
141
-
142
- EOS
143
- request = R(body, true)
144
-
145
- request.env['QUERY_STRING'].should == 'open_id_complete=1&nonce=ytPOcwni&nonce=ytPOcwni&openid.assoc_handle=%7BHMAC-SHA1%7D%7B473e38fe%7D%7BJTjJxA%3D%3D%7D&openid.identity=http%3A%2F%2Fmacournoyer.myopenid.com%2F&openid.mode=id_res&openid.op_endpoint=http%3A%2F%2Fwww.myopenid.com%2Fserver&openid.response_nonce=2007-11-29T01%3A19%3A35ZGA5FUU&openid.return_to=http%3A%2F%2Flocalhost%3A3000%2Fsession%3Fopen_id_complete%3D1%26nonce%3DytPOcwni%26nonce%3DytPOcwni&openid.sig=lPIRgwpfR6JAdGGnb0ZjcY%2FWjr8%3D&openid.signed=assoc_handle%2Cidentity%2Cmode%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned%2Csreg.email%2Csreg.nickname&openid.sreg.email=macournoyer%40yahoo.ca&openid.sreg.nickname=macournoyer'
146
-
147
- request.should validate_with_lint
148
- end
149
-
150
- it 'should parse even with stupid Content-Length' do
151
- body = <<-EOS.chomp
152
- POST / HTTP/1.1
153
- Host: localhost:3000
154
- Content-Length: 300
155
-
156
- aye
157
- EOS
158
- request = R(body, true)
159
-
160
- request.body.rewind
161
- request.body.read.should == 'aye'
162
- end
163
-
164
- it "should parse ie6 urls" do
165
- %w(/some/random/path"
166
- /some/random/path>
167
- /some/random/path<
168
- /we/love/you/ie6?q=<"">
169
- /url?<="&>="
170
- /mal"formed"?
171
- ).each do |path|
172
- parser = HttpParser.new
173
- req = {}
174
- sorta_safe = %(GET #{path} HTTP/1.1\r\n\r\n)
175
- nread = parser.execute(req, sorta_safe, 0)
176
-
177
- sorta_safe.size.should == nread - 1 # Ragel 6 skips last linebreak
178
- parser.should be_finished
179
- parser.should_not be_error
180
- end
181
- end
182
-
183
- xit "should parse absolute request URI" do
184
- request = R(<<-EOS, true)
185
- GET http://localhost:3000/hi HTTP/1.1
186
- Host: localhost:3000
187
-
188
- EOS
189
- request.env['PATH_INFO'].should == '/hi'
190
-
191
- request.should validate_with_lint
192
- end
193
-
194
-
195
- it "should fails on heders larger then MAX_HEADER" do
196
- proc { R("GET / HTTP/1.1\r\nFoo: #{'X' * Request::MAX_HEADER}\r\n\r\n") }.should raise_error(InvalidRequest)
197
- end
198
-
199
- it "should default SERVER_NAME to localhost" do
200
- request = R("GET / HTTP/1.1\r\n\r\n")
201
- request.env['SERVER_NAME'].should == "localhost"
202
- end
203
-
204
- it 'should normalize http_fields' do
205
- [ "GET /index.html HTTP/1.1\r\nhos-t: localhost\r\n\r\n",
206
- "GET /index.html HTTP/1.1\r\nhOs_t: localhost\r\n\r\n",
207
- "GET /index.html HTTP/1.1\r\nhoS-T: localhost\r\n\r\n"
208
- ].each { |req_str|
209
- parser = HttpParser.new
210
- req = {}
211
- nread = parser.execute(req, req_str, 0)
212
- req.should have_key('HTTP_HOS_T')
213
- }
214
- end
215
-
216
- it "should parse PATH_INFO with semicolon" do
217
- qs = "QUERY_STRING"
218
- pi = "PATH_INFO"
219
- {
220
- "/1;a=b?c=d&e=f" => { qs => "c=d&e=f", pi => "/1;a=b" },
221
- "/1?c=d&e=f" => { qs => "c=d&e=f", pi => "/1" },
222
- "/1;a=b" => { qs => "", pi => "/1;a=b" },
223
- "/1;a=b?" => { qs => "", pi => "/1;a=b" },
224
- "/1?a=b;c=d&e=f" => { qs => "a=b;c=d&e=f", pi => "/1" },
225
- "*" => { qs => "", pi => "" },
226
- }.each do |uri, expect|
227
- parser = HttpParser.new
228
- env = {}
229
- nread = parser.execute(env, "GET #{uri} HTTP/1.1\r\nHost: www.example.com\r\n\r\n", 0)
230
-
231
- env[pi].should == expect[pi]
232
- env[qs].should == expect[qs]
233
- env["REQUEST_URI"].should == uri
234
-
235
- next if uri == "*"
236
-
237
- # Validate w/ Ruby's URI.parse
238
- uri = URI.parse("http://example.com#{uri}")
239
- env[qs].should == uri.query.to_s
240
- env[pi].should == uri.path
241
- end
242
- end
243
-
244
- it "should parse IE7 badly encoded URL" do
245
- body = <<-EOS.chomp
246
- GET /H%uFFFDhnchenbrustfilet HTTP/1.1
247
- Host: localhost:3000
248
-
249
- EOS
250
- request = R(body, true)
251
-
252
- request.env['REQUEST_URI'].should == "/H%uFFFDhnchenbrustfilet"
253
- end
254
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Request, 'persistent' do
4
- before do
5
- @request = Request.new
6
- end
7
-
8
- it "should not assume that a persistent connection is maintained for HTTP version 1.0" do
9
- @request.env['HTTP_VERSION'] = 'HTTP/1.0'
10
- @request.should_not be_persistent
11
- end
12
-
13
- it "should assume that a persistent connection is maintained for HTTP version 1.0 when specified" do
14
- @request.env['HTTP_VERSION'] = 'HTTP/1.0'
15
- @request.env['HTTP_CONNECTION'] = 'Keep-Alive'
16
- @request.should be_persistent
17
- end
18
-
19
- it "should maintain a persistent connection for HTTP/1.1 client" do
20
- @request.env['HTTP_VERSION'] = 'HTTP/1.1'
21
- @request.env['HTTP_CONNECTION'] = 'Keep-Alive'
22
- @request.should be_persistent
23
- end
24
-
25
- it "should maintain a persistent connection for HTTP/1.1 client by default" do
26
- @request.env['HTTP_VERSION'] = 'HTTP/1.1'
27
- @request.should be_persistent
28
- end
29
-
30
- it "should not maintain a persistent connection for HTTP/1.1 client when Connection header include close" do
31
- @request.env['HTTP_VERSION'] = 'HTTP/1.1'
32
- @request.env['HTTP_CONNECTION'] = 'close'
33
- @request.should_not be_persistent
34
- end
35
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Request, 'processing' do
4
- it 'should parse in chunks' do
5
- request = Request.new
6
- request.parse("POST / HTTP/1.1\r\n").should be_false
7
- request.parse("Host: localhost\r\n").should be_false
8
- request.parse("Content-Length: 9\r\n").should be_false
9
- request.parse("\r\nvery ").should be_false
10
- request.parse("cool").should be_true
11
-
12
- request.env['CONTENT_LENGTH'].should == '9'
13
- request.body.read.should == 'very cool'
14
- request.should validate_with_lint
15
- end
16
-
17
- it "should move body to tempfile when too big" do
18
- len = Request::MAX_BODY + 2
19
- request = Request.new
20
- request.parse("POST /postit HTTP/1.1\r\nContent-Length: #{len}\r\n\r\n#{'X' * (len/2)}")
21
- request.parse('X' * (len/2))
22
-
23
- request.body.size.should == len
24
- request.should be_finished
25
- request.body.class.should == Tempfile
26
- end
27
-
28
- it "should delete body tempfile when closing" do
29
- body = 'X' * (Request::MAX_BODY + 1)
30
-
31
- request = Request.new
32
- request.parse("POST /postit HTTP/1.1\r\n")
33
- request.parse("Content-Length: #{body.size}\r\n\r\n")
34
- request.parse(body)
35
-
36
- request.body.path.should_not be_nil
37
- request.close
38
- request.body.path.should be_nil
39
- end
40
-
41
- it "should raise error when header is too big" do
42
- big_headers = "X-Test: X\r\n" * (1024 * (80 + 32))
43
- proc { R("GET / HTTP/1.1\r\n#{big_headers}\r\n") }.should raise_error(InvalidRequest)
44
- end
45
-
46
- it "should set body external encoding to ASCII_8BIT" do
47
- pending("Ruby 1.9 compatible implementations only") unless StringIO.instance_methods.include? :external_encoding
48
- Request.new.body.external_encoding.should == Encoding::ASCII_8BIT
49
- end
50
- end