serverside 0.1.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGELOG +97 -0
  2. data/COPYING +18 -0
  3. data/README +51 -0
  4. data/Rakefile +92 -0
  5. data/bin/serverside +74 -0
  6. data/doc/rdoc/classes/Daemon.html +253 -0
  7. data/doc/rdoc/classes/Daemon/Base.html +146 -0
  8. data/doc/rdoc/classes/Daemon/Cluster.html +308 -0
  9. data/doc/rdoc/classes/Daemon/Cluster/PidFile.html +228 -0
  10. data/doc/rdoc/classes/Daemon/PidFile.html +178 -0
  11. data/doc/rdoc/classes/ServerSide.html +160 -0
  12. data/doc/rdoc/classes/ServerSide/Application.html +147 -0
  13. data/doc/rdoc/classes/ServerSide/Application/Base.html +196 -0
  14. data/doc/rdoc/classes/ServerSide/Application/Static.html +154 -0
  15. data/doc/rdoc/classes/ServerSide/Connection.html +128 -0
  16. data/doc/rdoc/classes/ServerSide/Connection/Base.html +343 -0
  17. data/doc/rdoc/classes/ServerSide/Connection/Const.html +229 -0
  18. data/doc/rdoc/classes/ServerSide/Connection/Static.html +172 -0
  19. data/doc/rdoc/classes/ServerSide/Server.html +162 -0
  20. data/doc/rdoc/classes/ServerSide/StaticFiles.html +208 -0
  21. data/doc/rdoc/classes/ServerSide/StaticFiles/Const.html +179 -0
  22. data/doc/rdoc/classes/String.html +210 -0
  23. data/doc/rdoc/classes/Symbol.html +156 -0
  24. data/doc/rdoc/created.rid +1 -0
  25. data/doc/rdoc/files/CHANGELOG.html +260 -0
  26. data/doc/rdoc/files/COPYING.html +129 -0
  27. data/doc/rdoc/files/README.html +171 -0
  28. data/doc/rdoc/files/lib/serverside/application_rb.html +109 -0
  29. data/doc/rdoc/files/lib/serverside/cluster_rb.html +101 -0
  30. data/doc/rdoc/files/lib/serverside/connection_rb.html +101 -0
  31. data/doc/rdoc/files/lib/serverside/core_ext_rb.html +107 -0
  32. data/doc/rdoc/files/lib/serverside/daemon_rb.html +108 -0
  33. data/doc/rdoc/files/lib/serverside/server_rb.html +108 -0
  34. data/doc/rdoc/files/lib/serverside/static_rb.html +101 -0
  35. data/doc/rdoc/files/lib/serverside_rb.html +131 -0
  36. data/doc/rdoc/fr_class_index.html +44 -0
  37. data/doc/rdoc/fr_file_index.html +37 -0
  38. data/doc/rdoc/fr_method_index.html +60 -0
  39. data/doc/rdoc/index.html +24 -0
  40. data/doc/rdoc/rdoc-style.css +208 -0
  41. data/lib/serverside.rb +13 -0
  42. data/lib/serverside/application.rb +40 -0
  43. data/lib/serverside/cluster.rb +72 -0
  44. data/lib/serverside/connection.rb +115 -0
  45. data/lib/serverside/core_ext.rb +27 -0
  46. data/lib/serverside/daemon.rb +67 -0
  47. data/lib/serverside/server.rb +18 -0
  48. data/lib/serverside/static.rb +96 -0
  49. data/test/functional/primitive_static_server_test.rb +37 -0
  50. data/test/functional/static_profile.rb +17 -0
  51. data/test/functional/static_rfuzz.rb +67 -0
  52. data/test/functional/static_server_test.rb +25 -0
  53. data/test/test_helper.rb +2 -0
  54. data/test/unit/application_test.rb +16 -0
  55. data/test/unit/cluster_test.rb +129 -0
  56. data/test/unit/connection_test.rb +193 -0
  57. data/test/unit/core_ext_test.rb +32 -0
  58. data/test/unit/daemon_test.rb +75 -0
  59. data/test/unit/server_test.rb +26 -0
  60. data/test/unit/static_test.rb +143 -0
  61. metadata +140 -0
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'net/http'
3
+
4
+ class ServerTest < Test::Unit::TestCase
5
+ class DummyConnection
6
+ attr_reader :conn
7
+ @@count = 0
8
+ def initialize(conn)
9
+ @@count += 1
10
+ @conn = conn
11
+ @conn << "HTTP/1.1 200\r\nContent-Length: 9\r\n\r\nHi there!"
12
+ @conn.close
13
+ end
14
+ end
15
+
16
+ def test_server_creation
17
+ t = Thread.new {ServerSide::Server.new('0.0.0.0', 17543, DummyConnection)}
18
+ sleep 0.1
19
+
20
+ h = Net::HTTP.new('localhost', 17543)
21
+ resp, data = h.get('/', nil)
22
+ assert_equal 200, resp.code.to_i
23
+ assert_equal 'Hi there!', data
24
+ t.exit
25
+ end
26
+ end
@@ -0,0 +1,143 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'stringio'
3
+ require 'fileutils'
4
+
5
+ class ConnectionTest < Test::Unit::TestCase
6
+ class Dummy < ServerSide::Connection::Static
7
+ def self.static_files
8
+ @@static_files
9
+ end
10
+
11
+ def self.mime_types
12
+ @@mime_types
13
+ end
14
+
15
+ attr_accessor :conn, :path, :headers
16
+
17
+ def initialize
18
+ @headers = {}
19
+ end
20
+ end
21
+
22
+ def test_cache
23
+ assert_kind_of Hash, Dummy.static_files
24
+ Dummy.static_files.clear
25
+ c = Dummy.new
26
+ c.conn = StringIO.new
27
+ assert_nil Dummy.static_files[__FILE__]
28
+ c.serve_file(__FILE__)
29
+ cache = Dummy.static_files[__FILE__]
30
+ assert_not_nil cache
31
+ stat = File.stat(__FILE__)
32
+ etag = (ServerSide::StaticFiles::Const::ETagFormat %
33
+ [stat.mtime.to_i, stat.size, stat.ino])
34
+ assert_equal etag, cache[0]
35
+ assert_equal IO.read(__FILE__), cache[1]
36
+ end
37
+
38
+ def test_mime_types
39
+ assert_kind_of Hash, Dummy.mime_types
40
+ assert_equal 'text/plain', Dummy.mime_types['.rb']
41
+ assert_equal 'text/plain', Dummy.mime_types['.invalid']
42
+ assert_equal 'text/html', Dummy.mime_types['.html']
43
+ assert_equal 'text/css', Dummy.mime_types['.css']
44
+ assert_equal 'text/javascript', Dummy.mime_types['.js']
45
+ assert_equal 'image/gif', Dummy.mime_types['.gif']
46
+ assert_equal 'image/jpeg', Dummy.mime_types['.jpg']
47
+ assert_equal 'image/jpeg', Dummy.mime_types['.jpeg']
48
+ assert_equal 'image/png', Dummy.mime_types['.png']
49
+ end
50
+
51
+ def test_serve_file_normal
52
+ c = Dummy.new
53
+ c.conn = StringIO.new
54
+ c.serve_file(__FILE__)
55
+ c.conn.rewind
56
+ resp = c.conn.read
57
+
58
+ assert_equal '200', /HTTP\/1.1\s(.*)\r\n/.match(resp)[1]
59
+ fc = IO.read(__FILE__)
60
+ stat = File.stat(__FILE__)
61
+ etag = (ServerSide::StaticFiles::Const::ETagFormat %
62
+ [stat.mtime.to_i, stat.size, stat.ino])
63
+ assert_equal etag, /ETag:\s(.*)\r\n/.match(resp)[1]
64
+ assert_equal ServerSide::StaticFiles::Const::MaxAge,
65
+ /Cache-Control:\s(.*)\r\n/.match(resp)[1]
66
+ assert_equal stat.size.to_s,
67
+ /Content-Length:\s(.*)\r\n/.match(resp)[1]
68
+ end
69
+
70
+ def test_serve_file_etags
71
+ c = Dummy.new
72
+ c.conn = StringIO.new
73
+ Dummy.static_files.clear
74
+ c.serve_file(__FILE__)
75
+ c.conn.rewind
76
+ resp = c.conn.read
77
+
78
+ # normal response
79
+ assert_equal '200', /HTTP\/1.1\s(.*)\r\n/.match(resp)[1]
80
+ fc = IO.read(__FILE__)
81
+ stat = File.stat(__FILE__)
82
+ etag = (ServerSide::StaticFiles::Const::ETagFormat %
83
+ [stat.mtime.to_i, stat.size, stat.ino])
84
+ assert_equal etag, /ETag:\s(.*)\r\n/.match(resp)[1]
85
+ assert_equal ServerSide::StaticFiles::Const::MaxAge,
86
+ /Cache-Control:\s(.*)\r\n/.match(resp)[1]
87
+ assert_equal stat.size.to_s,
88
+ /Content-Length:\s(.*)\r\n/.match(resp)[1]
89
+
90
+ c.conn = StringIO.new
91
+ c.headers[ServerSide::StaticFiles::Const::IfNoneMatch] = etag
92
+ c.serve_file(__FILE__)
93
+ c.conn.rewind
94
+ resp = c.conn.read
95
+
96
+ # not modified response
97
+ assert_equal '304 Not Modified', /HTTP\/1.1\s(.*)\r\n/.match(resp)[1]
98
+ fc = IO.read(__FILE__)
99
+ stat = File.stat(__FILE__)
100
+ etag = (ServerSide::StaticFiles::Const::ETagFormat %
101
+ [stat.mtime.to_i, stat.size, stat.ino])
102
+ assert_equal etag, /ETag:\s(.*)\r\n/.match(resp)[1]
103
+ assert_equal ServerSide::StaticFiles::Const::MaxAge,
104
+ /Cache-Control:\s(.*)\r\n/.match(resp)[1]
105
+ assert_equal '0', /Content-Length:\s(.*)\r\n/.match(resp)[1]
106
+
107
+ FileUtils.touch(__FILE__)
108
+ c.conn = StringIO.new
109
+ c.headers[ServerSide::StaticFiles::Const::IfNoneMatch] = etag
110
+ c.serve_file(__FILE__)
111
+ c.conn.rewind
112
+ resp = c.conn.read
113
+
114
+ # modified response
115
+ assert_equal '200', /HTTP\/1.1\s(.*)\r\n/.match(resp)[1]
116
+ fc = IO.read(__FILE__)
117
+ stat = File.stat(__FILE__)
118
+ etag = (ServerSide::StaticFiles::Const::ETagFormat %
119
+ [stat.mtime.to_i, stat.size, stat.ino])
120
+ assert_equal etag, /ETag:\s(.*)\r\n/.match(resp)[1]
121
+ assert_equal ServerSide::StaticFiles::Const::MaxAge,
122
+ /Cache-Control:\s(.*)\r\n/.match(resp)[1]
123
+ assert_equal stat.size.to_s,
124
+ /Content-Length:\s(.*)\r\n/.match(resp)[1]
125
+ end
126
+
127
+ def test_serve_dir
128
+ dir = File.dirname(__FILE__)
129
+
130
+ c = Dummy.new
131
+ c.conn = StringIO.new
132
+ Dummy.static_files.clear
133
+ c.path = dir
134
+ c.serve_dir(dir)
135
+ c.conn.rewind
136
+ resp = c.conn.read
137
+
138
+ Dir.entries(dir).each do |fn|
139
+ next if fn == '.'
140
+ assert_not_nil resp =~ /<a href="#{dir/fn}">(#{fn})<\/a>/
141
+ end
142
+ end
143
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: serverside
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.59
7
+ date: 2006-08-22 00:00:00 +03:00
8
+ summary: Performance-oriented web framework.
9
+ require_paths:
10
+ - lib
11
+ email: ciconia@gmail.com
12
+ homepage: http://code.google.com/p/serverside/
13
+ rubyforge_project:
14
+ description: Performance-oriented web framework.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.2
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Sharon Rosner
30
+ files:
31
+ - COPYING
32
+ - README
33
+ - Rakefile
34
+ - bin/serverside
35
+ - doc/rdoc
36
+ - doc/rdoc/created.rid
37
+ - doc/rdoc/rdoc-style.css
38
+ - doc/rdoc/files
39
+ - doc/rdoc/classes
40
+ - doc/rdoc/fr_file_index.html
41
+ - doc/rdoc/fr_class_index.html
42
+ - doc/rdoc/fr_method_index.html
43
+ - doc/rdoc/index.html
44
+ - doc/rdoc/files/README.html
45
+ - doc/rdoc/files/CHANGELOG.html
46
+ - doc/rdoc/files/COPYING.html
47
+ - doc/rdoc/files/lib
48
+ - doc/rdoc/files/lib/serverside_rb.html
49
+ - doc/rdoc/files/lib/serverside
50
+ - doc/rdoc/files/lib/serverside/server_rb.html
51
+ - doc/rdoc/files/lib/serverside/daemon_rb.html
52
+ - doc/rdoc/files/lib/serverside/application_rb.html
53
+ - doc/rdoc/files/lib/serverside/core_ext_rb.html
54
+ - doc/rdoc/files/lib/serverside/connection_rb.html
55
+ - doc/rdoc/files/lib/serverside/cluster_rb.html
56
+ - doc/rdoc/files/lib/serverside/static_rb.html
57
+ - doc/rdoc/classes/Symbol.html
58
+ - doc/rdoc/classes/String.html
59
+ - doc/rdoc/classes/Daemon.html
60
+ - doc/rdoc/classes/Daemon
61
+ - doc/rdoc/classes/ServerSide.html
62
+ - doc/rdoc/classes/ServerSide
63
+ - doc/rdoc/classes/Daemon/PidFile.html
64
+ - doc/rdoc/classes/Daemon/Base.html
65
+ - doc/rdoc/classes/Daemon/Cluster.html
66
+ - doc/rdoc/classes/Daemon/Cluster
67
+ - doc/rdoc/classes/Daemon/Cluster/PidFile.html
68
+ - doc/rdoc/classes/ServerSide/StaticFiles.html
69
+ - doc/rdoc/classes/ServerSide/StaticFiles
70
+ - doc/rdoc/classes/ServerSide/Application.html
71
+ - doc/rdoc/classes/ServerSide/Application
72
+ - doc/rdoc/classes/ServerSide/Connection.html
73
+ - doc/rdoc/classes/ServerSide/Connection
74
+ - doc/rdoc/classes/ServerSide/Server.html
75
+ - doc/rdoc/classes/ServerSide/StaticFiles/Const.html
76
+ - doc/rdoc/classes/ServerSide/Application/Base.html
77
+ - doc/rdoc/classes/ServerSide/Application/Static.html
78
+ - doc/rdoc/classes/ServerSide/Connection/Const.html
79
+ - doc/rdoc/classes/ServerSide/Connection/Base.html
80
+ - doc/rdoc/classes/ServerSide/Connection/Static.html
81
+ - test/unit
82
+ - test/test_helper.rb
83
+ - test/functional
84
+ - test/unit/daemon_test.rb
85
+ - test/unit/application_test.rb
86
+ - test/unit/server_test.rb
87
+ - test/unit/core_ext_test.rb
88
+ - test/unit/connection_test.rb
89
+ - test/unit/cluster_test.rb
90
+ - test/unit/static_test.rb
91
+ - test/functional/primitive_static_server_test.rb
92
+ - test/functional/static_server_test.rb
93
+ - test/functional/static_profile.rb
94
+ - test/functional/static_rfuzz.rb
95
+ - lib/serverside.rb
96
+ - lib/serverside
97
+ - lib/serverside/server.rb
98
+ - lib/serverside/daemon.rb
99
+ - lib/serverside/application.rb
100
+ - lib/serverside/core_ext.rb
101
+ - lib/serverside/connection.rb
102
+ - lib/serverside/cluster.rb
103
+ - lib/serverside/static.rb
104
+ - CHANGELOG
105
+ test_files: []
106
+
107
+ rdoc_options:
108
+ - --quiet
109
+ - --title
110
+ - ServerSide Documentation
111
+ - --opname
112
+ - index.html
113
+ - --line-numbers
114
+ - --main
115
+ - README
116
+ - --inline-source
117
+ - --exclude
118
+ - ^(examples|extras)\/
119
+ - --exclude
120
+ - lib/serverside.rb
121
+ extra_rdoc_files:
122
+ - README
123
+ - CHANGELOG
124
+ - COPYING
125
+ executables:
126
+ - serverside
127
+ extensions: []
128
+
129
+ requirements: []
130
+
131
+ dependencies:
132
+ - !ruby/object:Gem::Dependency
133
+ name: metaid
134
+ version_requirement:
135
+ version_requirements: !ruby/object:Gem::Version::Requirement
136
+ requirements:
137
+ - - ">"
138
+ - !ruby/object:Gem::Version
139
+ version: 0.0.0
140
+ version: