mongrel_esi 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +53 -0
- data/LICENSE +471 -0
- data/README +186 -0
- data/Rakefile +141 -0
- data/bin/mongrel_esi +271 -0
- data/ext/esi/common.rl +41 -0
- data/ext/esi/esi_parser.c +387 -0
- data/ext/esi/extconf.rb +6 -0
- data/ext/esi/machine.rb +499 -0
- data/ext/esi/parser.c +1675 -0
- data/ext/esi/parser.h +113 -0
- data/ext/esi/parser.rb +49 -0
- data/ext/esi/parser.rl +398 -0
- data/ext/esi/ruby_esi.rl +135 -0
- data/ext/esi/run-test.rb +3 -0
- data/ext/esi/test/common.rl +41 -0
- data/ext/esi/test/parser.c +1676 -0
- data/ext/esi/test/parser.h +113 -0
- data/ext/esi/test/parser.rl +398 -0
- data/ext/esi/test/test.c +373 -0
- data/ext/esi/test1.rb +56 -0
- data/ext/esi/test2.rb +45 -0
- data/lib/esi/cache.rb +207 -0
- data/lib/esi/config.rb +154 -0
- data/lib/esi/dispatcher.rb +27 -0
- data/lib/esi/handler.rb +236 -0
- data/lib/esi/invalidator.rb +40 -0
- data/lib/esi/logger.rb +46 -0
- data/lib/esi/router.rb +84 -0
- data/lib/esi/tag/attempt.rb +6 -0
- data/lib/esi/tag/base.rb +85 -0
- data/lib/esi/tag/except.rb +24 -0
- data/lib/esi/tag/include.rb +190 -0
- data/lib/esi/tag/invalidate.rb +54 -0
- data/lib/esi/tag/try.rb +40 -0
- data/lib/multi_dirhandler.rb +70 -0
- data/setup.rb +1585 -0
- data/test/integration/basic_test.rb +39 -0
- data/test/integration/cache_test.rb +37 -0
- data/test/integration/docs/content/500.html +16 -0
- data/test/integration/docs/content/500_with_failover.html +16 -0
- data/test/integration/docs/content/500_with_failover_to_alt.html +8 -0
- data/test/integration/docs/content/ajax_test_page.html +15 -0
- data/test/integration/docs/content/cookie_variable.html +3 -0
- data/test/integration/docs/content/foo.html +15 -0
- data/test/integration/docs/content/include_in_include.html +15 -0
- data/test/integration/docs/content/malformed_transforms.html +16 -0
- data/test/integration/docs/content/malformed_transforms.html-correct +11 -0
- data/test/integration/docs/content/static-failover.html +20 -0
- data/test/integration/docs/content/test2.html +1 -0
- data/test/integration/docs/content/test3.html +17 -0
- data/test/integration/docs/esi_invalidate.html +6 -0
- data/test/integration/docs/esi_mixed_content.html +15 -0
- data/test/integration/docs/esi_test_content.html +27 -0
- data/test/integration/docs/index.html +688 -0
- data/test/integration/docs/test1.html +1 -0
- data/test/integration/docs/test3.html +9 -0
- data/test/integration/docs/test_failover.html +1 -0
- data/test/integration/handler_test.rb +270 -0
- data/test/integration/help.rb +234 -0
- data/test/net/get_test.rb +197 -0
- data/test/net/net_helper.rb +16 -0
- data/test/net/server_test.rb +249 -0
- data/test/unit/base_tag_test.rb +44 -0
- data/test/unit/esi-sample.html +56 -0
- data/test/unit/help.rb +77 -0
- data/test/unit/include_request_test.rb +69 -0
- data/test/unit/include_tag_test.rb +14 -0
- data/test/unit/parser_test.rb +478 -0
- data/test/unit/router_test.rb +34 -0
- data/test/unit/sample.html +21 -0
- data/tools/rakehelp.rb +119 -0
- metadata +182 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'help.rb')
|
2
|
+
require 'esi/router'
|
3
|
+
|
4
|
+
class RouterTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def router
|
7
|
+
ESI::Router.new(
|
8
|
+
[{:host => '127.0.0.1', :port => '8504', :match_url => '(^\/(images\/sorry|articles|privacy-policy|terms-of-service|about|site-map|contact-us|help|store).*|^\/(\?.*)?$)'},
|
9
|
+
{:host => '127.0.0.1', :port => '8509', :match_url => '^\/(test).*|^$'},
|
10
|
+
{:host => '127.0.0.1', :port => '8502', :match_url => 'default'}] )
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def test_default_route
|
15
|
+
url = router.url_for( "/foo" )
|
16
|
+
assert_equal( 'http://127.0.0.1:8502/foo', url )
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_slash_landing_with_query
|
20
|
+
url = router.url_for( "/?hello" )
|
21
|
+
assert_equal( 'http://127.0.0.1:8504/?hello', url )
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_test_page
|
25
|
+
url = router.url_for( "/test" )
|
26
|
+
assert_equal( 'http://127.0.0.1:8509/test', url )
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_pass_url_with_scheme
|
30
|
+
assert_equal "http://example.com", router.url_for("http://example.com")
|
31
|
+
assert_equal "http://www.example.com", router.url_for("http://www.example.com")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<title>Something else</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<h1>hello</h1>
|
8
|
+
<div class="body">
|
9
|
+
<esi:include src="/remote/1"/>
|
10
|
+
<div>some content</div>
|
11
|
+
<esi:try>
|
12
|
+
<esi:attempt>
|
13
|
+
<esi:include src="/remote/2"/>
|
14
|
+
</esi:attempt>
|
15
|
+
<esi:except>
|
16
|
+
<p>it failed</p>
|
17
|
+
</esi:except>
|
18
|
+
</esi:try>
|
19
|
+
</div>
|
20
|
+
</body>
|
21
|
+
</html>
|
data/tools/rakehelp.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# This final came directly from mongrel 1.0.1 source
|
2
|
+
# with a few modifications to support some of my network tests
|
3
|
+
# Also, i have figured out yet if this should remain so much a clone of the mongrel tree
|
4
|
+
# or become a plugin, need to review more closely how that works
|
5
|
+
|
6
|
+
def make(makedir)
|
7
|
+
Dir.chdir(makedir) do
|
8
|
+
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def extconf(dir)
|
13
|
+
Dir.chdir(dir) do ruby "extconf.rb" end
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup_tests
|
17
|
+
Rake::TestTask.new do |t|
|
18
|
+
t.test_files = FileList["test/unit/*_test.rb"] + FileList["test/integration/*_test.rb"]
|
19
|
+
t.verbose = true
|
20
|
+
end
|
21
|
+
|
22
|
+
Rake::TestTask.new("test:net") do |t|
|
23
|
+
t.libs << "test/net"
|
24
|
+
t.test_files = FileList['test/net/*_test.rb']
|
25
|
+
t.verbose = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def setup_clean otherfiles
|
31
|
+
files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
|
32
|
+
CLEAN.include(files)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def setup_rdoc files
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
39
|
+
rdoc.options << '--line-numbers'
|
40
|
+
rdoc.rdoc_files.add(files)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def setup_extension(dir, extension)
|
46
|
+
ext = "ext/#{dir}"
|
47
|
+
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
48
|
+
ext_files = FileList[
|
49
|
+
"#{ext}/*.c",
|
50
|
+
"#{ext}/*.h",
|
51
|
+
"#{ext}/extconf.rb",
|
52
|
+
"#{ext}/Makefile",
|
53
|
+
"lib"
|
54
|
+
]
|
55
|
+
|
56
|
+
task "lib" do
|
57
|
+
directory "lib"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Builds just the #{extension} extension"
|
61
|
+
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
62
|
+
|
63
|
+
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
64
|
+
extconf "#{ext}"
|
65
|
+
end
|
66
|
+
|
67
|
+
file ext_so => ext_files do
|
68
|
+
make "#{ext}"
|
69
|
+
cp ext_so, "lib"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def base_gem_spec(pkg_name, pkg_version)
|
75
|
+
rm_rf "test/coverage"
|
76
|
+
pkg_version = pkg_version
|
77
|
+
pkg_name = pkg_name
|
78
|
+
pkg_file_name = "#{pkg_name}-#{pkg_version}"
|
79
|
+
Gem::Specification.new do |s|
|
80
|
+
s.name = pkg_name
|
81
|
+
s.version = pkg_version
|
82
|
+
s.platform = Gem::Platform::RUBY
|
83
|
+
s.has_rdoc = true
|
84
|
+
s.extra_rdoc_files = [ "README" ]
|
85
|
+
|
86
|
+
s.files = %w(COPYING LICENSE README Rakefile) +
|
87
|
+
Dir.glob("{bin,doc/rdoc,test}/**/*") +
|
88
|
+
Dir.glob("ext/**/*.{h,c,rb,rl}") +
|
89
|
+
Dir.glob("{examples,tools,lib}/**/*.rb")
|
90
|
+
|
91
|
+
s.require_path = "lib"
|
92
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
93
|
+
s.bindir = "bin"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def setup_gem(pkg_name, pkg_version)
|
98
|
+
spec = base_gem_spec(pkg_name, pkg_version)
|
99
|
+
yield spec if block_given?
|
100
|
+
|
101
|
+
Rake::GemPackageTask.new(spec) do |p|
|
102
|
+
p.gem_spec = spec
|
103
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Conditional require rcov/rcovtask if present
|
108
|
+
begin
|
109
|
+
require 'rcov/rcovtask'
|
110
|
+
|
111
|
+
Rcov::RcovTask.new do |t|
|
112
|
+
t.test_files = FileList['test/unit/*_test.rb'] + FileList["test/integration/*_test.rb"]
|
113
|
+
t.rcov_opts << "-x /usr"
|
114
|
+
t.output_dir = "test/coverage"
|
115
|
+
t.verbose = true
|
116
|
+
end
|
117
|
+
rescue Object => e
|
118
|
+
puts e.message
|
119
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongrel_esi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Todd A. Fisher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-05 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: daemons
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.3
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: fastthread
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.6.2
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: hpricot
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0.6"
|
41
|
+
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: memcache-client
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.5.0
|
50
|
+
version:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: cgi_multipart_eof_fix
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.0.0
|
59
|
+
version:
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: mongrel
|
62
|
+
version_requirement:
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.0.1
|
68
|
+
version:
|
69
|
+
description: A small fast ESI HTTP Server built on top of Mongrel
|
70
|
+
email:
|
71
|
+
executables:
|
72
|
+
- mongrel_esi
|
73
|
+
extensions:
|
74
|
+
- ext/esi/extconf.rb
|
75
|
+
extra_rdoc_files:
|
76
|
+
- README
|
77
|
+
files:
|
78
|
+
- COPYING
|
79
|
+
- LICENSE
|
80
|
+
- README
|
81
|
+
- Rakefile
|
82
|
+
- bin/mongrel_esi
|
83
|
+
- test/integration
|
84
|
+
- test/integration/basic_test.rb
|
85
|
+
- test/integration/cache_test.rb
|
86
|
+
- test/integration/docs
|
87
|
+
- test/integration/docs/content
|
88
|
+
- test/integration/docs/content/500.html
|
89
|
+
- test/integration/docs/content/500_with_failover.html
|
90
|
+
- test/integration/docs/content/500_with_failover_to_alt.html
|
91
|
+
- test/integration/docs/content/ajax_test_page.html
|
92
|
+
- test/integration/docs/content/cookie_variable.html
|
93
|
+
- test/integration/docs/content/foo.html
|
94
|
+
- test/integration/docs/content/include_in_include.html
|
95
|
+
- test/integration/docs/content/malformed_transforms.html
|
96
|
+
- test/integration/docs/content/malformed_transforms.html-correct
|
97
|
+
- test/integration/docs/content/static-failover.html
|
98
|
+
- test/integration/docs/content/test2.html
|
99
|
+
- test/integration/docs/content/test3.html
|
100
|
+
- test/integration/docs/esi_invalidate.html
|
101
|
+
- test/integration/docs/esi_mixed_content.html
|
102
|
+
- test/integration/docs/esi_test_content.html
|
103
|
+
- test/integration/docs/index.html
|
104
|
+
- test/integration/docs/test1.html
|
105
|
+
- test/integration/docs/test3.html
|
106
|
+
- test/integration/docs/test_failover.html
|
107
|
+
- test/integration/handler_test.rb
|
108
|
+
- test/integration/help.rb
|
109
|
+
- test/net
|
110
|
+
- test/net/get_test.rb
|
111
|
+
- test/net/net_helper.rb
|
112
|
+
- test/net/server_test.rb
|
113
|
+
- test/unit
|
114
|
+
- test/unit/base_tag_test.rb
|
115
|
+
- test/unit/esi-sample.html
|
116
|
+
- test/unit/help.rb
|
117
|
+
- test/unit/include_request_test.rb
|
118
|
+
- test/unit/include_tag_test.rb
|
119
|
+
- test/unit/parser_test.rb
|
120
|
+
- test/unit/router_test.rb
|
121
|
+
- test/unit/sample.html
|
122
|
+
- ext/esi/parser.h
|
123
|
+
- ext/esi/test/parser.h
|
124
|
+
- ext/esi/esi_parser.c
|
125
|
+
- ext/esi/parser.c
|
126
|
+
- ext/esi/test/parser.c
|
127
|
+
- ext/esi/test/test.c
|
128
|
+
- ext/esi/extconf.rb
|
129
|
+
- ext/esi/machine.rb
|
130
|
+
- ext/esi/parser.rb
|
131
|
+
- ext/esi/run-test.rb
|
132
|
+
- ext/esi/test1.rb
|
133
|
+
- ext/esi/test2.rb
|
134
|
+
- ext/esi/common.rl
|
135
|
+
- ext/esi/parser.rl
|
136
|
+
- ext/esi/ruby_esi.rl
|
137
|
+
- ext/esi/test/common.rl
|
138
|
+
- ext/esi/test/parser.rl
|
139
|
+
- tools/rakehelp.rb
|
140
|
+
- lib/esi/cache.rb
|
141
|
+
- lib/esi/config.rb
|
142
|
+
- lib/esi/dispatcher.rb
|
143
|
+
- lib/esi/handler.rb
|
144
|
+
- lib/esi/invalidator.rb
|
145
|
+
- lib/esi/logger.rb
|
146
|
+
- lib/esi/router.rb
|
147
|
+
- lib/esi/tag/attempt.rb
|
148
|
+
- lib/esi/tag/base.rb
|
149
|
+
- lib/esi/tag/except.rb
|
150
|
+
- lib/esi/tag/include.rb
|
151
|
+
- lib/esi/tag/invalidate.rb
|
152
|
+
- lib/esi/tag/try.rb
|
153
|
+
- lib/multi_dirhandler.rb
|
154
|
+
- setup.rb
|
155
|
+
has_rdoc: true
|
156
|
+
homepage:
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.8.5
|
167
|
+
version:
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: "0"
|
173
|
+
version:
|
174
|
+
requirements: []
|
175
|
+
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 1.0.1
|
178
|
+
signing_key:
|
179
|
+
specification_version: 2
|
180
|
+
summary: A small fast ESI HTTP Server built on top of Mongrel
|
181
|
+
test_files: []
|
182
|
+
|