hayabusa 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -9,12 +9,13 @@ gem "mail"
9
9
  gem "datet"
10
10
  gem "http2"
11
11
  gem "tpool"
12
+ gem "fcgi"
12
13
 
13
14
  # Add dependencies to develop your gem here.
14
15
  # Include everything needed to run rake, tests, features, etc.
15
16
  group :development do
16
17
  gem "json"
17
- gem "rspec", "~> 2.3.0"
18
+ gem "rspec", ">= 2.3.0"
18
19
  gem "bundler", ">= 1.0.0"
19
20
  gem "jeweler", "~> 1.6.3"
20
21
  gem "sqlite3" if RUBY_ENGINE != "jruby"
@@ -4,15 +4,16 @@ GEM
4
4
  datet (0.0.20)
5
5
  diff-lcs (1.1.3)
6
6
  erubis (2.7.0)
7
+ fcgi (0.8.8)
7
8
  git (1.2.5)
8
- http2 (0.0.10)
9
+ http2 (0.0.12)
9
10
  i18n (0.6.1)
10
11
  jeweler (1.6.4)
11
12
  bundler (~> 1.0)
12
13
  git (>= 1.2.5)
13
14
  rake
14
15
  json (1.7.5)
15
- knjrbfw (0.0.98)
16
+ knjrbfw (0.0.99)
16
17
  datet
17
18
  http2
18
19
  php4r
@@ -28,14 +29,14 @@ GEM
28
29
  http2
29
30
  polyglot (0.3.3)
30
31
  rake (0.9.2.2)
31
- rspec (2.3.0)
32
- rspec-core (~> 2.3.0)
33
- rspec-expectations (~> 2.3.0)
34
- rspec-mocks (~> 2.3.0)
35
- rspec-core (2.3.1)
36
- rspec-expectations (2.3.0)
37
- diff-lcs (~> 1.1.2)
38
- rspec-mocks (2.3.0)
32
+ rspec (2.11.0)
33
+ rspec-core (~> 2.11.0)
34
+ rspec-expectations (~> 2.11.0)
35
+ rspec-mocks (~> 2.11.0)
36
+ rspec-core (2.11.1)
37
+ rspec-expectations (2.11.3)
38
+ diff-lcs (~> 1.1.3)
39
+ rspec-mocks (2.11.3)
39
40
  sqlite3 (1.3.6)
40
41
  tpool (0.0.4)
41
42
  treetop (1.4.10)
@@ -51,11 +52,12 @@ DEPENDENCIES
51
52
  bundler (>= 1.0.0)
52
53
  datet
53
54
  erubis
55
+ fcgi
54
56
  http2
55
57
  jeweler (~> 1.6.3)
56
58
  json
57
59
  knjrbfw
58
60
  mail
59
- rspec (~> 2.3.0)
61
+ rspec (>= 2.3.0)
60
62
  sqlite3
61
63
  tpool
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "hayabusa"
8
- s.version = "0.0.15"
7
+ s.name = %q{hayabusa}
8
+ s.version = "0.0.16"
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"]
12
- s.date = "2012-09-30"
13
- s.description = "A threadded web/app-server that focuses on threadding, shared ressources, speed and more."
14
- s.email = "k@spernj.org"
12
+ s.date = %q{2012-10-05}
13
+ s.description = %q{A threadded web/app-server that focuses on threadding, shared ressources, speed and more.}
14
+ s.email = %q{k@spernj.org}
15
15
  s.executables = ["check_running.rb", "hayabusa_benchmark.rb", "hayabusa_cgi.rb", "hayabusa_fcgi.fcgi", "hayabusa_fcgi.rb", "hayabusa_fcgi_server.rb", "hayabusa_spec_restart.rb", "knjappserver_start.rb"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE.txt",
@@ -95,17 +95,18 @@ Gem::Specification.new do |s|
95
95
  "pages/spec_vars_get.rhtml",
96
96
  "pages/spec_vars_header.rhtml",
97
97
  "pages/spec_vars_post.rhtml",
98
+ "pages/spec_vars_post_fileupload.rhtml",
98
99
  "pages/tests.rhtml",
99
100
  "pages/threadded_content_test.rhtml",
100
101
  "spec/fcgi_multiple_processes_spec.rb",
101
102
  "spec/hayabusa_spec.rb",
102
103
  "spec/spec_helper.rb"
103
104
  ]
104
- s.homepage = "http://github.com/kaspernj/hayabusa"
105
+ s.homepage = %q{http://github.com/kaspernj/hayabusa}
105
106
  s.licenses = ["MIT"]
106
107
  s.require_paths = ["lib"]
107
- s.rubygems_version = "1.8.24"
108
- s.summary = "A threadded web/app-server that supports stand-alone, CGI and FCGI-modes."
108
+ s.rubygems_version = %q{1.6.2}
109
+ s.summary = %q{A threadded web/app-server that supports stand-alone, CGI and FCGI-modes.}
109
110
 
110
111
  if s.respond_to? :specification_version then
111
112
  s.specification_version = 3
@@ -117,8 +118,9 @@ Gem::Specification.new do |s|
117
118
  s.add_runtime_dependency(%q<datet>, [">= 0"])
118
119
  s.add_runtime_dependency(%q<http2>, [">= 0"])
119
120
  s.add_runtime_dependency(%q<tpool>, [">= 0"])
121
+ s.add_runtime_dependency(%q<fcgi>, [">= 0"])
120
122
  s.add_development_dependency(%q<json>, [">= 0"])
121
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
123
+ s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
122
124
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
123
125
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
124
126
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
@@ -129,8 +131,9 @@ Gem::Specification.new do |s|
129
131
  s.add_dependency(%q<datet>, [">= 0"])
130
132
  s.add_dependency(%q<http2>, [">= 0"])
131
133
  s.add_dependency(%q<tpool>, [">= 0"])
134
+ s.add_dependency(%q<fcgi>, [">= 0"])
132
135
  s.add_dependency(%q<json>, [">= 0"])
133
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
136
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
134
137
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
135
138
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
136
139
  s.add_dependency(%q<sqlite3>, [">= 0"])
@@ -142,8 +145,9 @@ Gem::Specification.new do |s|
142
145
  s.add_dependency(%q<datet>, [">= 0"])
143
146
  s.add_dependency(%q<http2>, [">= 0"])
144
147
  s.add_dependency(%q<tpool>, [">= 0"])
148
+ s.add_dependency(%q<fcgi>, [">= 0"])
145
149
  s.add_dependency(%q<json>, [">= 0"])
146
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
150
+ s.add_dependency(%q<rspec>, [">= 2.3.0"])
147
151
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
148
152
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
149
153
  s.add_dependency(%q<sqlite3>, [">= 0"])
@@ -5,8 +5,13 @@ class Hayabusa::Cgi_tools
5
5
  def convert_fcgi_post(params)
6
6
  post_hash = {}
7
7
 
8
- params.each do |key, val|
9
- post_hash[key] = val.first
8
+ params.each do |key, realval|
9
+ val = realval.first
10
+
11
+ #Sometimes uploaded files are given as StringIO's.
12
+ val = val.string if val.is_a?(StringIO)
13
+
14
+ post_hash[key] = val
10
15
  end
11
16
 
12
17
  post_ret = {}
@@ -46,21 +46,15 @@ class Hayabusa
46
46
 
47
47
  thread_obj.args[:running] = true
48
48
  yield(*args[:args])
49
- _hb.log_puts("Done yielding for #{args[:id]}")
50
49
  rescue => e
51
50
  thread_obj.args[:error] = true
52
51
  thread_obj.args[:error_obj] = e
53
52
 
54
53
  self.handle_error(e)
55
54
  ensure
56
- _hb.log_puts("Seting arguments on thread.") if @debug
57
55
  thread_obj.args[:running] = false
58
56
  thread_obj.args[:done] = true
59
-
60
- _hb.log_puts("Free thread ob-db.") if @debug
61
57
  @ob.db.free_thread if @ob.db.opts[:threadsafe]
62
-
63
- _hb.log_puts("Free thread db-handler.") if @debug
64
58
  @db_handler.free_thread if @db_handler.opts[:threadsafe]
65
59
  end
66
60
  end
@@ -123,7 +117,6 @@ class Hayabusa::Thread_instance
123
117
 
124
118
  def join
125
119
  while !@args[:done] and !@args[:error]
126
- _hb.log_puts(@args)
127
120
  sleep 0.1
128
121
  end
129
122
  end
@@ -44,7 +44,7 @@ class Hayabusa::Fcgi
44
44
  File.open(fcgi_config_fp) do |fp|
45
45
  fp.flock(File::LOCK_EX)
46
46
 
47
- fcgi_config_cont = File.read(fcgi_config_fp)
47
+ fcgi_config_cont = File.read(fcgi_config_fp) rescue ""
48
48
  if !fcgi_config_cont.empty?
49
49
  #Seems like an instance is already running - check PID to be sure.
50
50
  fcgi_config = Marshal.load(File.read(fcgi_config_fp))
@@ -121,7 +121,7 @@ class Hayabusa::Http_session < Hayabusa::Client_session
121
121
  @hb.log_puts "#{__id__} - Closing httpsession because of timeout." if @debug
122
122
  rescue Errno::ECONNRESET, Errno::ENOTCONN, Errno::EPIPE => e
123
123
  @hb.log_puts "#{__id__} - Connection error (#{e.inspect})..." if @debug
124
- @hb.log_puts e.backtrace
124
+ @hb.log_puts e.backtrace if @debug
125
125
  rescue Interrupt => e
126
126
  raise e
127
127
  rescue Exception => e
@@ -1,41 +1,97 @@
1
+ require "tempfile"
2
+
1
3
  #This class parses and handels post-multipart requests.
2
4
  class Hayabusa::Http_session::Post_multipart
5
+ #This hash contains all the data read from the post-request.
3
6
  attr_reader :return
4
7
 
5
8
  def initialize(args)
6
9
  @args = args
7
- boundary_regexp = /\A--#{@args["boundary"]}(--)?#{@args["crlf"]}\z/
10
+ crlf = args[:crlf]
11
+
12
+ boundary_regexp = /\A--#{Regexp.escape(@args[:boundary])}(--)?(\r\n|\n|$)\z/
8
13
  @return = {}
9
14
  @data = nil
10
15
  @mode = nil
16
+ @clength = 0
11
17
  @headers = {}
12
18
  @counts = {}
19
+ str_crlf = nil
13
20
 
14
- @args["io"].each do |line|
15
- if boundary_regexp =~ line
21
+ @args[:io].each do |line|
22
+ begin
23
+ boundary_match = line.match(boundary_regexp)
24
+ rescue ArgumentError
25
+ #Happens when "invalid byte sequence in UTF-8" - the boundary-line will be UTF-8-valid and match the 'boundary_regexp'.
26
+ boundary_match = false
27
+ end
28
+
29
+ if boundary_match
16
30
  #Finish the data we were writing.
17
31
  self.finish_data if @data
18
32
 
19
- @data = ""
33
+ @data_first = true
34
+ @data_written = 0
35
+ @clength = nil
36
+ @name = nil
20
37
  @mode = "headers"
38
+ str_crlf = nil
21
39
  elsif @mode == "headers"
22
- if match = line.match(/^(.+?):\s+(.+)#{@args["crlf"]}$/)
23
- @headers[match[1].to_s.downcase] = match[2]
24
- elsif line == @args["crlf"]
40
+ if match = line.match(/^(.+?):\s+(.+)#{crlf}$/)
41
+ key = match[1].to_s.downcase
42
+ val = match[2]
43
+
44
+ @headers[key] = val
45
+
46
+ if key == "content-length"
47
+ @clength = val.to_i
48
+ elsif key == "content-disposition"
49
+ #Figure out value-name in post-hash.
50
+ match_name = val.match(/name=\"(.+?)\"/)
51
+ raise "Could not match name." if !match_name
52
+ @name = match_name[1]
53
+
54
+ #Fix count with name if given as increamental [].
55
+ if match = @name.match(/^(.+)\[\]$/)
56
+ if !@counts.key?(match[1])
57
+ @counts[match[1]] = 0
58
+ else
59
+ @counts[match[1]] += 1
60
+ end
61
+
62
+ @name = "#{match[1]}[#{@counts[match[1]]}]"
63
+ end
64
+
65
+ #Figure out actual filename.
66
+ if match_fname = val.match(/filename=\"(.+?)\"/)
67
+ @fname = match_fname[1]
68
+ @data = Tempfile.new("hayabusa_http_session_post_multipart")
69
+ else
70
+ @data = ""
71
+ end
72
+ end
73
+ elsif line == crlf
25
74
  @mode = "body"
26
75
  else
27
76
  raise "Could not match header from: '#{line}'."
28
77
  end
29
78
  elsif @mode == "body"
30
- @data << line
31
- elsif line == @args["crlf"] and !@mode
79
+ match = line.match(/^(.*?)(\r\n|\n)$/)
80
+ str = "#{str_crlf}#{match[1]}"
81
+ str_crlf = match[2]
82
+
83
+ @data_written += str.bytesize
84
+ @data << str
85
+
86
+ self.finish_data if @clength and @data_written >= @clength
87
+ elsif !@mode and (line == crlf or line == "\n" or line == "\r\n")
32
88
  #ignore.
33
89
  else
34
- raise "Invalid mode: '#{@mode}' for line: '#{line}'."
90
+ raise "Invalid mode: '#{@mode}' (#{@mode.class.name}) for line: '#{line}' for total post-string:\n#{@args[:io].string}"
35
91
  end
36
92
  end
37
93
 
38
- self.finish_data if @data and @data.to_s.length > 0
94
+ self.finish_data if @data
39
95
 
40
96
  @data = nil
41
97
  @headers = nil
@@ -45,50 +101,37 @@ class Hayabusa::Http_session::Post_multipart
45
101
 
46
102
  #Add the current treated data to the return-hash.
47
103
  def finish_data
48
- @data.chop!
49
- name = nil
50
-
51
- disp = @headers["content-disposition"]
52
- raise "No 'content-disposition' was given." if !disp
53
-
54
-
55
- #Figure out value-name in post-hash.
56
- match_name = disp.match(/name=\"(.+?)\"/)
57
- raise "Could not match name." if !match_name
58
- name = match_name[1]
59
-
60
-
61
- #Fix count with name if given as increamental [].
62
- if match = name.match(/^(.+)\[\]$/)
63
- if !@counts.key?(match[1])
64
- @counts[match[1]] = 0
65
- else
66
- @counts[match[1]] += 1
67
- end
104
+ if @headers.empty? and @data_written == 0
105
+ @data.close(true) if @data.is_a?(Tempfile)
68
106
 
69
- name = "#{match[1]}[#{@counts[match[1]]}]"
107
+ self.reset_data
108
+ return nil
70
109
  end
71
110
 
111
+ @data.close(false) if @data.is_a?(Tempfile)
112
+ raise "No 'content-disposition' was given (#{@headers}) (#{@data})." if !@name
72
113
 
73
- #Figure out actual filename.
74
- match_fname = disp.match(/filename=\"(.+?)\"/)
75
-
76
- if match_fname
114
+ if @fname
77
115
  obj = Hayabusa::Http_session::Post_multipart::File_upload.new(
78
- "fname" => match_fname[1],
79
- "headers" => @headers,
80
- "data" => @data
116
+ :fname => @fname,
117
+ :headers => @headers,
118
+ :data => @data
81
119
  )
82
- @return[name] = obj
83
- @data = nil
84
- @headers = {}
85
- @mode = nil
120
+ @return[@name] = obj
86
121
  else
87
- @return[name] = @data
88
- @data = nil
89
- @headers = {}
90
- @mode = nil
122
+ @return[@name] = @data
91
123
  end
124
+
125
+ self.reset_data
126
+ end
127
+
128
+ def reset_data
129
+ @data = nil
130
+ @name = nil
131
+ @fname = nil
132
+ @headers = {}
133
+ @mode = nil
134
+ @clength = 0
92
135
  end
93
136
  end
94
137
 
@@ -100,27 +143,27 @@ class Hayabusa::Http_session::Post_multipart::File_upload
100
143
 
101
144
  #Returns the size of the upload.
102
145
  def size
103
- return @args["data"].length
146
+ return @args[:data].length
104
147
  end
105
148
 
106
149
  #Returns the size of the fileupload.
107
150
  def length
108
- return @args["data"].length
151
+ return @args[:data].length
109
152
  end
110
153
 
111
154
  #Returns the filename given for the fileupload.
112
155
  def filename
113
- return @args["fname"]
156
+ return @args[:fname]
114
157
  end
115
158
 
116
159
  #Returns the headers given for the fileupload. Type and more should be here.
117
160
  def headers
118
- return @args["headers"]
161
+ return @args[:headers]
119
162
  end
120
163
 
121
164
  #Returns the content of the file-upload as a string.
122
165
  def to_s
123
- return @args["data"]
166
+ return File.read(@args[:data].path)
124
167
  end
125
168
 
126
169
  #Saves the content of the fileupload to a given path.
@@ -1,4 +1,4 @@
1
- require "knj/web"
1
+ require "tempfile"
2
2
 
3
3
  #If we are running on JRuby or Rubinius this will seriously speed things up if we are behind a proxy.
4
4
  if RUBY_PLATFORM == "java" or RUBY_ENGINE == "rbx"
@@ -156,31 +156,40 @@ class Hayabusa::Http_session::Request
156
156
  sleep 2
157
157
  end
158
158
  rescue => e
159
- if @hb
160
- @hb.handle_error(e)
161
- else
162
- STDOUT.print Knj::Errors.error_str(e) if !STDOUT.closed?
163
- end
159
+ @hb.handle_error(e)
164
160
  end
165
161
  end
166
162
 
163
+ if @headers["content-type"] and match = @headers["content-type"].first.match(/^multipart\/form-data; boundary=(.+)\Z/)
164
+ #This is useually used for file-uploads and is expected to be slower because of disk-access. Use temporary file to spare memory.
165
+ mode = :multipart
166
+ post_data = Tempfile.open("hayabusa_multipart_raw")
167
+ else
168
+ #This is a normal post useually only with strings and such. That can be handeled by memory.
169
+ mode = :normal
170
+ post_data = ""
171
+ end
172
+
167
173
  while @read < @clength
168
174
  read_size = @clength - @read
169
- read_size = 4096 if read_size > 4096
175
+ read_size = 8192 if read_size > 8192
170
176
 
171
177
  raise Errno::ECONNRESET, "Socket closed." if socket.closed?
172
178
  read = socket.read(read_size)
173
179
  raise Errno::ECONNRESET, "Socket returned non-string: '#{read.class.name}'." if !read.is_a?(String)
180
+
174
181
  post_data << read
175
- @read += read.length
182
+ @read += read.bytesize
176
183
  end
177
184
 
178
- if @headers["content-type"] and match = @headers["content-type"].first.match(/^multipart\/form-data; boundary=(.+)\Z/)
185
+ if mode == :multipart
186
+ post_data.rewind
179
187
  post_treated = Hayabusa::Http_session::Post_multipart.new(
180
- "io" => StringIO.new("#{post_data}"),
181
- "boundary" => match[1],
182
- "crlf" => @crlf
188
+ :io => post_data,
189
+ :boundary => match[1],
190
+ :crlf => @crlf
183
191
  ).return
192
+ post_data.close(true)
184
193
 
185
194
  self.convert_post(@post, post_treated, {:urldecode => false})
186
195
  else
@@ -1,15 +1,21 @@
1
1
  #coding: utf-8
2
2
 
3
3
  def _(str)
4
- hb = _hb
5
- session = Thread.current[:hayabusa][:session].sess_data if Thread.current[:hayabusa] and Thread.current[:hayabusa][:session]
4
+ thread = Thread.current
5
+ thread_hayabusa = thread[:hayabusa]
6
+ raise "Could not register Hayabusa-data." if !thread_hayabusa
7
+ hb = thread_hayabusa[:hb]
8
+ raise "Could not register Hayabusa." if !hb
9
+ raise "'gettext' not enabled for Hayabusa." if !hb.gettext
10
+
11
+ session = thread_hayabusa[:session].sess_data if thread_hayabusa[:session]
6
12
  locale = nil
7
13
 
8
- if Thread.current[:locale].to_s.length > 0
9
- locale = Thread.current[:locale]
10
- elsif session and session[:locale].to_s.strip.length > 0
14
+ if !thread[:locale].to_s.empty?
15
+ locale = thread[:locale]
16
+ elsif session and !session[:locale].to_s.strip.empty?
11
17
  locale = session[:locale]
12
- elsif hb and hb.config[:locale_default].to_s.strip.length > 0
18
+ elsif hb and !hb.config[:locale_default].to_s.strip.empty?
13
19
  session[:locale] = hb.config[:locale_default] if session
14
20
  locale = hb.config[:locale_default]
15
21
  elsif !session and !hb
@@ -2,23 +2,17 @@
2
2
  #Knj.p _hb.config
3
3
  #exit
4
4
 
5
- _hb.log_puts("1")
6
5
  print "1"
7
6
 
8
- _hb.log_puts("2")
9
7
  cont = "2"
10
8
  t1 = _hb.thread(:id => 4) do
11
9
  sleep 0.5
12
- _hb.log_puts("4")
13
10
  cont << "4"
14
- _hb.log_puts("4 done")
15
11
  end
16
12
 
17
13
  t2 = _hb.thread(:id => 3) do
18
14
  sleep 0.3
19
- _hb.log_puts("3")
20
15
  cont << "3"
21
- _hb.log_puts("3 done")
22
16
  end
23
17
 
24
18
  sleep 0.1
@@ -29,7 +23,6 @@
29
23
  t1.join
30
24
  t2.join_error
31
25
 
32
- _hb.log_puts("5")
33
26
  cont << "5"
34
27
 
35
28
  print cont
@@ -0,0 +1,9 @@
1
+ <%
2
+ pdata = {}
3
+ _post.each do |key, val|
4
+ pdata[key] = val.to_s
5
+ end
6
+
7
+ require "json"
8
+ print JSON.generate(pdata)
9
+ %>
@@ -3,11 +3,22 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "Hayabusa" do
4
4
  it "should be able to start a sample-server" do
5
5
  require "rubygems"
6
- require "hayabusa"
7
- require "/home/kaspernj/Dev/Ruby/Gems/knjrbfw/lib/knjrbfw.rb"
8
6
  require "sqlite3" if RUBY_ENGINE != "jruby"
9
7
  require "json"
10
- Knj.gem_require(:Http2, "http2")
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
11
22
 
12
23
  db_path = "#{Knj::Os.tmpdir}/hayabusa_rspec.sqlite3"
13
24
  File.unlink(db_path) if File.exists?(db_path)
@@ -52,7 +63,7 @@ describe "Hayabusa" do
52
63
 
53
64
  raise "Expected thread-pool-priority to be '-3' but it wasnt: '#{$appserver.threadpool.args[:priority]}'." if $appserver.threadpool.args[:priority] != -3
54
65
 
55
- http = Http2.new(:host => "localhost", :port => 80)
66
+ http = Http2.new(:host => "localhost", :port => 80, :encoding_gzip => false, :debug => false)
56
67
 
57
68
  $testmodes = [{
58
69
  :name => :standalone,
@@ -76,6 +87,36 @@ describe "Hayabusa" do
76
87
  # end
77
88
  #end
78
89
 
90
+ it "should be able to upload files" do
91
+ $testmodes.each do |tdata|
92
+ fpath = "#{File.realpath(File.dirname(__FILE__))}/../pages/spec_thread_joins.rhtml"
93
+
94
+ res = tdata[:http].post_multipart(:url => "#{tdata[:path_pre]}spec_vars_post_fileupload.rhtml", :post => {
95
+ "testfile" => {
96
+ :filename => "spec_thread_joins.rhtml",
97
+ :fpath => fpath
98
+ }
99
+ })
100
+
101
+ data = JSON.parse(res.body)
102
+
103
+ if data["testfile"] != File.read(fpath)
104
+ File.open("/tmp/hayabusa_spec_testfile1", "w") do |fp|
105
+ fp.puts("Class: #{data["testfile"].class.name}")
106
+ fp.write(data["testfile"])
107
+ end
108
+
109
+ File.open("/tmp/hayabusa_spec_testfile2", "w") do |fp|
110
+ fp.write(File.read(fpath))
111
+ end
112
+
113
+ raise "Expected uploaded data for mode '#{tdata[:name]}' to be the same but it wasnt:\n\"#{data["testfile"]}\"\n\n\"#{File.read(fpath)}\""
114
+ end
115
+ end
116
+ end
117
+
118
+ if false
119
+
79
120
  it "should be able to handle a GET-request." do
80
121
  $testmodes.each do |tdata|
81
122
  res = tdata[:http].get("#{tdata[:path_pre]}spec.rhtml")
@@ -302,6 +343,8 @@ describe "Hayabusa" do
302
343
  end
303
344
  end
304
345
 
346
+ end
347
+
305
348
  it "should be able to stop." do
306
349
  $appserver.stop
307
350
  end
metadata CHANGED
@@ -1,141 +1,153 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hayabusa
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.16
4
5
  prerelease:
5
- version: 0.0.15
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Kasper Johansen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-09-30 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-10-05 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
16
  name: knjrbfw
17
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &16343080 !ruby/object:Gem::Requirement
18
18
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *16343080
26
+ - !ruby/object:Gem::Dependency
27
27
  name: erubis
28
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &16341740 !ruby/object:Gem::Requirement
29
29
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *16341740
37
+ - !ruby/object:Gem::Dependency
38
38
  name: mail
39
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &16340380 !ruby/object:Gem::Requirement
40
40
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *16340380
48
+ - !ruby/object:Gem::Dependency
49
49
  name: datet
50
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &16321500 !ruby/object:Gem::Requirement
51
51
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
58
+ version_requirements: *16321500
59
+ - !ruby/object:Gem::Dependency
60
60
  name: http2
61
- requirement: &id005 !ruby/object:Gem::Requirement
61
+ requirement: &16320740 !ruby/object:Gem::Requirement
62
62
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *16320740
70
+ - !ruby/object:Gem::Dependency
71
71
  name: tpool
72
- requirement: &id006 !ruby/object:Gem::Requirement
72
+ requirement: &16320020 !ruby/object:Gem::Requirement
73
73
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
80
+ version_requirements: *16320020
81
+ - !ruby/object:Gem::Dependency
82
+ name: fcgi
83
+ requirement: &16319300 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: *16319300
92
+ - !ruby/object:Gem::Dependency
82
93
  name: json
83
- requirement: &id007 !ruby/object:Gem::Requirement
94
+ requirement: &16318580 !ruby/object:Gem::Requirement
84
95
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
102
+ version_requirements: *16318580
103
+ - !ruby/object:Gem::Dependency
93
104
  name: rspec
94
- requirement: &id008 !ruby/object:Gem::Requirement
105
+ requirement: &16317540 !ruby/object:Gem::Requirement
95
106
  none: false
96
- requirements:
97
- - - ~>
98
- - !ruby/object:Gem::Version
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
99
110
  version: 2.3.0
100
111
  type: :development
101
112
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
113
+ version_requirements: *16317540
114
+ - !ruby/object:Gem::Dependency
104
115
  name: bundler
105
- requirement: &id009 !ruby/object:Gem::Requirement
116
+ requirement: &16316440 !ruby/object:Gem::Requirement
106
117
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
110
121
  version: 1.0.0
111
122
  type: :development
112
123
  prerelease: false
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
124
+ version_requirements: *16316440
125
+ - !ruby/object:Gem::Dependency
115
126
  name: jeweler
116
- requirement: &id010 !ruby/object:Gem::Requirement
127
+ requirement: &16315300 !ruby/object:Gem::Requirement
117
128
  none: false
118
- requirements:
129
+ requirements:
119
130
  - - ~>
120
- - !ruby/object:Gem::Version
131
+ - !ruby/object:Gem::Version
121
132
  version: 1.6.3
122
133
  type: :development
123
134
  prerelease: false
124
- version_requirements: *id010
125
- - !ruby/object:Gem::Dependency
135
+ version_requirements: *16315300
136
+ - !ruby/object:Gem::Dependency
126
137
  name: sqlite3
127
- requirement: &id011 !ruby/object:Gem::Requirement
138
+ requirement: &16312540 !ruby/object:Gem::Requirement
128
139
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: "0"
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
133
144
  type: :development
134
145
  prerelease: false
135
- version_requirements: *id011
136
- description: A threadded web/app-server that focuses on threadding, shared ressources, speed and more.
146
+ version_requirements: *16312540
147
+ description: A threadded web/app-server that focuses on threadding, shared ressources,
148
+ speed and more.
137
149
  email: k@spernj.org
138
- executables:
150
+ executables:
139
151
  - check_running.rb
140
152
  - hayabusa_benchmark.rb
141
153
  - hayabusa_cgi.rb
@@ -145,11 +157,10 @@ executables:
145
157
  - hayabusa_spec_restart.rb
146
158
  - knjappserver_start.rb
147
159
  extensions: []
148
-
149
- extra_rdoc_files:
160
+ extra_rdoc_files:
150
161
  - LICENSE.txt
151
162
  - README.rdoc
152
- files:
163
+ files:
153
164
  - .document
154
165
  - .rspec
155
166
  - Gemfile
@@ -227,40 +238,39 @@ files:
227
238
  - pages/spec_vars_get.rhtml
228
239
  - pages/spec_vars_header.rhtml
229
240
  - pages/spec_vars_post.rhtml
241
+ - pages/spec_vars_post_fileupload.rhtml
230
242
  - pages/tests.rhtml
231
243
  - pages/threadded_content_test.rhtml
232
244
  - spec/fcgi_multiple_processes_spec.rb
233
245
  - spec/hayabusa_spec.rb
234
246
  - spec/spec_helper.rb
247
+ has_rdoc: true
235
248
  homepage: http://github.com/kaspernj/hayabusa
236
- licenses:
249
+ licenses:
237
250
  - MIT
238
251
  post_install_message:
239
252
  rdoc_options: []
240
-
241
- require_paths:
253
+ require_paths:
242
254
  - lib
243
- required_ruby_version: !ruby/object:Gem::Requirement
255
+ required_ruby_version: !ruby/object:Gem::Requirement
244
256
  none: false
245
- requirements:
246
- - - ">="
247
- - !ruby/object:Gem::Version
248
- hash: 1606654535065321094
249
- segments:
257
+ requirements:
258
+ - - ! '>='
259
+ - !ruby/object:Gem::Version
260
+ version: '0'
261
+ segments:
250
262
  - 0
251
- version: "0"
252
- required_rubygems_version: !ruby/object:Gem::Requirement
263
+ hash: -3140330148185755228
264
+ required_rubygems_version: !ruby/object:Gem::Requirement
253
265
  none: false
254
- requirements:
255
- - - ">="
256
- - !ruby/object:Gem::Version
257
- version: "0"
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
258
270
  requirements: []
259
-
260
271
  rubyforge_project:
261
- rubygems_version: 1.8.24
272
+ rubygems_version: 1.6.2
262
273
  signing_key:
263
274
  specification_version: 3
264
275
  summary: A threadded web/app-server that supports stand-alone, CGI and FCGI-modes.
265
276
  test_files: []
266
-