hayabusa 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,13 +6,13 @@ GEM
6
6
  erubis (2.7.0)
7
7
  fcgi (0.9.1)
8
8
  git (1.2.5)
9
- http2 (0.0.21)
9
+ http2 (0.0.22)
10
10
  jeweler (1.6.4)
11
11
  bundler (~> 1.0)
12
12
  git (>= 1.2.5)
13
13
  rake
14
14
  json (1.8.0)
15
- knjrbfw (0.0.105)
15
+ knjrbfw (0.0.107)
16
16
  datet
17
17
  http2
18
18
  php4r
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.23
1
+ 0.0.24
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hayabusa"
8
- s.version = "0.0.23"
8
+ s.version = "0.0.24"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
@@ -39,6 +39,7 @@ Gem::Specification.new do |s|
39
39
  "conf/apache2_hayabusa_conf.conf",
40
40
  "hayabusa.gemspec",
41
41
  "lib/hayabusa.rb",
42
+ "lib/hayabusa_cgi.rb",
42
43
  "lib/hayabusa_cgi_session.rb",
43
44
  "lib/hayabusa_cgi_tools.rb",
44
45
  "lib/hayabusa_client_session.rb",
@@ -0,0 +1,37 @@
1
+ require "cgi"
2
+
3
+ class CGI
4
+ public :env_table
5
+ def self.remove_params
6
+ if (const_defined?(:CGI_PARAMS))
7
+ remove_const(:CGI_PARAMS)
8
+ remove_const(:CGI_COOKIES)
9
+ end
10
+ end
11
+ end
12
+
13
+ # A hack to use CGI in FCGI mode (copied from the original FCGI framework).
14
+ class Hayabusa::Cgi < ::CGI
15
+ def initialize(request, *args)
16
+ ::CGI.remove_params
17
+ @request = request
18
+ super(*args)
19
+ @args = *args
20
+ end
21
+
22
+ def args
23
+ @args
24
+ end
25
+
26
+ def env_table
27
+ @request.env
28
+ end
29
+
30
+ def stdinput
31
+ @request.in
32
+ end
33
+
34
+ def stdoutput
35
+ @request.out
36
+ end
37
+ end
@@ -68,10 +68,10 @@ class Hayabusa::Cgi_tools
68
68
 
69
69
  #This method is used to proxy a request to another FCGI-process, since a single FCGI-process cant handle more requests simultanious.
70
70
  def proxy_request_to(args)
71
- cgi, http, fp_log = args[:cgi], args[:http], args[:fp_log]
71
+ @cgi, @http, fp_log = args[:cgi], args[:http], args[:fp_log]
72
72
 
73
73
  headers = {"Hayabusa_mode" => "proxy"}
74
- cgi.env_table.each do |key, val|
74
+ @cgi.env.each do |key, val|
75
75
  keyl = key.to_s.downcase
76
76
 
77
77
  if key[0, 5] == "HTTP_"
@@ -87,66 +87,62 @@ class Hayabusa::Cgi_tools
87
87
  end
88
88
 
89
89
  #Make request.
90
- uri = Knj::Web.parse_uri(cgi.env_table["REQUEST_URI"])
90
+ uri = Knj::Web.parse_uri(@cgi.env["REQUEST_URI"])
91
91
  url = File.basename(uri[:path])
92
92
  url = url[1, url.length] if url[0] == "/"
93
93
 
94
- if cgi.env_table["QUERY_STRING"].to_s.length > 0
95
- url << "?#{cgi.env_table["QUERY_STRING"]}"
96
- end
97
-
98
- #cgi.print "Content-Type: text/html\r\n"
99
- #cgi.print "\r\n"
100
-
101
- if args[:timeout]
102
- ttime = args[:timeout]
103
- else
104
- ttime = 30
94
+ if @cgi.env["QUERY_STRING"].to_s.length > 0
95
+ url << "?#{cgi.env["QUERY_STRING"]}"
105
96
  end
106
97
 
107
98
  fp_log.puts("Proxying URL: '#{url}'.") if fp_log
108
99
 
109
100
  #The HTTP-connection can have closed mean while, so we have to test it.
110
- raise Errno::ECONNABORTED if !http.socket_working?
101
+ raise Errno::ECONNABORTED unless @http.socket_working?
111
102
 
112
- #require "timeout"
113
- #Timeout.timeout(ttime) do
114
- if cgi.request_method == "POST" and cgi.content_type.to_s.downcase.index("multipart/form-data") != nil
115
- count = 0
116
- http.post_multipart(
117
- :url => url,
118
- :post => self.convert_fcgi_post_fileuploads_to_http2(self.convert_fcgi_post(cgi.params, :http2_compatible => true)),
119
- :default_headers => headers,
120
- :cookies => false,
121
- :on_content => proc{|line|
122
- cgi.print(line) if count > 0
123
- count += 1
124
- }
125
- )
126
- elsif cgi.request_method == "POST"
127
- count = 0
128
- http.post(
103
+ # Count used to know what is the status line.
104
+ @count = 0
105
+
106
+ if @cgi.env["REQUEST_METHOD"] == "POST"
107
+ # Use CGI to parse post.
108
+ real_cgi = Hayabusa::Cgi.new(@cgi)
109
+ params = real_cgi.params
110
+
111
+ if cgi.env["CONTENT_TYPE"].to_s.downcase.include?("multipart/form-data")
112
+ @http.post_multipart(
129
113
  :url => url,
130
- :post => self.convert_fcgi_post(cgi.params, :http2_compatible => true),
114
+ :post => self.convert_fcgi_post_fileuploads_to_http2(self.convert_fcgi_post(params, :http2_compatible => true)),
131
115
  :default_headers => headers,
132
116
  :cookies => false,
133
- :on_content => proc{|line|
134
- cgi.print(line) if count > 0
135
- count += 1
136
- }
117
+ :on_content => self.method(:on_content)
137
118
  )
138
119
  else
139
- count = 0
140
- http.get(
120
+ @http.post(
141
121
  :url => url,
122
+ :post => self.convert_fcgi_post(params, :http2_compatible => true),
142
123
  :default_headers => headers,
143
124
  :cookies => false,
144
- :on_content => proc{|line|
145
- cgi.print(line) if count > 0
146
- count += 1
147
- }
125
+ :on_content => self.method(:on_content)
148
126
  )
149
127
  end
150
- #end
128
+ else
129
+ @http.get(
130
+ :url => url,
131
+ :default_headers => headers,
132
+ :cookies => false,
133
+ :on_content => self.method(:on_content)
134
+ )
135
+ end
136
+ end
137
+
138
+ def on_content(line)
139
+ if @count <= 0
140
+ # This is needed to trick FCGI into writing out correct status codes by ignoring the original status code and outputting it as a "Status"-header instead which is defined in the response-file.
141
+ else
142
+ # Write the given line to the content.
143
+ @cgi.out.print(line)
144
+ end
145
+
146
+ @count += 1
151
147
  end
152
148
  end
@@ -1,3 +1,5 @@
1
+ require "cgi"
2
+
1
3
  #This class is used for FCGI-sessions. It normally starts a Hayabusa-host-process which this (and other) FCGI-processes will proxy requests to. The host-process will automatically kill itself when no more FCGI-sessions are connected to emulate normal FCGI behaviour.
2
4
  class Hayabusa::Fcgi
3
5
  def initialize
@@ -24,10 +26,10 @@ class Hayabusa::Fcgi
24
26
  return nil if @hayabusa or @fcgi_proxy
25
27
 
26
28
  #Parse the configuration-header and generate Hayabusa-config-hash.
27
- raise "No HTTP_HAYABUSA_FCGI_CONFIG-header was given." if !@cgi.env_table["HTTP_HAYABUSA_FCGI_CONFIG"]
28
- @hayabusa_fcgi_conf_path = @cgi.env_table["HTTP_HAYABUSA_FCGI_CONFIG"]
29
+ raise "No HTTP_HAYABUSA_FCGI_CONFIG-header was given." if !@cgi.env["HTTP_HAYABUSA_FCGI_CONFIG"]
30
+ @hayabusa_fcgi_conf_path = @cgi.env["HTTP_HAYABUSA_FCGI_CONFIG"]
29
31
  require @hayabusa_fcgi_conf_path
30
- raise "No 'Hayabusa::FCGI_CONF'-constant was spawned by '#{@cgi.env_table["HTTP_HAYABUSA_FCGI_CONFIG"]}'." if !Hayabusa.const_defined?(:FCGI_CONF)
32
+ raise "No 'Hayabusa::FCGI_CONF'-constant was spawned by '#{@cgi.env["HTTP_HAYABUSA_FCGI_CONFIG"]}'." if !Hayabusa.const_defined?(:FCGI_CONF)
31
33
  conf = Hayabusa::FCGI_CONF
32
34
 
33
35
  hayabusa_conf = Hayabusa::FCGI_CONF[:hayabusa]
@@ -132,11 +134,8 @@ class Hayabusa::Fcgi
132
134
  $stderr.puts "[hayabusa] Starting FCGI." if @debug
133
135
 
134
136
  begin
135
- FCGI.each_cgi do |cgi|
137
+ FCGI.each do |cgi|
136
138
  begin
137
- #cgi.print "Content-Type: text/html\r\n"
138
- #cgi.print "\r\n"
139
-
140
139
  #Set 'cgi'-variable for CGI-tools.
141
140
  @cgi_tools.cgi = cgi
142
141
  @cgi = cgi
@@ -149,23 +148,20 @@ class Hayabusa::Fcgi
149
148
  end
150
149
 
151
150
  #Ensure the same FCGI-process isnt active for more than one website.
152
- raise "Expected 'HTTP_HAYABUSA_FCGI_CONFIG' to be '#{@hayabusa_fcgi_conf_path}' but it wasnt: '#{cgi.env_table["HTTP_HAYABUSA_FCGI_CONFIG"]}'." if @hayabusa_fcgi_conf_path and @hayabusa_fcgi_conf_path != cgi.env_table["HTTP_HAYABUSA_FCGI_CONFIG"]
151
+ raise "Expected 'HTTP_HAYABUSA_FCGI_CONFIG' to be '#{@hayabusa_fcgi_conf_path}' but it wasnt: '#{cgi.env["HTTP_HAYABUSA_FCGI_CONFIG"]}'." if @hayabusa_fcgi_conf_path and @hayabusa_fcgi_conf_path != cgi.env["HTTP_HAYABUSA_FCGI_CONFIG"]
153
152
 
154
- if @fcgi_proxy
155
- #Proxy request to the host-FCGI-process.
156
- $stderr.puts "[hayabusa] Proxying request." if @debug
157
- @cgi_tools.proxy_request_to(:cgi => cgi, :http => @fcgi_proxy[:http], :fp_log => @fcgi_proxy[:fp_log])
158
- else
159
- self.handle_fcgi_request(:cgi => cgi)
160
- end
153
+ #Proxy request to the host-FCGI-process.
154
+ raise "No proxy spawned." unless @fcgi_proxy
155
+ $stderr.puts "[hayabusa] Proxying request." if @debug
156
+ @cgi_tools.proxy_request_to(:cgi => cgi, :http => @fcgi_proxy[:http], :fp_log => @fcgi_proxy[:fp_log])
161
157
  rescue Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET => e
162
158
  $stderr.puts "[hayabusa] Connection to server was interrupted - trying again: <#{e.class.name}> #{e.message}"
163
159
  @fcgi_proxy = nil #Force re-evaluate if this process should be host or proxy.
164
160
  retry
165
161
  rescue Exception => e
166
- cgi.print "Content-Type: text/html\r\n"
167
- cgi.print "\r\n"
168
- cgi.print Knj::Errors.error_str(e, :html => true)
162
+ @cgi.out.print "Content-Type: text/html\r\n"
163
+ @cgi.out.print "\r\n"
164
+ @cgi.out.print Knj::Errors.error_str(e, :html => true)
169
165
 
170
166
  if @hayabusa
171
167
  @hayabusa.log_puts e.inspect
@@ -175,6 +171,7 @@ class Hayabusa::Fcgi
175
171
  STDERR.puts e.backtrace
176
172
  end
177
173
  ensure
174
+ @cgi.finish
178
175
  @cgi = nil
179
176
  @cgi_tools.cgi = nil
180
177
  end
@@ -184,45 +181,4 @@ class Hayabusa::Fcgi
184
181
  @hayabusa.stop if @hayabusa
185
182
  end
186
183
  end
187
-
188
- #Handles the request as a real request on a Hayabusa-host running inside the current process. This is not used any more but kept if we need support for it once again (maybe the developer should be able to decide this in some kind of config?).
189
- def handle_fcgi_request(args)
190
- #Host the FCGI-process.
191
- $stderr.puts "[hayabusa] Running request as CGI." if @debug
192
-
193
- #Enforce $stdout variable.
194
- $stdout = @hayabusa.cio
195
-
196
- #The rest is copied from the FCGI-part.
197
- headers = {}
198
- @cgi.env_table.each do |key, val|
199
- if key[0, 5] == "HTTP_" and key != "HTTP_HAYABUSA_FCGI_CONFIG"
200
- key = key[5, key.length].gsub("_", " ").gsub(" ", "-")
201
- headers[key] = val
202
- end
203
- end
204
-
205
- meta = @cgi.env_table.to_hash
206
-
207
- uri = Knj::Web.parse_uri(meta["REQUEST_URI"])
208
- meta["PATH_TRANSLATED"] = File.basename(uri[:path])
209
-
210
- cgi_data = {
211
- :cgi => @cgi,
212
- :headers => headers,
213
- :get => Knj::Web.parse_urlquery(@cgi.env_table["QUERY_STRING"], :urldecode => true, :force_utf8 => true),
214
- :meta => meta
215
- }
216
- if @cgi.request_method == "POST"
217
- cgi_data[:post] = @cgi_tools.convert_fcgi_post(@cgi.params)
218
- else
219
- cgi_data[:post] = {}
220
- end
221
-
222
- @hayabusa.config[:cgi] = cgi_data
223
-
224
-
225
- #Handle request.
226
- @hayabusa.start_cgi_request
227
- end
228
184
  end
@@ -193,16 +193,10 @@ class Hayabusa::Http_session::Request
193
193
  ).return
194
194
  post_data.close(true)
195
195
 
196
- self.convert_post(@post, post_treated, {:urldecode => false})
196
+ Hayabusa::Http_session::Request.convert_post(@post, post_treated, {:urldecode => false})
197
197
  else
198
- post_data.split("&").each do |splitted|
199
- splitted = splitted.split("=")
200
- key = Knj::Web.urldec(splitted[0]).to_s.encode("utf-8")
201
- val = splitted[1].to_s.encode("utf-8")
202
- post_treated[key] = val
203
- end
204
-
205
- self.convert_post(@post, post_treated, {:urldecode => true})
198
+ Hayabusa::Http_session::Request.parse_post(post_data, post_treated)
199
+ Hayabusa::Http_session::Request.convert_post(@post, post_treated, {:urldecode => true})
206
200
  end
207
201
  end
208
202
  ensure
@@ -219,6 +213,16 @@ class Hayabusa::Http_session::Request
219
213
  end
220
214
  end
221
215
 
216
+ # Takes raw post data and puts it into a hash.
217
+ def self.parse_post(post_data, post_treated)
218
+ post_data.split("&").each do |splitted|
219
+ splitted = splitted.split("=")
220
+ key = Knj::Web.urldec(splitted[0]).to_s.encode("utf-8")
221
+ val = splitted[1].to_s.encode("utf-8")
222
+ post_treated[key] = val
223
+ end
224
+ end
225
+
222
226
  #Parses the if-modified-since header and returns it as a Time-object. Returns false is no if-modified-since-header is given or raises an RuntimeError if it cant be parsed.
223
227
  def modified_since
224
228
  return @modified_since if @modified_since
@@ -233,8 +237,8 @@ class Hayabusa::Http_session::Request
233
237
  return @modified_since
234
238
  end
235
239
 
236
- #Converts post-result to the right type of hash.
237
- def convert_post(seton, post_val, args = {})
240
+ # Converts post-result to the right type of hash.
241
+ def self.convert_post(seton, post_val, args = {})
238
242
  post_val.each do |varname, value|
239
243
  Knj::Web.parse_name(seton, varname, value, args)
240
244
  end
@@ -116,6 +116,9 @@ class Hayabusa::Http_session::Response
116
116
  res << NL
117
117
  end
118
118
 
119
+ # The status header is used to make CGI or FCGI use the correct status-code.
120
+ self.header("Status", "#{@status} #{STATUS_CODES[@status]}")
121
+
119
122
  @headers.each do |key, val|
120
123
  res << "#{val[0]}: #{val[1]}#{NL}"
121
124
  end
@@ -1,3 +1,6 @@
1
+ require "rubygems"
2
+ require "RMagick"
3
+
1
4
  Hayabusa::CGI_CONF = {
2
5
  :hayabusa => {
3
6
  :title => "Cgi_test",
@@ -1,3 +1,6 @@
1
+ require "rubygems"
2
+ require "RMagick"
3
+
1
4
  Hayabusa::FCGI_CONF = {
2
5
  :hayabusa => {
3
6
  :title => "Fcgi_test",
@@ -1,92 +1,92 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Hayabusa" do
4
- it "should be able to start a sample-server" do
5
- require "rubygems"
6
- require "sqlite3" if RUBY_ENGINE != "jruby"
7
- require "json"
8
-
9
- begin
10
- require "#{File.realpath(File.dirname(__FILE__))}/../../knjrbfw/lib/knjrbfw.rb"
11
- rescue LoadError
12
- require "knjrbfw"
13
- end
14
-
15
- require "#{File.realpath(File.dirname(__FILE__))}/../lib/hayabusa.rb"
16
-
17
- begin
18
- require "#{File.realpath(File.dirname(__FILE__))}/../../http2/lib/http2.rb"
19
- rescue LoadError
20
- require "http2"
21
- end
22
-
23
- db_path = "#{Knj::Os.tmpdir}/hayabusa_rspec.sqlite3"
24
- File.unlink(db_path) if File.exists?(db_path)
25
-
26
- db = Knj::Db.new(
27
- :type => "sqlite3",
28
- :path => db_path,
29
- :return_keys => "symbols"
30
- )
31
-
32
- $appserver = Hayabusa.new(
33
- :debug => false,
34
- :title => "SpecTest",
35
- :port => 1515,
36
- :doc_root => "#{File.dirname(__FILE__)}/../pages",
37
- :locales_gettext_funcs => true,
38
- :locale_default => "da_DK",
39
- :db => db,
40
- :threadding => {
41
- :priority => -3
42
- }
43
- )
44
-
45
- $appserver.config[:handlers] << {
46
- :regex => /^\/Kasper$/,
47
- :callback => proc{|data|
48
- data[:httpsession].page_path = nil
49
-
50
- eruby = data[:httpsession].eruby
51
- eruby.connect(:on_error) do |e|
52
- _hb.handle_error(e)
53
- end
54
-
55
- eruby.import("#{File.dirname(__FILE__)}/../pages/spec.rhtml")
56
- }
4
+ require "rubygems"
5
+ require "sqlite3" if RUBY_ENGINE != "jruby"
6
+ require "json"
7
+ require "RMagick"
8
+
9
+ begin
10
+ require "#{File.realpath(File.dirname(__FILE__))}/../../knjrbfw/lib/knjrbfw.rb"
11
+ rescue LoadError
12
+ require "knjrbfw"
13
+ end
14
+
15
+ require "#{File.realpath(File.dirname(__FILE__))}/../lib/hayabusa.rb"
16
+
17
+ begin
18
+ require "#{File.realpath(File.dirname(__FILE__))}/../../http2/lib/http2.rb"
19
+ puts "Loaded custom version of Http2."
20
+ rescue LoadError
21
+ require "http2"
22
+ puts "Loaded normal gem version of Http2."
23
+ end
24
+
25
+ db_path = "#{Knj::Os.tmpdir}/hayabusa_rspec.sqlite3"
26
+ File.unlink(db_path) if File.exists?(db_path)
27
+
28
+ db = Knj::Db.new(
29
+ :type => "sqlite3",
30
+ :path => db_path,
31
+ :return_keys => "symbols"
32
+ )
33
+
34
+ $appserver = Hayabusa.new(
35
+ :debug => false,
36
+ :title => "SpecTest",
37
+ :port => 1515,
38
+ :doc_root => "#{File.dirname(__FILE__)}/../pages",
39
+ :locales_gettext_funcs => true,
40
+ :locale_default => "da_DK",
41
+ :db => db,
42
+ :threadding => {
43
+ :priority => -3
57
44
  }
58
-
59
- $appserver.vars[:test] = "kasper"
60
- $appserver.define_magic_var(:_testvar1, "Kasper")
61
- $appserver.define_magic_var(:_testvar2, "Johansen")
62
- $appserver.start
63
-
64
- raise "Expected thread-pool-priority to be '-3' but it wasnt: '#{$appserver.threadpool.args[:priority]}'." if $appserver.threadpool.args[:priority] != -3
65
-
66
- http = Http2.new(:host => "localhost", :port => 80, :encoding_gzip => false, :debug => false) rescue nil
67
-
68
- $testmodes = [{
69
- :name => :standalone,
70
- :path_pre => "",
71
- :http => Http2.new(:host => "localhost", :port => 1515, :debug => false)
45
+ )
46
+
47
+ $appserver.config[:handlers] << {
48
+ :regex => /^\/Kasper$/,
49
+ :callback => proc{|data|
50
+ data[:httpsession].page_path = nil
51
+
52
+ eruby = data[:httpsession].eruby
53
+ eruby.connect(:on_error) do |e|
54
+ _hb.handle_error(e)
55
+ end
56
+
57
+ eruby.import("#{File.dirname(__FILE__)}/../pages/spec.rhtml")
58
+ }
59
+ }
60
+
61
+ $appserver.vars[:test] = "kasper"
62
+ $appserver.define_magic_var(:_testvar1, "Kasper")
63
+ $appserver.define_magic_var(:_testvar2, "Johansen")
64
+ $appserver.start
65
+
66
+ raise "Expected thread-pool-priority to be '-3' but it wasnt: '#{$appserver.threadpool.args[:priority]}'." if $appserver.threadpool.args[:priority] != -3
67
+
68
+ http = Http2.new(:host => "localhost", :port => 80, :encoding_gzip => false, :debug => false) rescue nil
69
+
70
+ $testmodes = [{
71
+ :name => :standalone,
72
+ :path_pre => "",
73
+ :http => Http2.new(:host => "localhost", :port => 1515, :debug => false)
74
+ }]
75
+
76
+ if http
77
+ $testmodes += [{
78
+ :name => :cgi,
79
+ :path_pre => "hayabusa_cgi_test/",
80
+ :http => http
81
+ },{
82
+ :name => :fcgi,
83
+ :path_pre => "hayabusa_fcgi_test/",
84
+ :http => http
72
85
  }]
73
-
74
- if http
75
- $testmodes += [{
76
- :name => :cgi,
77
- :path_pre => "hayabusa_cgi_test/",
78
- :http => http
79
- },{
80
- :name => :fcgi,
81
- :path_pre => "hayabusa_fcgi_test/",
82
- :http => http
83
- }]
84
- end
85
86
  end
86
87
 
87
88
  it "should be able to get multiple pictures" do
88
89
  require "base64"
89
- require "RMagick"
90
90
 
91
91
  # Symlink 'image.rhtml' first.
92
92
  img_from_path = "#{Knj.knjrbfw_path}/webscripts/image.rhtml"
@@ -97,13 +97,12 @@ describe "Hayabusa" do
97
97
  File.unlink(img_to_path) if File.symlink?(img_to_path)
98
98
  File.symlink(img_from_path, img_to_path)
99
99
 
100
+ last_tdata = nil
101
+
100
102
  begin
101
- http = $testmodes.first[:http]
102
- res = http.get("image.rhtml?path64=#{Base64.encode64("image.png").to_s.strip}&rounded_corners=8&width=550")
103
- res.contenttype.should eql("image/png")
104
- res.header?("content-length").should eql(true)
105
-
106
103
  $testmodes.each do |tdata|
104
+ last_tdata = tdata
105
+
107
106
  3.times do
108
107
  path = "#{File.dirname(__FILE__)}/../pages/testpic.jpeg"
109
108
 
@@ -122,6 +121,7 @@ describe "Hayabusa" do
122
121
  #puts "Getting exit-script through #{tdata[:name]}"
123
122
  res_exit = tdata[:http].get("#{tdata[:path_pre]}spec_exit.rhtml")
124
123
  res_exit.body.should eql("ExitOutput\n")
124
+ res_exit.code.to_i.should eql(304)
125
125
 
126
126
  #puts "Getting normal image through #{tdata[:name]}"
127
127
  res2 = tdata[:http].get("#{tdata[:path_pre]}image.rhtml?path64=#{Base64.encode64("image.png").to_s.strip}&rounded_corners=8&width=550")
@@ -130,6 +130,11 @@ describe "Hayabusa" do
130
130
  res1.body.bytesize.should eql(res2.body.bytesize)
131
131
  end
132
132
  end
133
+ rescue => e
134
+ puts "Mode: #{last_tdata[:name]}" if last_tdata
135
+ STDERR.puts e.inspect
136
+ STDERR.puts e.backtrace
137
+ raise e
133
138
  ensure
134
139
  File.unlink(img_to_path) if File.exists?(img_to_path)
135
140
  end
@@ -162,9 +167,12 @@ describe "Hayabusa" do
162
167
 
163
168
  1.upto(2) do |count|
164
169
  data = Marshal.load(res.body)
170
+ raise "No data returned?" unless data
165
171
 
166
172
  if count != 2
167
- if data["testfile#{count}"]["val"] != File.read(fpaths["fpath#{count}"])
173
+ key = "testfile#{count}"
174
+ raise "Not defined in returned data: '#{key}' in '#{data}'." unless data.key?(key)
175
+ if data[key]["val"] != File.read(fpaths["fpath#{count}"])
168
176
  File.open("/tmp/hayabusa_spec_testfile#{count}_1", "w") do |fp|
169
177
  fp.puts("Class: #{data["testfile#{count}"].class.name}")
170
178
  fp.write(data["testfile#{count}"])
@@ -205,7 +213,7 @@ describe "Hayabusa" do
205
213
  res = tdata[:http].post(:url => "#{tdata[:path_pre]}spec.rhtml", :post => {
206
214
  "postdata" => "Test post"
207
215
  })
208
- raise "POST-request did not return expected data: '#{res.body}' for '#{tdata[:name]}'." if res.body.to_s.strip != "Test post"
216
+ raise "POST-request did not return expected data: '#{res.body}' for '#{tdata[:name]}' data: '#{res.body}'." if res.body.to_s.strip != "Test post"
209
217
 
210
218
  res = tdata[:http].post(:url => "#{tdata[:path_pre]}spec.rhtml?choice=dopostconvert", :post => {
211
219
  "postdata" => "Test post",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hayabusa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -273,6 +273,7 @@ files:
273
273
  - conf/apache2_hayabusa_conf.conf
274
274
  - hayabusa.gemspec
275
275
  - lib/hayabusa.rb
276
+ - lib/hayabusa_cgi.rb
276
277
  - lib/hayabusa_cgi_session.rb
277
278
  - lib/hayabusa_cgi_tools.rb
278
279
  - lib/hayabusa_client_session.rb
@@ -354,7 +355,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
354
355
  version: '0'
355
356
  segments:
356
357
  - 0
357
- hash: 4394094248699079700
358
+ hash: 635854692325218381
358
359
  required_rubygems_version: !ruby/object:Gem::Requirement
359
360
  none: false
360
361
  requirements: