hayabusa 0.0.24 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +363 -0
  3. data/Rakefile +0 -14
  4. data/bin/hayabusa_fcgi.fcgi +1 -0
  5. data/bin/hayabusa_fcgi_server.rb +0 -1
  6. data/lib/hayabusa.rb +124 -118
  7. data/lib/hayabusa_cgi_tools.rb +4 -2
  8. data/lib/hayabusa_client_session.rb +3 -1
  9. data/lib/hayabusa_database.rb +84 -84
  10. data/lib/hayabusa_datarow.rb +873 -0
  11. data/lib/hayabusa_ext/mailing.rb +8 -7
  12. data/lib/hayabusa_ext/web.rb +5 -0
  13. data/lib/hayabusa_fcgi.rb +13 -4
  14. data/lib/hayabusa_http_session.rb +2 -0
  15. data/lib/hayabusa_http_session_contentgroup.rb +7 -1
  16. data/lib/hayabusa_http_session_request.rb +7 -1
  17. data/lib/hayabusa_http_session_response.rb +30 -29
  18. data/lib/hayabusa_objects.rb +1455 -0
  19. data/lib/hayabusa_revision.rb +347 -0
  20. data/lib/kernel_ext/magic_methods.rb +4 -0
  21. data/lib/models/log.rb +27 -27
  22. data/lib/models/log_access.rb +20 -20
  23. data/lib/models/log_data.rb +6 -6
  24. data/lib/models/log_data_link.rb +2 -2
  25. data/lib/models/log_data_value.rb +5 -5
  26. data/lib/models/log_link.rb +12 -12
  27. data/lib/models/session.rb +6 -6
  28. metadata +125 -126
  29. data/.document +0 -5
  30. data/.rspec +0 -1
  31. data/Gemfile +0 -24
  32. data/Gemfile.lock +0 -70
  33. data/README.rdoc +0 -315
  34. data/VERSION +0 -1
  35. data/bin/hayabusa_fcgi.fcgi +0 -42
  36. data/conf/apache2_cgi_rhtml_conf.conf +0 -10
  37. data/conf/apache2_fcgi_rhtml_conf.conf +0 -22
  38. data/conf/apache2_hayabusa_conf.conf +0 -15
  39. data/hayabusa.gemspec +0 -167
  40. data/pages/benchmark.rhtml +0 -0
  41. data/pages/benchmark_print.rhtml +0 -14
  42. data/pages/benchmark_simple.rhtml +0 -3
  43. data/pages/benchmark_threadded_content.rhtml +0 -21
  44. data/pages/config_cgi.rb +0 -22
  45. data/pages/config_fcgi.rb +0 -22
  46. data/pages/debug_database_connections.rhtml +0 -46
  47. data/pages/debug_http_sessions.rhtml +0 -40
  48. data/pages/debug_memory_usage.rhtml +0 -39
  49. data/pages/error_notfound.rhtml +0 -12
  50. data/pages/image.png +0 -0
  51. data/pages/logs_latest.rhtml +0 -57
  52. data/pages/logs_show.rhtml +0 -32
  53. data/pages/spec.rhtml +0 -41
  54. data/pages/spec_exit.rhtml +0 -5
  55. data/pages/spec_multiple_threads.rhtml +0 -18
  56. data/pages/spec_sleeper.rhtml +0 -4
  57. data/pages/spec_test_multiple_clients.rhtml +0 -3
  58. data/pages/spec_thread_joins.rhtml +0 -29
  59. data/pages/spec_threadded_content.rhtml +0 -40
  60. data/pages/spec_vars_get.rhtml +0 -4
  61. data/pages/spec_vars_header.rhtml +0 -3
  62. data/pages/spec_vars_post.rhtml +0 -4
  63. data/pages/spec_vars_post_fileupload.rhtml +0 -19
  64. data/pages/testpic.jpeg +0 -0
  65. data/pages/tests.rhtml +0 -14
  66. data/pages/threadded_content_test.rhtml +0 -23
  67. data/spec/fcgi_multiple_processes_spec.rb +0 -104
  68. data/spec/hayabusa_spec.rb +0 -423
  69. data/spec/spec_helper.rb +0 -12
  70. data/spec/test_upload.xlsx +0 -0
@@ -1,46 +0,0 @@
1
- <h1>Database connections</h1>
2
-
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>Key</th>
7
- <th>Free</th>
8
- </tr>
9
- </thead>
10
- <tbody>
11
- <%
12
- thread_handler = _hb.db_handler.conns
13
- if !thread_handler.is_a?(Knj::Threadhandler)
14
- print "A threadhandler has not been spawned for this instance."
15
- exit
16
- end
17
-
18
- objects = thread_handler.objects.clone
19
-
20
- objects.each_index do |key|
21
- val = objects[key]
22
-
23
- %>
24
- <tr>
25
- <td>
26
- <%=key%>
27
- </td>
28
- <td>
29
- <%=Knj::Strings.yn_str(val[:free])%>
30
- </td>
31
- </tr>
32
- <%
33
- end
34
-
35
- if objects.empty?
36
- %>
37
- <tr>
38
- <td colspan="2">
39
- Thread handler was spawned but no active connections was spawned?
40
- </td>
41
- </tr>
42
- <%
43
- end
44
- %>
45
- </tbody>
46
- </table>
@@ -1,40 +0,0 @@
1
- <h1>HTTP sessions</h1>
2
-
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>Key</th>
7
- <th>Working</th>
8
- </tr>
9
- </thead>
10
- <tbody>
11
- <%
12
- sessions = _hb.httpserv.http_sessions.clone
13
-
14
- sessions.each_index do |key|
15
- http_session = sessions[key]
16
-
17
- %>
18
- <tr>
19
- <td>
20
- <%=key%>
21
- </td>
22
- <td>
23
- <%=Knj::Strings.yn_str(http_session.working)%>
24
- </td>
25
- </tr>
26
- <%
27
- end
28
-
29
- if sessions.empty?
30
- %>
31
- <tr>
32
- <td colspan="2">
33
- No HTTP-sessions has been spawned.
34
- </td>
35
- </tr>
36
- <%
37
- end
38
- %>
39
- </tbody>
40
- </table>
@@ -1,39 +0,0 @@
1
- <%
2
- if _get["choice"] == "dogarbagecollect"
3
- _hb.clean
4
- GC.start
5
-
6
- #Clean all Knj::Objects used in the application.
7
- ObjectSpace.each_object(Knj::Objects) do |objects|
8
- objects.clean_all
9
- end
10
-
11
- Knj::Web.redirect("?show=debug_memory_usage")
12
- end
13
- %>
14
-
15
- <h1>Memory usage</h1>
16
-
17
- <div style="padding-bottom: 15px;">
18
- <input type="button" value="Garbage collect" onclick="location.href='?show=debug_memory_usage&amp;choice=dogarbagecollect';" />
19
- </div>
20
-
21
- <h1>Hayabusa sessions</h1>
22
- <table style="width: 600px;">
23
- <tbody>
24
- <tr>
25
- <td>Active sessions</td>
26
- <td><%=_hb.num(_hb.sessions.length, 0)%></td>
27
- </tr>
28
- <tr>
29
- <td>Total sessions</td>
30
- <td><%=_hb.num(_hb.ob.list(:Session, "count" => true), 0)%>
31
- </tr>
32
- </tbody>
33
- </table>
34
-
35
- <br />
36
-
37
- <%
38
- Knj::Memory_analyzer.new.write
39
- %>
@@ -1,12 +0,0 @@
1
- <%
2
- _httpsession.resp.status = 404
3
- %>
4
- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
5
- <html><head>
6
- <title>404 Not Found</title>
7
- </head><body>
8
- <h1>Not Found</h1>
9
- <p>The requested URL <%=_meta["REQUEST_URI"]%> was not found on this server.</p>
10
- <hr>
11
- <address>Hayabusa at <%=_meta["HTTP_HOST"]%></address>
12
- </body></html>
data/pages/image.png DELETED
Binary file
@@ -1,57 +0,0 @@
1
- <%
2
- access = _hb.events.call(:check_page_access, {:page => :logs_latest})
3
- if !access
4
- print _("You do not have access to this page.")
5
- exit
6
- end
7
-
8
- ob = _hb.events.call(:ob)
9
- %>
10
-
11
- <table class="list">
12
- <thead>
13
- <tr>
14
- <th><%=_("ID")%></th>
15
- <th><%=_("Log")%></th>
16
- <%if ob%>
17
- <th><%=_("Object")%></th>
18
- <%end%>
19
- </tr>
20
- </thead>
21
- <tbody>
22
- <%
23
- logs = _hb.ob.list(:Log, {
24
- "orderby" => [["date_saved", "desc"]],
25
- "limit" => 200
26
- })
27
-
28
- logs.each do |log|
29
- %>
30
- <tr>
31
- <td>
32
- <a href="logs_show.rhtml?log_id=<%=log.id%>"><%=log.id%></a>
33
- </td>
34
- <td>
35
- <%=log.first_line%>
36
- </td>
37
- <%if ob%>
38
- <td>
39
- <%=log.objects_html(ob)%>
40
- </td>
41
- <%end%>
42
- </tr>
43
- <%
44
- end
45
-
46
- if logs.empty?
47
- %>
48
- <tr>
49
- <td class="error">
50
- <%=_("No logs were found.")%>
51
- </td>
52
- </tr>
53
- <%
54
- end
55
- %>
56
- </tbody>
57
- </table>
@@ -1,32 +0,0 @@
1
- <%
2
- access = _hb.events.call(:check_page_access, {:page => :logs_show})
3
- if !access
4
- print _("You do not have access to this page.")
5
- exit
6
- end
7
-
8
- ob = _hb.events.call(:ob)
9
- log = _hb.ob.get(:Log, _get["log_id"])
10
- %>
11
-
12
- <table class="form">
13
- <%
14
- print Knj::Web.inputs([{
15
- :title => _("Date"),
16
- :type => :info,
17
- :value => Datet.in(log[:date_saved]).out
18
- }])
19
-
20
- if ob
21
- print Knj::Web.input(
22
- :title => _("Objects"),
23
- :type => :info,
24
- :value => log.objects_html(ob)
25
- )
26
- end
27
- %>
28
- </table>
29
-
30
- <div style="padding-top: 10px;">
31
- <%=log.text%>
32
- </div>
data/pages/spec.rhtml DELETED
@@ -1,41 +0,0 @@
1
- <%
2
- require "json"
3
-
4
- if _get["choice"] == "test_cookie"
5
- _hb.cookie(
6
- "name" => "TestCookie",
7
- "value" => "TestValue",
8
- "expires" => Time.new + 3600 #add an hour
9
- )
10
- _hb.cookie(
11
- "name" => "TestCookie2",
12
- "value" => "TestValue2",
13
- "expires" => Time.new + 7200 #add an hour
14
- )
15
- _hb.cookie(
16
- "name" => "TestCookie3",
17
- "value" => "TestValue 3 ",
18
- "expires" => Time.new + 1200
19
- )
20
- exit
21
- elsif _get["choice"] == "dopostconvert"
22
- print JSON.generate(_post)
23
- exit
24
- end
25
-
26
- if _get["choice"] == "get_cookies"
27
- print JSON.generate(_cookie)
28
- exit
29
- end
30
-
31
- _hb.header("TestHeader", "NormalHeader")
32
- _hb.header_raw("TestRaw: RawHeader")
33
-
34
- if _meta["REQUEST_METHOD"] == "POST"
35
- print _post["postdata"]
36
- elsif _get["choice"] == "check_get_parse"
37
- print _get["value"]
38
- else
39
- print "Test"
40
- end
41
- %>
@@ -1,5 +0,0 @@
1
- <%
2
- _httpsession.resp.status = 304
3
- puts "ExitOutput"
4
- exit
5
- %>
@@ -1,18 +0,0 @@
1
- <%
2
- require "json"
3
-
4
- if !_session.key?(:request_count)
5
- _session[:request_count] = 1
6
- else
7
- _session[:request_count] = _session[:request_count].to_i + 1
8
- end
9
-
10
- print JSON.generate(
11
- :pid => Process.pid,
12
- :session_id => _session_obj.id,
13
- :session_hash_id => _session.__id__,
14
- :request_count => _session[:request_count],
15
- :cookie => _cookie,
16
- :meta => _meta
17
- )
18
- %>
@@ -1,4 +0,0 @@
1
- <%
2
- sleep 0.7
3
- print Process.pid
4
- %>
@@ -1,3 +0,0 @@
1
- <%
2
-
3
- %>
@@ -1,29 +0,0 @@
1
- <%
2
- #Knj.p _hb.config
3
- #exit
4
-
5
- print "1"
6
-
7
- cont = "2"
8
- t1 = _hb.thread(:id => 4) do
9
- sleep 0.5
10
- cont << "4"
11
- end
12
-
13
- t2 = _hb.thread(:id => 3) do
14
- sleep 0.3
15
- cont << "3"
16
- end
17
-
18
- sleep 0.1
19
-
20
- raise "Expected thread 1 to be running but it wasnt." if !t1.running?
21
- raise "Expected thread 2 to be running but it wasnt." if !t2.running?
22
-
23
- t1.join
24
- t2.join_error
25
-
26
- cont << "5"
27
-
28
- print cont
29
- %>
@@ -1,40 +0,0 @@
1
- <%
2
- _hb.threadded_content do
3
- sleep 0.2
4
- print "1"
5
- end
6
-
7
- print "2"
8
-
9
- _hb.threadded_content do
10
- sleep 0.1
11
-
12
- _hb.threadded_content do
13
- sleep 0.1
14
- print "3"
15
-
16
- sleep 0.1
17
-
18
- _hb.threadded_content do
19
- print "4"
20
- sleep 0.1
21
- print "5"
22
- end
23
-
24
- _hb.threadded_content do
25
- print "6"
26
- print "7"
27
- end
28
- end
29
-
30
- print "8"
31
- end
32
-
33
- #This will first finish after the printing has starter - it should still be printed correct.
34
- _hb.threadded_content do
35
- sleep 1
36
- print "9"
37
- end
38
-
39
- print "10"
40
- %>
@@ -1,4 +0,0 @@
1
- <%
2
- require "json"
3
- print JSON.generate(_get)
4
- %>
@@ -1,3 +0,0 @@
1
- <%
2
- _hb.header("TestHeader", "TestValue")
3
- %>
@@ -1,4 +0,0 @@
1
- <%
2
- require "json"
3
- print JSON.generate(_post)
4
- %>
@@ -1,19 +0,0 @@
1
- <%
2
- pdata = {}
3
- _post.each do |key, val|
4
- data = {
5
- "class" => val.class.name
6
- }
7
-
8
- if val.is_a?(Hayabusa::Http_session::Post_multipart::File_upload)
9
- data["val"] = val.to_s
10
- else
11
- data["val"] = val
12
- end
13
-
14
- pdata[key] = data
15
- end
16
-
17
- require "json"
18
- print Marshal.dump(pdata)
19
- %>
data/pages/testpic.jpeg DELETED
Binary file
data/pages/tests.rhtml DELETED
@@ -1,14 +0,0 @@
1
- <%
2
- print "Test 1: #{_testvar1}<br />\n"
3
- print "Test 2: #{_testvar2}<br />\n"
4
- %>
5
-
6
- <table style="width: 1000px;">
7
- <%
8
- print Knj::Web.inputs([{
9
- :title => "FCKEditor test",
10
- :type => :fckeditor,
11
- :name => :textest
12
- }])
13
- %>
14
- </table>
@@ -1,23 +0,0 @@
1
- <%
2
- print "1"
3
-
4
- _hb.threadded_content do
5
- print "2"
6
- sleep 0.5
7
- end
8
-
9
- print "3"
10
-
11
- _hb.threadded_content do
12
- print "4"
13
-
14
- _hb.threadded_content do
15
- print "5"
16
- sleep 0.2
17
- end
18
-
19
- sleep 0.3
20
- end
21
-
22
- print "6"
23
- %>
@@ -1,104 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Hayabusa" do
4
- it "should handle sessions correctly under stressed conditions" do
5
- require "knjrbfw"
6
- Knj.gem_require(:Http2)
7
- require "json"
8
-
9
- ts = []
10
- errs = []
11
-
12
- 1.upto(10) do |t_i|
13
- ts << Thread.new do
14
- if t_i == 1
15
- debug = true
16
- else
17
- debug = false
18
- end
19
-
20
- begin
21
- session_id = nil
22
- hayabusa_session_id = nil
23
- session_hash_obj_id = nil
24
-
25
- Http2.new(:host => "localhost", :user_agent => "Client#{t_i}", :debug => false) do |http|
26
- 1.upto(25) do |request_i|
27
- res = http.get(:url => "hayabusa_fcgi_test/spec_multiple_threads.rhtml")
28
-
29
- begin
30
- data_json = JSON.parse(res.body)
31
- rescue => e
32
- raise "Could not parse result as JSON: '#{res.body}'."
33
- end
34
-
35
- data = {}
36
- data_json.each do |key, val|
37
- data["#{key.to_s}"] = "#{val.to_s}"
38
- end
39
-
40
- if request_i == 1
41
- hayabusa_session_id = data["cookie"]["HayabusaSession"]
42
- session_hash_obj_id = data["session_hash_id"]
43
- session_id = data["session_id"]
44
- end
45
-
46
- #puts "request-i: #{request_i}, data-request-count: #{data["request_count"]}, hash-id: #{data["session_hash_id"]}" if debug
47
-
48
- #Check 'HayabusaSession'-cookie.
49
- raise "No 'HayabusaSession'-cookie?" if !data["cookie"]["HayabusaSession"]
50
- raise "Expected 'HayabusaSession'-cookie to be '#{hayabusa_session_id}' but it wasnt: '#{data["cookie"]["HayabusaSession"]}' (#{data["cookie"]})." if hayabusa_session_id != data["cookie"]["HayabusaSession"]
51
-
52
- #Check session-hash-object-ID.
53
- raise "No 'session_hash_id' from request: '#{data}'." if data["session_hash_id"].to_s.strip.empty?
54
- raise "Expected session-hash-object-ID to be '#{session_hash_obj_id}' but it wasnt: '#{data["session_hash_id"]}'." if session_hash_obj_id != data["session_hash_id"] or !session_hash_obj_id
55
-
56
-
57
- #Check session-object-ID.
58
- raise "Expected session-ID to be '#{session_id}' but it wasnt: '#{data["session_id"]}' for request '#{request_i}'." if session_id != data["session_id"]
59
- raise "Expected request-count for session to be the same as on the client: '#{request_i}' but it wasnt: '#{data["request_count"]}'." if data["request_count"].to_i != request_i
60
- end
61
- end
62
- rescue => e
63
- errs << e
64
- end
65
- end
66
- end
67
-
68
- ts.each do |t|
69
- t.join
70
- end
71
-
72
- errs.each do |e|
73
- raise e
74
- end
75
- end
76
-
77
- it "two simultanious request should be handeled by the same process - one should proxy the request" do
78
- Knj.gem_require(:Http2, "http2")
79
- require "json"
80
-
81
- Http2.new(:host => "localhost") do |http1|
82
- Http2.new(:host => "localhost") do |http2|
83
- res1 = nil
84
- res2 = nil
85
-
86
- t1 = Thread.new do
87
- res1 = http1.get(:url => "hayabusa_fcgi_test/spec_sleeper.rhtml")
88
- end
89
-
90
- t2 = Thread.new do
91
- res2 = http2.get(:url => "hayabusa_fcgi_test/spec_sleeper.rhtml")
92
- end
93
-
94
- t1.join
95
- t2.join
96
-
97
- pid1 = res1.body.to_i
98
- pid2 = res2.body.to_i
99
-
100
- raise "Expected PIDs to be the same: '#{res1.body}', '#{res2.body}'." if pid1 != pid2 or pid1 == 0 or pid2 == 0
101
- end
102
- end
103
- end
104
- end