mongrel_esi 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +15 -8
- data/bin/mongrel_esi +0 -0
- data/ext/esi/common.rl +32 -27
- data/ext/esi/esi_parser.c +11 -4
- data/ext/esi/parser.c +4536 -901
- data/ext/esi/parser.h +7 -0
- data/ext/esi/parser.rl +171 -53
- data/ext/esi/run-test.rb +0 -0
- data/ext/esi/test/common.rl +32 -27
- data/ext/esi/test/parser.c +322 -1342
- data/ext/esi/test/parser.h +7 -0
- data/ext/esi/test/parser.rl +171 -53
- data/ext/esi/test/test.c +13 -4
- data/ext/esi/test1.rb +35 -3
- data/lib/esi/cache.rb +2 -1
- data/lib/esi/config.rb +37 -0
- data/lib/esi/dispatcher.rb +3 -5
- data/lib/esi/invalidator.rb +3 -0
- data/lib/esi/logger.rb +0 -7
- data/lib/esi/parser.rb +70 -0
- data/lib/esi/processor.rb +88 -0
- data/lib/esi/proxy.rb +104 -0
- data/lib/esi/response.rb +106 -0
- data/lib/esi/router.rb +3 -0
- data/lib/esi/tag/attempt.rb +3 -0
- data/lib/esi/tag/base.rb +3 -1
- data/lib/esi/tag/except.rb +2 -0
- data/lib/esi/tag/include.rb +131 -132
- data/lib/esi/tag/invalidate.rb +2 -0
- data/lib/esi/tag/try.rb +3 -0
- data/test/integration/basic_test.rb +0 -1
- data/test/integration/docs/esi_max_age_varies.html +10 -0
- data/test/integration/handler_test.rb +31 -5
- data/test/integration/help.rb +13 -1
- data/test/load_test.rb +133 -0
- data/test/unit/include_request_test.rb +1 -1
- data/test/unit/parser_test.rb +41 -5
- data/test/unit/response_test.rb +184 -0
- metadata +50 -224
- data/doc/rdoc/classes/ESI/Cache.html +0 -178
- data/doc/rdoc/classes/ESI/Cache.src/M000060.html +0 -17
- data/doc/rdoc/classes/ESI/Cache.src/M000061.html +0 -20
- data/doc/rdoc/classes/ESI/Config/CacheConfig.html +0 -212
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000055.html +0 -19
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000056.html +0 -19
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000057.html +0 -18
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000058.html +0 -18
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000059.html +0 -18
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.html +0 -187
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/M000052.html +0 -19
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/M000053.html +0 -21
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/M000054.html +0 -21
- data/doc/rdoc/classes/ESI/Config.html +0 -291
- data/doc/rdoc/classes/ESI/Config.src/M000043.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000044.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000045.html +0 -35
- data/doc/rdoc/classes/ESI/Config.src/M000046.html +0 -38
- data/doc/rdoc/classes/ESI/Config.src/M000047.html +0 -23
- data/doc/rdoc/classes/ESI/Config.src/M000048.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000049.html +0 -20
- data/doc/rdoc/classes/ESI/Config.src/M000050.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000051.html +0 -24
- data/doc/rdoc/classes/ESI/Dispatcher.html +0 -172
- data/doc/rdoc/classes/ESI/Dispatcher.src/M000062.html +0 -23
- data/doc/rdoc/classes/ESI/Dispatcher.src/M000063.html +0 -20
- data/doc/rdoc/classes/ESI/Fragment.html +0 -218
- data/doc/rdoc/classes/ESI/Fragment.src/M000076.html +0 -21
- data/doc/rdoc/classes/ESI/Fragment.src/M000077.html +0 -18
- data/doc/rdoc/classes/ESI/Fragment.src/M000078.html +0 -18
- data/doc/rdoc/classes/ESI/Handler.html +0 -236
- data/doc/rdoc/classes/ESI/Handler.src/M000079.html +0 -19
- data/doc/rdoc/classes/ESI/Handler.src/M000080.html +0 -161
- data/doc/rdoc/classes/ESI/Handler.src/M000081.html +0 -24
- data/doc/rdoc/classes/ESI/Handler.src/M000082.html +0 -18
- data/doc/rdoc/classes/ESI/Handler.src/M000083.html +0 -26
- data/doc/rdoc/classes/ESI/Handler.src/M000084.html +0 -30
- data/doc/rdoc/classes/ESI/Invalidator.html +0 -131
- data/doc/rdoc/classes/ESI/Invalidator.src/M000004.html +0 -41
- data/doc/rdoc/classes/ESI/Log.html +0 -251
- data/doc/rdoc/classes/ESI/Log.src/M000005.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000006.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000007.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000008.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000009.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000010.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000011.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000012.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000013.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.html +0 -314
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000034.html +0 -24
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000035.html +0 -22
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000036.html +0 -19
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000037.html +0 -23
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000038.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000039.html +0 -19
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000040.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000041.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000042.html +0 -17
- data/doc/rdoc/classes/ESI/Router.html +0 -229
- data/doc/rdoc/classes/ESI/Router.src/M000073.html +0 -36
- data/doc/rdoc/classes/ESI/Router.src/M000074.html +0 -25
- data/doc/rdoc/classes/ESI/Router.src/M000075.html +0 -24
- data/doc/rdoc/classes/ESI/RubyCache.html +0 -278
- data/doc/rdoc/classes/ESI/RubyCache.src/M000064.html +0 -20
- data/doc/rdoc/classes/ESI/RubyCache.src/M000065.html +0 -22
- data/doc/rdoc/classes/ESI/RubyCache.src/M000066.html +0 -21
- data/doc/rdoc/classes/ESI/RubyCache.src/M000067.html +0 -22
- data/doc/rdoc/classes/ESI/RubyCache.src/M000068.html +0 -18
- data/doc/rdoc/classes/ESI/RubyCache.src/M000069.html +0 -22
- data/doc/rdoc/classes/ESI/RubyCache.src/M000070.html +0 -18
- data/doc/rdoc/classes/ESI/RubyCache.src/M000071.html +0 -18
- data/doc/rdoc/classes/ESI/RubyCache.src/M000072.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Attempt.html +0 -113
- data/doc/rdoc/classes/ESI/Tag/Base.html +0 -267
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000028.html +0 -26
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000029.html +0 -23
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000030.html +0 -22
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000031.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000032.html +0 -22
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000033.html +0 -23
- data/doc/rdoc/classes/ESI/Tag/Except.html +0 -184
- data/doc/rdoc/classes/ESI/Tag/Except.src/M000020.html +0 -21
- data/doc/rdoc/classes/ESI/Tag/Except.src/M000021.html +0 -20
- data/doc/rdoc/classes/ESI/Tag/Except.src/M000022.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Include.html +0 -189
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000017.html +0 -20
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000018.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000019.html +0 -125
- data/doc/rdoc/classes/ESI/Tag/IncludeRequest/Error.html +0 -155
- data/doc/rdoc/classes/ESI/Tag/IncludeRequest/Error.src/M000016.html +0 -19
- data/doc/rdoc/classes/ESI/Tag/IncludeRequest.html +0 -199
- data/doc/rdoc/classes/ESI/Tag/IncludeRequest.src/M000014.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/IncludeRequest.src/M000015.html +0 -42
- data/doc/rdoc/classes/ESI/Tag/Invalidate.html +0 -171
- data/doc/rdoc/classes/ESI/Tag/Invalidate.src/M000025.html +0 -19
- data/doc/rdoc/classes/ESI/Tag/Invalidate.src/M000026.html +0 -51
- data/doc/rdoc/classes/ESI/Tag/Invalidate.src/M000027.html +0 -19
- data/doc/rdoc/classes/ESI/Tag/Try.html +0 -161
- data/doc/rdoc/classes/ESI/Tag/Try.src/M000023.html +0 -40
- data/doc/rdoc/classes/ESI/Tag/Try.src/M000024.html +0 -18
- data/doc/rdoc/classes/ESI/Tag.html +0 -137
- data/doc/rdoc/classes/ESI.html +0 -169
- data/doc/rdoc/classes/MultiDirHandler.html +0 -198
- data/doc/rdoc/classes/MultiDirHandler.src/M000001.html +0 -20
- data/doc/rdoc/classes/MultiDirHandler.src/M000002.html +0 -28
- data/doc/rdoc/classes/MultiDirHandler.src/M000003.html +0 -22
- data/doc/rdoc/classes/Net/An/HTTP.html +0 -137
- data/doc/rdoc/classes/Net/An/HTTP.src/M000087.html +0 -17
- data/doc/rdoc/classes/Net/An/IORequest.html +0 -139
- data/doc/rdoc/classes/Net/An/IORequest.src/M000088.html +0 -17
- data/doc/rdoc/classes/Net/An/IOResponse.html +0 -139
- data/doc/rdoc/classes/Net/An/IOResponse.src/M000085.html +0 -17
- data/doc/rdoc/classes/Net/An/IOSocket.html +0 -137
- data/doc/rdoc/classes/Net/An/IOSocket.src/M000086.html +0 -17
- data/doc/rdoc/classes/Net/An.html +0 -114
- data/doc/rdoc/classes/Net.html +0 -119
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/COPYING.html +0 -168
- data/doc/rdoc/files/LICENSE.html +0 -605
- data/doc/rdoc/files/README.html +0 -361
- data/doc/rdoc/files/lib/esi/cache_rb.html +0 -113
- data/doc/rdoc/files/lib/esi/config_rb.html +0 -108
- data/doc/rdoc/files/lib/esi/dispatcher_rb.html +0 -109
- data/doc/rdoc/files/lib/esi/handler_rb.html +0 -121
- data/doc/rdoc/files/lib/esi/invalidator_rb.html +0 -117
- data/doc/rdoc/files/lib/esi/logger_rb.html +0 -108
- data/doc/rdoc/files/lib/esi/router_rb.html +0 -101
- data/doc/rdoc/files/lib/esi/tag/attempt_rb.html +0 -101
- data/doc/rdoc/files/lib/esi/tag/base_rb.html +0 -108
- data/doc/rdoc/files/lib/esi/tag/except_rb.html +0 -101
- data/doc/rdoc/files/lib/esi/tag/include_rb.html +0 -109
- data/doc/rdoc/files/lib/esi/tag/invalidate_rb.html +0 -109
- data/doc/rdoc/files/lib/esi/tag/try_rb.html +0 -108
- data/doc/rdoc/files/lib/multi_dirhandler_rb.html +0 -109
- data/doc/rdoc/files/lib/net/ahttp_rb.html +0 -109
- data/doc/rdoc/fr_class_index.html +0 -55
- data/doc/rdoc/fr_file_index.html +0 -44
- data/doc/rdoc/fr_method_index.html +0 -114
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/ext/esi/parser.rb +0 -49
- data/ext/esi/ruby_esi.rl +0 -135
- data/lib/esi/handler.rb +0 -221
- data/lib/net/ahttp.rb +0 -36
@@ -1,21 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>new (ESI::Fragment)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/esi/cache.rb, line 13</span>
|
14
|
-
13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">uri</span>,<span class="ruby-identifier">max_age</span>,<span class="ruby-identifier">body</span>)
|
15
|
-
14: <span class="ruby-ivar">@uri</span> = <span class="ruby-identifier">uri</span>
|
16
|
-
15: <span class="ruby-identifier">max_age</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\+.*$/</span>,<span class="ruby-value str">''</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max_age</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
|
17
|
-
16: <span class="ruby-ivar">@max_age</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">max_age</span>.<span class="ruby-identifier">to_i</span>
|
18
|
-
17: <span class="ruby-ivar">@body</span> = <span class="ruby-identifier">body</span>
|
19
|
-
18: <span class="ruby-keyword kw">end</span></pre>
|
20
|
-
</body>
|
21
|
-
</html>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>dup (ESI::Fragment)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/esi/cache.rb, line 21</span>
|
14
|
-
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dup</span>
|
15
|
-
22: <span class="ruby-constant">Fragment</span>.<span class="ruby-identifier">new</span>( <span class="ruby-ivar">@uri</span>, <span class="ruby-ivar">@max_age</span>, <span class="ruby-ivar">@body</span> )
|
16
|
-
23: <span class="ruby-keyword kw">end</span></pre>
|
17
|
-
</body>
|
18
|
-
</html>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>valid? (ESI::Fragment)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/esi/cache.rb, line 26</span>
|
14
|
-
26: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid?</span>
|
15
|
-
27: (<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator"><</span> <span class="ruby-ivar">@max_age</span>)
|
16
|
-
28: <span class="ruby-keyword kw">end</span></pre>
|
17
|
-
</body>
|
18
|
-
</html>
|
@@ -1,236 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: ESI::Handler</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">ESI::Handler</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/esi/handler_rb.html">
|
59
|
-
lib/esi/handler.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
<div id="method-list">
|
86
|
-
<h3 class="section-bar">Methods</h3>
|
87
|
-
|
88
|
-
<div class="name-list">
|
89
|
-
<a href="#M000084">copy_headers</a>
|
90
|
-
<a href="#M000083">http_params</a>
|
91
|
-
<a href="#M000079">new</a>
|
92
|
-
<a href="#M000080">process</a>
|
93
|
-
<a href="#M000082">read_status</a>
|
94
|
-
<a href="#M000081">send_chunk</a>
|
95
|
-
</div>
|
96
|
-
</div>
|
97
|
-
|
98
|
-
</div>
|
99
|
-
|
100
|
-
|
101
|
-
<!-- if includes -->
|
102
|
-
<div id="includes">
|
103
|
-
<h3 class="section-bar">Included Modules</h3>
|
104
|
-
|
105
|
-
<div id="includes-list">
|
106
|
-
<span class="include-name"><a href="Log.html">ESI::Log</a></span>
|
107
|
-
</div>
|
108
|
-
</div>
|
109
|
-
|
110
|
-
<div id="section">
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
<div id="attribute-list">
|
117
|
-
<h3 class="section-bar">Attributes</h3>
|
118
|
-
|
119
|
-
<div class="name-list">
|
120
|
-
<table>
|
121
|
-
<tr class="top-aligned-row context-row">
|
122
|
-
<td class="context-item-name">config</td>
|
123
|
-
<td class="context-item-value"> [R] </td>
|
124
|
-
<td class="context-item-desc"></td>
|
125
|
-
</tr>
|
126
|
-
</table>
|
127
|
-
</div>
|
128
|
-
</div>
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
<!-- if method_list -->
|
133
|
-
<div id="methods">
|
134
|
-
<h3 class="section-bar">Public Class methods</h3>
|
135
|
-
|
136
|
-
<div id="method-M000079" class="method-detail">
|
137
|
-
<a name="M000079"></a>
|
138
|
-
|
139
|
-
<div class="method-heading">
|
140
|
-
<a href="Handler.src/M000079.html" target="Code" class="method-signature"
|
141
|
-
onclick="popupCode('Handler.src/M000079.html');return false;">
|
142
|
-
<span class="method-name">new</span><span class="method-args">(dispatcher)</span>
|
143
|
-
</a>
|
144
|
-
</div>
|
145
|
-
|
146
|
-
<div class="method-description">
|
147
|
-
</div>
|
148
|
-
</div>
|
149
|
-
|
150
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
151
|
-
|
152
|
-
<div id="method-M000080" class="method-detail">
|
153
|
-
<a name="M000080"></a>
|
154
|
-
|
155
|
-
<div class="method-heading">
|
156
|
-
<a href="Handler.src/M000080.html" target="Code" class="method-signature"
|
157
|
-
onclick="popupCode('Handler.src/M000080.html');return false;">
|
158
|
-
<span class="method-name">process</span><span class="method-args">(request, response)</span>
|
159
|
-
</a>
|
160
|
-
</div>
|
161
|
-
|
162
|
-
<div class="method-description">
|
163
|
-
</div>
|
164
|
-
</div>
|
165
|
-
|
166
|
-
<h3 class="section-bar">Protected Instance methods</h3>
|
167
|
-
|
168
|
-
<div id="method-M000084" class="method-detail">
|
169
|
-
<a name="M000084"></a>
|
170
|
-
|
171
|
-
<div class="method-heading">
|
172
|
-
<a href="Handler.src/M000084.html" target="Code" class="method-signature"
|
173
|
-
onclick="popupCode('Handler.src/M000084.html');return false;">
|
174
|
-
<span class="method-name">copy_headers</span><span class="method-args">(head,response)</span>
|
175
|
-
</a>
|
176
|
-
</div>
|
177
|
-
|
178
|
-
<div class="method-description">
|
179
|
-
</div>
|
180
|
-
</div>
|
181
|
-
|
182
|
-
<div id="method-M000083" class="method-detail">
|
183
|
-
<a name="M000083"></a>
|
184
|
-
|
185
|
-
<div class="method-heading">
|
186
|
-
<a href="Handler.src/M000083.html" target="Code" class="method-signature"
|
187
|
-
onclick="popupCode('Handler.src/M000083.html');return false;">
|
188
|
-
<span class="method-name">http_params</span><span class="method-args">(params)</span>
|
189
|
-
</a>
|
190
|
-
</div>
|
191
|
-
|
192
|
-
<div class="method-description">
|
193
|
-
</div>
|
194
|
-
</div>
|
195
|
-
|
196
|
-
<div id="method-M000082" class="method-detail">
|
197
|
-
<a name="M000082"></a>
|
198
|
-
|
199
|
-
<div class="method-heading">
|
200
|
-
<a href="Handler.src/M000082.html" target="Code" class="method-signature"
|
201
|
-
onclick="popupCode('Handler.src/M000082.html');return false;">
|
202
|
-
<span class="method-name">read_status</span><span class="method-args">(response)</span>
|
203
|
-
</a>
|
204
|
-
</div>
|
205
|
-
|
206
|
-
<div class="method-description">
|
207
|
-
</div>
|
208
|
-
</div>
|
209
|
-
|
210
|
-
<div id="method-M000081" class="method-detail">
|
211
|
-
<a name="M000081"></a>
|
212
|
-
|
213
|
-
<div class="method-heading">
|
214
|
-
<a href="Handler.src/M000081.html" target="Code" class="method-signature"
|
215
|
-
onclick="popupCode('Handler.src/M000081.html');return false;">
|
216
|
-
<span class="method-name">send_chunk</span><span class="method-args">( response, buffer )</span>
|
217
|
-
</a>
|
218
|
-
</div>
|
219
|
-
|
220
|
-
<div class="method-description">
|
221
|
-
</div>
|
222
|
-
</div>
|
223
|
-
|
224
|
-
|
225
|
-
</div>
|
226
|
-
|
227
|
-
|
228
|
-
</div>
|
229
|
-
|
230
|
-
|
231
|
-
<div id="validator-badges">
|
232
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
233
|
-
</div>
|
234
|
-
|
235
|
-
</body>
|
236
|
-
</html>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>new (ESI::Handler)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/esi/handler.rb, line 23</span>
|
14
|
-
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">dispatcher</span>)
|
15
|
-
24: <span class="ruby-ivar">@config</span> = <span class="ruby-identifier">dispatcher</span>.<span class="ruby-identifier">config</span>
|
16
|
-
25: <span class="ruby-ivar">@router</span> = <span class="ruby-identifier">dispatcher</span>.<span class="ruby-identifier">router</span>
|
17
|
-
26: <span class="ruby-keyword kw">end</span></pre>
|
18
|
-
</body>
|
19
|
-
</html>
|
@@ -1,161 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<title>process (ESI::Handler)</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
-
</head>
|
12
|
-
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/esi/handler.rb, line 28</span>
|
14
|
-
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
15
|
-
29:
|
16
|
-
30: <span class="ruby-identifier">start</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
17
|
-
31: <span class="ruby-identifier">status</span> = <span class="ruby-value">200</span>
|
18
|
-
32: <span class="ruby-identifier">url</span> = <span class="ruby-ivar">@router</span>.<span class="ruby-identifier">url_for</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">"REQUEST_URI"</span>])
|
19
|
-
33:
|
20
|
-
34: <span class="ruby-identifier">params</span> = <span class="ruby-identifier">http_params</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>)
|
21
|
-
35:
|
22
|
-
36: <span class="ruby-identifier">proxy_error</span> = <span class="ruby-keyword kw">nil</span>
|
23
|
-
37:
|
24
|
-
38:
|
25
|
-
39: <span class="ruby-identifier">log_debug</span> <span class="ruby-node">"#{request.params["REQUEST_METHOD"]} => #{url}"</span>
|
26
|
-
40: <span class="ruby-identifier">chunk_count</span> = <span class="ruby-value">0</span>
|
27
|
-
41: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>)
|
28
|
-
42:
|
29
|
-
43: <span class="ruby-identifier">path_with_query</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span> <span class="ruby-value">? </span><span class="ruby-node">"#{uri.path}?#{uri.query}"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>
|
30
|
-
44:
|
31
|
-
45: <span class="ruby-identifier">proxy_request</span> = (<span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">"REQUEST_METHOD"</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"POST"</span>) <span class="ruby-operator">?</span>
|
32
|
-
46: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">path_with_query</span>, <span class="ruby-identifier">params</span> ) <span class="ruby-operator">:</span>
|
33
|
-
47: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Get</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">path_with_query</span>, <span class="ruby-identifier">params</span> )
|
34
|
-
48:
|
35
|
-
49: <span class="ruby-identifier">proxy_connection</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>)
|
36
|
-
50:
|
37
|
-
51: <span class="ruby-comment cmt"># open the conneciton up so we can start to stream the connection</span>
|
38
|
-
52: <span class="ruby-identifier">proxy_connection</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">proxy_request</span>,<span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">read</span>) <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">proxy_response</span><span class="ruby-operator">|</span>
|
39
|
-
53:
|
40
|
-
54: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">read_status</span>( <span class="ruby-identifier">proxy_response</span> )
|
41
|
-
55:
|
42
|
-
56: <span class="ruby-identifier">copy_headers</span>( <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>, <span class="ruby-identifier">proxy_response</span> ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">>=</span> <span class="ruby-value">500</span>
|
43
|
-
57:
|
44
|
-
58: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">>=</span> <span class="ruby-value">500</span> <span class="ruby-keyword kw">or</span> (<span class="ruby-identifier">status</span> <span class="ruby-operator"><</span> <span class="ruby-value">400</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">>=</span> <span class="ruby-value">300</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@config</span>.<span class="ruby-identifier">enable_esi_processor?</span>( <span class="ruby-identifier">proxy_response</span> )
|
45
|
-
59: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">status</span>, <span class="ruby-keyword kw">true</span>) <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
|
46
|
-
60:
|
47
|
-
61: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">>=</span> <span class="ruby-value">500</span>
|
48
|
-
62: <span class="ruby-comment cmt"># TODO: only report this if configured to expose it</span>
|
49
|
-
63: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">proxy_error</span>
|
50
|
-
64: <span class="ruby-keyword kw">end</span>
|
51
|
-
65:
|
52
|
-
66: <span class="ruby-comment cmt"># proxy the 500 response</span>
|
53
|
-
67: <span class="ruby-identifier">proxy_response</span>.<span class="ruby-identifier">read_body</span> <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">fragment</span><span class="ruby-operator">|</span>
|
54
|
-
68: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">fragment</span>
|
55
|
-
69: <span class="ruby-keyword kw">end</span>
|
56
|
-
70:
|
57
|
-
71: <span class="ruby-keyword kw">end</span>
|
58
|
-
72: <span class="ruby-keyword kw">else</span>
|
59
|
-
73: <span class="ruby-comment cmt"># NOTE: It's very important that surrogate control headers are set to parse only if the </span>
|
60
|
-
74: <span class="ruby-comment cmt"># page has esi:include tags. Because of the nature of Transfer-Encoding: chunked if we keep</span>
|
61
|
-
75: <span class="ruby-comment cmt"># everything in memory until we reach an esi tag. Then we load the tag into memory and send the next</span>
|
62
|
-
76: <span class="ruby-comment cmt"># chunk and so on. This means that the density of tags to markup will result in more or less of the document</span>
|
63
|
-
77: <span class="ruby-comment cmt"># being stored in memory. A way we can get around this and attempt to keep a fixed size of the document in </span>
|
64
|
-
78: <span class="ruby-comment cmt"># memory at all time is by setting a buffer size of say 1024. Then no matter what we'll always chunk the document</span>
|
65
|
-
79: <span class="ruby-comment cmt"># by 1024 or some other size chunk.</span>
|
66
|
-
80: <span class="ruby-keyword kw">begin</span>
|
67
|
-
81: <span class="ruby-comment cmt"># Use the ESI Parser</span>
|
68
|
-
82:
|
69
|
-
83: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>[<span class="ruby-value str">"Transfer-Encoding"</span>] = <span class="ruby-value str">"chunked"</span>
|
70
|
-
84: <span class="ruby-comment cmt"># this is the important part, rather then send the whole document back we send in chunks</span>
|
71
|
-
85: <span class="ruby-comment cmt"># each fragment is roughly in it's own chunk, this does mean we require http 1.1, chunk size is still a limit</span>
|
72
|
-
86: <span class="ruby-identifier">header</span> = <span class="ruby-constant">Mongrel</span><span class="ruby-operator">::</span><span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">STATUS_FORMAT</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">status</span>, <span class="ruby-constant">Mongrel</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-identifier">status</span>]]
|
73
|
-
87: <span class="ruby-identifier">header</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/Connection: close\r\n/</span>,<span class="ruby-value str">''</span>)
|
74
|
-
88: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">rewind</span>
|
75
|
-
89: <span class="ruby-identifier">header</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>.<span class="ruby-identifier">out</span>.<span class="ruby-identifier">read</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Mongrel</span><span class="ruby-operator">::</span><span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LINE_END</span>
|
76
|
-
90: <span class="ruby-identifier">header</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/Status:.*?\r\n/</span>,<span class="ruby-value str">''</span>)
|
77
|
-
91: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">write</span>( <span class="ruby-identifier">header</span> )
|
78
|
-
92:
|
79
|
-
93: <span class="ruby-comment cmt">#print header</span>
|
80
|
-
94:
|
81
|
-
95: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">ESI</span><span class="ruby-operator">::</span><span class="ruby-constant">CParser</span>.<span class="ruby-identifier">new</span>
|
82
|
-
96: <span class="ruby-identifier">chunk_size</span> = <span class="ruby-ivar">@config</span>[<span class="ruby-identifier">:chunk_size</span>] <span class="ruby-operator">||</span> <span class="ruby-value">4096</span>
|
83
|
-
97: <span class="ruby-identifier">max_depth</span> = <span class="ruby-ivar">@config</span>[<span class="ruby-identifier">:max_depth</span>] <span class="ruby-operator">||</span> <span class="ruby-value">3</span>
|
84
|
-
98: <span class="ruby-identifier">buffer</span> = <span class="ruby-value str">""</span> <span class="ruby-comment cmt"># when buffer reaches chunk_size write to the response socket</span>
|
85
|
-
99:
|
86
|
-
100: <span class="ruby-comment cmt"># handle start tags</span>
|
87
|
-
101: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">start_tag_handler</span> <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">tag_name</span>, <span class="ruby-identifier">attrs</span><span class="ruby-operator">|</span>
|
88
|
-
102: <span class="ruby-identifier">tag</span> = <span class="ruby-constant">ESI</span><span class="ruby-operator">::</span><span class="ruby-constant">Tag</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">create</span>( <span class="ruby-ivar">@router</span>,
|
89
|
-
103: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>,
|
90
|
-
104: <span class="ruby-identifier">params</span>,
|
91
|
-
105: <span class="ruby-identifier">tag_name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/esi:/</span>,<span class="ruby-value str">''</span>),
|
92
|
-
106: <span class="ruby-identifier">attrs</span>,
|
93
|
-
107: <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">cache</span> )
|
94
|
-
108: <span class="ruby-comment cmt"># set the tag depth</span>
|
95
|
-
109: <span class="ruby-identifier">tag</span>.<span class="ruby-identifier">depth</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">depth</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tag</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:depth=</span>)
|
96
|
-
110: <span class="ruby-identifier">tag</span>.<span class="ruby-identifier">max_depth</span> = <span class="ruby-identifier">max_depth</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tag</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:max_depth=</span>)
|
97
|
-
111:
|
98
|
-
112: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span>
|
99
|
-
113: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span>.<span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">tag</span>)
|
100
|
-
114: <span class="ruby-keyword kw">else</span>
|
101
|
-
115: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span> = <span class="ruby-identifier">tag</span>
|
102
|
-
116: <span class="ruby-keyword kw">end</span>
|
103
|
-
117: <span class="ruby-keyword kw">end</span>
|
104
|
-
118:
|
105
|
-
119: <span class="ruby-comment cmt"># handle end tags</span>
|
106
|
-
120: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">end_tag_handler</span> <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">tag_name</span><span class="ruby-operator">|</span>
|
107
|
-
121: <span class="ruby-comment cmt">#ct = Time.now</span>
|
108
|
-
122: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">tag_name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/esi:/</span>,<span class="ruby-value str">''</span>)
|
109
|
-
123: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span>.<span class="ruby-identifier">close</span>(<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">output</span>)
|
110
|
-
124: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span> = <span class="ruby-keyword kw">nil</span>
|
111
|
-
125: <span class="ruby-keyword kw">else</span>
|
112
|
-
126: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">esi_tag</span>.<span class="ruby-identifier">close_child</span>(<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">output</span>,<span class="ruby-identifier">tag_name</span>)
|
113
|
-
127: <span class="ruby-keyword kw">end</span>
|
114
|
-
128: <span class="ruby-comment cmt">#puts "\t[#{tag_name}] Time to close: #{Time.now - ct}"</span>
|
115
|
-
129: <span class="ruby-keyword kw">end</span>
|
116
|
-
130:
|
117
|
-
131: <span class="ruby-comment cmt"># handle data streaming</span>
|
118
|
-
132: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">output_handler</span> <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">chars</span><span class="ruby-operator">|</span>
|
119
|
-
133: <span class="ruby-identifier">buffer</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">chars</span>
|
120
|
-
134: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">>=</span> <span class="ruby-identifier">chunk_size</span>
|
121
|
-
135: <span class="ruby-comment cmt">#print buffer</span>
|
122
|
-
136: <span class="ruby-identifier">send_chunk</span>( <span class="ruby-identifier">response</span>, <span class="ruby-identifier">buffer</span> )
|
123
|
-
137: <span class="ruby-identifier">chunk_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
124
|
-
138: <span class="ruby-identifier">buffer</span> = <span class="ruby-value str">""</span>
|
125
|
-
139: <span class="ruby-keyword kw">end</span>
|
126
|
-
140: <span class="ruby-keyword kw">end</span>
|
127
|
-
141:
|
128
|
-
142: <span class="ruby-comment cmt">#t = Time.now</span>
|
129
|
-
143: <span class="ruby-identifier">proxy_response</span>.<span class="ruby-identifier">read_body</span> <span class="ruby-keyword kw">do</span><span class="ruby-operator">|</span><span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
|
130
|
-
144: <span class="ruby-comment cmt">#pt = Time.now</span>
|
131
|
-
145: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">process</span> <span class="ruby-identifier">data</span>
|
132
|
-
146: <span class="ruby-comment cmt">#puts "Time in process: #{Time.now - pt}"</span>
|
133
|
-
147: <span class="ruby-keyword kw">end</span>
|
134
|
-
148: <span class="ruby-comment cmt">#puts "Response Time: #{Time.now - t}"</span>
|
135
|
-
149:
|
136
|
-
150: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finish</span>
|
137
|
-
151: <span class="ruby-identifier">parser</span> = <span class="ruby-keyword kw">nil</span>
|
138
|
-
152:
|
139
|
-
153: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
140
|
-
154: <span class="ruby-comment cmt">#print buffer</span>
|
141
|
-
155: <span class="ruby-identifier">send_chunk</span>( <span class="ruby-identifier">response</span>, <span class="ruby-identifier">buffer</span> )
|
142
|
-
156: <span class="ruby-identifier">chunk_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
143
|
-
157: <span class="ruby-keyword kw">end</span>
|
144
|
-
158:
|
145
|
-
159: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
146
|
-
160: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"\n#{e.class}: error in #{__FILE__}:#{__LINE__}\n"</span>
|
147
|
-
161: <span class="ruby-keyword kw">end</span>
|
148
|
-
162: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">write</span>( <span class="ruby-value str">"0\r\n\r\n"</span> )
|
149
|
-
163: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">done</span> = <span class="ruby-keyword kw">true</span>
|
150
|
-
164: <span class="ruby-keyword kw">end</span>
|
151
|
-
165: <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># end request</span>
|
152
|
-
166:
|
153
|
-
167: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
154
|
-
168: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"\n#{e.class}: error in #{__FILE__}:#{__LINE__}\n"</span>
|
155
|
-
169: <span class="ruby-keyword kw">ensure</span>
|
156
|
-
170:
|
157
|
-
171: <span class="ruby-identifier">log_request</span> <span class="ruby-node">"\nCompleted => #{url}, #{Time.now - start} seconds with status #{status} and #{chunk_count} chunks\n"</span>
|
158
|
-
172:
|
159
|
-
173: <span class="ruby-keyword kw">end</span></pre>
|
160
|
-
</body>
|
161
|
-
</html>
|