httpkit 0.6.0.pre.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +0 -2
  3. data/.travis.yml +1 -1
  4. data/Gemfile +2 -0
  5. data/README.md +32 -25
  6. data/Rakefile +5 -0
  7. data/config/flay.yml +1 -1
  8. data/doc/api/httpkit.html +50 -0
  9. data/doc/api/httpkit/body.html +149 -0
  10. data/doc/api/httpkit/client.html +50 -0
  11. data/doc/api/httpkit/client/body_handler.html +50 -0
  12. data/doc/api/httpkit/client/keep_alive_handler.html +79 -0
  13. data/doc/api/httpkit/client/mandatory_handler.html +50 -0
  14. data/doc/api/httpkit/client/timeouts_handler.html +82 -0
  15. data/doc/api/httpkit/connection/eventmachine.html +157 -0
  16. data/doc/api/httpkit/connection/status.html +50 -0
  17. data/doc/api/httpkit/promise.html +50 -0
  18. data/doc/api/httpkit/request.html +123 -0
  19. data/doc/api/httpkit/response.html +209 -0
  20. data/doc/api/httpkit/serializer.html +150 -0
  21. data/doc/api/httpkit/server.html +50 -0
  22. data/doc/api/httpkit/server/block_handler.html +50 -0
  23. data/doc/api/httpkit/server/body_handler.html +50 -0
  24. data/doc/api/httpkit/server/keep_alive_handler.html +145 -0
  25. data/doc/api/httpkit/server/mandatory_handler.html +50 -0
  26. data/doc/api/httpkit/server/timeouts_handler.html +81 -0
  27. data/doc/api/httpkit/support/handler_manager.html +95 -0
  28. data/doc/api/httpkit/support/message.html +50 -0
  29. data/doc/api/httpkit/version.html +50 -0
  30. data/doc/examples/echo_server.html +101 -0
  31. data/doc/examples/error_handling.html +176 -0
  32. data/doc/examples/getting_started.html +161 -0
  33. data/doc/examples/streaming.html +108 -0
  34. data/doc/index.html +165 -0
  35. data/examples/echo_server.rb +14 -6
  36. data/examples/error_handling.rb +56 -0
  37. data/examples/getting_started.rb +10 -18
  38. data/examples/streaming.rb +41 -0
  39. data/lib/httpkit.rb +22 -0
  40. data/lib/httpkit/body.rb +4 -0
  41. data/lib/httpkit/client.rb +1 -9
  42. data/lib/httpkit/client/keep_alive_handler.rb +1 -0
  43. data/lib/httpkit/connection/eventmachine.rb +2 -1
  44. data/lib/httpkit/server/block_handler.rb +13 -0
  45. data/lib/httpkit/server/keep_alive_handler.rb +1 -0
  46. data/lib/httpkit/version.rb +1 -1
  47. data/spec/integration/timeouts_spec.rb +3 -2
  48. data/spec/support/helper.rb +1 -8
  49. data/spec/unit/client_spec.rb +2 -21
  50. data/spec/unit/server_spec.rb +11 -1
  51. metadata +34 -5
  52. data/Procfile +0 -1
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>server.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="body.html">body.rb</a>
17
+ <a class="source" href="client.html">client.rb</a>
18
+ <a class="source" href="client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="connection/status.html">status.rb</a>
24
+ <a class="source" href="promise.html">promise.rb</a>
25
+ <a class="source" href="request.html">request.rb</a>
26
+ <a class="source" href="response.html">response.rb</a>
27
+ <a class="source" href="serializer.html">serializer.rb</a>
28
+ <a class="source" href="server.html">server.rb</a>
29
+ <a class="source" href="server/block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="server/body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="server/keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="server/mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="server/timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="support/message.html">message.rb</a>
36
+ <a class="source" href="version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>server.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>block_handler.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="../client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="../client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="../client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="../client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="../support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="../support/message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>block_handler.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>body_handler.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="../client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="../client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="../client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="../client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="../support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="../support/message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>body_handler.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>
@@ -0,0 +1,145 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>keep_alive_handler.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="../client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="../client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="../client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="../client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="../support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="../support/message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>keep_alive_handler.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <tr id='section-1'>
49
+ <td class=docs>
50
+ <div class="pilwrap">
51
+ <a class="pilcrow" href="#section-1">&#182;</a>
52
+ </div>
53
+
54
+ </td>
55
+ <td class=code>
56
+ <div class='highlight'><pre><span class="k">module</span> <span class="nn">HTTPkit</span>
57
+ <span class="k">class</span> <span class="nc">Server</span><span class="o">::</span><span class="no">KeepAliveHandler</span>
58
+ <span class="no">CONNECTION</span> <span class="o">=</span> <span class="s1">&#39;Connection&#39;</span><span class="o">.</span><span class="n">freeze</span>
59
+ <span class="no">CLOSE</span> <span class="o">=</span> <span class="s1">&#39;close&#39;</span><span class="o">.</span><span class="n">freeze</span>
60
+ <span class="no">KEEP_ALIVE</span> <span class="o">=</span> <span class="s1">&#39;keep-alive&#39;</span><span class="o">.</span><span class="n">freeze</span>
61
+
62
+ <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="n">_</span><span class="p">,</span> <span class="n">server</span><span class="p">,</span> <span class="n">_</span><span class="p">)</span>
63
+ <span class="vi">@server</span> <span class="o">=</span> <span class="n">server</span>
64
+ <span class="vi">@requests</span> <span class="o">=</span> <span class="p">{}</span>
65
+ <span class="k">end</span>
66
+
67
+ <span class="k">def</span> <span class="nf">serve</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">served</span><span class="p">)</span>
68
+ <span class="vi">@requests</span><span class="o">[</span><span class="n">sequence</span><span class="p">(</span><span class="n">request</span><span class="p">)</span><span class="o">]</span> <span class="o">=</span> <span class="n">served</span>
69
+ <span class="k">end</span>
70
+
71
+ <span class="k">def</span> <span class="nf">respond</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">)</span>
72
+ <span class="n">synchronize_responses</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
73
+
74
+ <span class="k">if</span> <span class="n">close_connection?</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
75
+ <span class="k">yield</span> <span class="n">request</span><span class="p">,</span> <span class="n">close_response</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
76
+ <span class="k">else</span>
77
+ <span class="k">yield</span> <span class="n">request</span><span class="p">,</span> <span class="n">keep_alive_response</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
78
+ <span class="k">end</span>
79
+ <span class="k">end</span>
80
+
81
+ <span class="k">def</span> <span class="nf">finish</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
82
+ <span class="vi">@requests</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">sequence</span><span class="p">(</span><span class="n">request</span><span class="p">))</span>
83
+ <span class="k">end</span>
84
+
85
+ <span class="kp">private</span>
86
+
87
+ <span class="k">def</span> <span class="nf">sequence</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
88
+ <span class="n">request</span><span class="o">.</span><span class="n">sequence</span><span class="p">(</span><span class="vi">@server</span><span class="p">)</span>
89
+ <span class="k">end</span>
90
+
91
+ <span class="k">def</span> <span class="nf">close_response</span><span class="p">(</span><span class="n">response</span><span class="p">)</span></pre></div>
92
+ </td>
93
+ </tr>
94
+ <tr id='section-2'>
95
+ <td class=docs>
96
+ <div class="pilwrap">
97
+ <a class="pilcrow" href="#section-2">&#182;</a>
98
+ </div>
99
+ <p>XXX: possible race condition with other locations waiting for this</p>
100
+ </td>
101
+ <td class=code>
102
+ <div class='highlight'><pre> <span class="n">response</span><span class="o">.</span><span class="n">closed</span> <span class="p">{</span> <span class="vi">@server</span><span class="o">.</span><span class="n">close</span> <span class="p">}</span>
103
+ <span class="n">response</span><span class="o">.</span><span class="n">with_headers</span><span class="p">(</span><span class="no">CONNECTION</span> <span class="o">=&gt;</span> <span class="no">CLOSE</span><span class="p">)</span>
104
+ <span class="k">end</span>
105
+
106
+ <span class="k">def</span> <span class="nf">keep_alive_response</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
107
+ <span class="n">response</span><span class="o">.</span><span class="n">with_headers</span><span class="p">(</span><span class="no">CONNECTION</span> <span class="o">=&gt;</span> <span class="no">KEEP_ALIVE</span><span class="p">)</span>
108
+ <span class="k">end</span>
109
+
110
+ <span class="k">def</span> <span class="nf">synchronize_responses</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
111
+ <span class="n">served</span> <span class="o">=</span> <span class="vi">@requests</span><span class="o">[</span><span class="n">sequence</span><span class="p">(</span><span class="n">request</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="o">]</span></pre></div>
112
+ </td>
113
+ </tr>
114
+ <tr id='section-3'>
115
+ <td class=docs>
116
+ <div class="pilwrap">
117
+ <a class="pilcrow" href="#section-3">&#182;</a>
118
+ </div>
119
+ <p>TODO: only wait for served, move rest to Serializer</p>
120
+
121
+ </td>
122
+ <td class=code>
123
+ <div class='highlight'><pre> <span class="n">served</span><span class="o">.</span><span class="n">sync</span><span class="o">.</span><span class="n">closed!</span> <span class="k">if</span> <span class="n">served</span>
124
+ <span class="k">end</span>
125
+
126
+ <span class="k">def</span> <span class="nf">connection_header</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
127
+ <span class="n">response</span> <span class="o">=</span> <span class="vi">@requests</span><span class="o">[</span><span class="n">sequence</span><span class="p">(</span><span class="n">request</span><span class="p">)</span><span class="o">].</span><span class="n">value</span>
128
+ <span class="n">request</span><span class="o">.</span><span class="n">headers</span><span class="o">[</span><span class="no">CONNECTION</span><span class="o">]</span> <span class="o">||</span> <span class="n">response</span><span class="o">.</span><span class="n">headers</span><span class="o">[</span><span class="no">CONNECTION</span><span class="o">]</span>
129
+ <span class="k">end</span>
130
+
131
+ <span class="k">def</span> <span class="nf">close_connection?</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
132
+ <span class="n">header</span> <span class="o">=</span> <span class="n">connection_header</span><span class="p">(</span><span class="n">request</span><span class="p">)</span><span class="o">.</span><span class="n">to_s</span><span class="o">.</span><span class="n">downcase</span>
133
+ <span class="n">header</span> <span class="o">==</span> <span class="no">CLOSE</span> <span class="o">||</span> <span class="n">http10_close?</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">http_version</span><span class="p">,</span> <span class="n">header</span><span class="p">)</span>
134
+ <span class="k">end</span>
135
+
136
+ <span class="k">def</span> <span class="nf">http10_close?</span><span class="p">(</span><span class="n">version</span><span class="p">,</span> <span class="n">header</span><span class="p">)</span>
137
+ <span class="n">version</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="o">.</span><span class="mi">1</span> <span class="o">&amp;&amp;</span> <span class="n">header</span> <span class="o">!=</span> <span class="no">KEEP_ALIVE</span>
138
+ <span class="k">end</span>
139
+ <span class="k">end</span>
140
+ <span class="k">end</span></pre></div>
141
+ </td>
142
+ </tr>
143
+ </table>
144
+ </div>
145
+ </body>
@@ -0,0 +1,50 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>mandatory_handler.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="../client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="../client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="../client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="../client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="../support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="../support/message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>mandatory_handler.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ </table>
49
+ </div>
50
+ </body>
@@ -0,0 +1,81 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>timeouts_handler.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="../client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="../client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="../client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="../client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="../support/handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="../support/message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>timeouts_handler.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <tr id='section-1'>
49
+ <td class=docs>
50
+ <div class="pilwrap">
51
+ <a class="pilcrow" href="#section-1">&#182;</a>
52
+ </div>
53
+
54
+ </td>
55
+ <td class=code>
56
+ <div class='highlight'><pre><span class="k">module</span> <span class="nn">HTTPkit</span></pre></div>
57
+ </td>
58
+ </tr>
59
+ <tr id='section-2'>
60
+ <td class=docs>
61
+ <div class="pilwrap">
62
+ <a class="pilcrow" href="#section-2">&#182;</a>
63
+ </div>
64
+ <p>@see EM.heartbeat_interval</p>
65
+
66
+ </td>
67
+ <td class=code>
68
+ <div class='highlight'><pre> <span class="k">class</span> <span class="nc">Server</span><span class="o">::</span><span class="no">TimeoutsHandler</span>
69
+ <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="n">config</span><span class="p">,</span> <span class="n">_</span><span class="p">,</span> <span class="n">connection</span><span class="p">)</span>
70
+ <span class="vi">@config</span> <span class="o">=</span> <span class="n">config</span>
71
+ <span class="vi">@connection</span> <span class="o">=</span> <span class="n">connection</span>
72
+
73
+ <span class="vi">@connection</span><span class="o">.</span><span class="n">comm_inactivity_timeout</span> <span class="o">=</span> <span class="vi">@config</span><span class="o">[</span><span class="ss">:timeout</span><span class="o">]</span> <span class="o">||=</span> <span class="mi">2</span><span class="o">.</span><span class="mi">0</span>
74
+ <span class="k">end</span>
75
+ <span class="k">end</span>
76
+ <span class="k">end</span></pre></div>
77
+ </td>
78
+ </tr>
79
+ </table>
80
+ </div>
81
+ </body>
@@ -0,0 +1,95 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>handler_manager.rb</title>
6
+ <link rel="stylesheet" href="http://jashkenas.github.io/docco/resources/linear/docco.css">
7
+ </head>
8
+ <body>
9
+ <div id='container'>
10
+ <div id="background"></div>
11
+ <div id="jump_to">
12
+ Jump To &hellip;
13
+ <div id="jump_wrapper">
14
+ <div id="jump_page">
15
+ <a class="source" href="../../httpkit.html">httpkit.rb</a>
16
+ <a class="source" href="../body.html">body.rb</a>
17
+ <a class="source" href="../client.html">client.rb</a>
18
+ <a class="source" href="../client/body_handler.html">body_handler.rb</a>
19
+ <a class="source" href="../client/keep_alive_handler.html">keep_alive_handler.rb</a>
20
+ <a class="source" href="../client/mandatory_handler.html">mandatory_handler.rb</a>
21
+ <a class="source" href="../client/timeouts_handler.html">timeouts_handler.rb</a>
22
+ <a class="source" href="../connection/eventmachine.html">eventmachine.rb</a>
23
+ <a class="source" href="../connection/status.html">status.rb</a>
24
+ <a class="source" href="../promise.html">promise.rb</a>
25
+ <a class="source" href="../request.html">request.rb</a>
26
+ <a class="source" href="../response.html">response.rb</a>
27
+ <a class="source" href="../serializer.html">serializer.rb</a>
28
+ <a class="source" href="../server.html">server.rb</a>
29
+ <a class="source" href="../server/block_handler.html">block_handler.rb</a>
30
+ <a class="source" href="../server/body_handler.html">body_handler.rb</a>
31
+ <a class="source" href="../server/keep_alive_handler.html">keep_alive_handler.rb</a>
32
+ <a class="source" href="../server/mandatory_handler.html">mandatory_handler.rb</a>
33
+ <a class="source" href="../server/timeouts_handler.html">timeouts_handler.rb</a>
34
+ <a class="source" href="handler_manager.html">handler_manager.rb</a>
35
+ <a class="source" href="message.html">message.rb</a>
36
+ <a class="source" href="../version.html">version.rb</a>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <table cellspacing=0 cellpadding=0>
41
+ <thead>
42
+ <tr>
43
+ <th class=docs><h1>handler_manager.rb</h1></th>
44
+ <th class=code></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <tr id='section-1'>
49
+ <td class=docs>
50
+ <div class="pilwrap">
51
+ <a class="pilcrow" href="#section-1">&#182;</a>
52
+ </div>
53
+
54
+ </td>
55
+ <td class=code>
56
+ <div class='highlight'><pre><span class="k">module</span> <span class="nn">HTTPkit</span>
57
+ <span class="k">module</span> <span class="nn">Support</span>
58
+ <span class="k">class</span> <span class="nc">HandlerManager</span>
59
+ <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">handlers</span><span class="p">)</span>
60
+ <span class="vi">@handlers</span> <span class="o">=</span> <span class="n">handlers</span>
61
+ <span class="k">end</span>
62
+
63
+ <span class="k">def</span> <span class="nf">invoke</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">arguments</span><span class="p">)</span>
64
+ <span class="vi">@handlers</span>
65
+ <span class="o">.</span><span class="n">select</span> <span class="p">{</span> <span class="o">|</span><span class="n">handler</span><span class="o">|</span> <span class="n">handler</span><span class="o">.</span><span class="n">respond_to?</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> <span class="p">}</span>
66
+ <span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">arguments</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">args</span><span class="p">,</span> <span class="n">handler</span><span class="o">|</span>
67
+ <span class="n">handler</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="p">{</span> <span class="o">|*</span><span class="n">new_args</span><span class="o">|</span> <span class="n">args</span> <span class="o">=</span> <span class="n">new_args</span> <span class="p">}</span>
68
+ <span class="n">args</span>
69
+ <span class="k">end</span>
70
+ <span class="k">end</span></pre></div>
71
+ </td>
72
+ </tr>
73
+ <tr id='section-2'>
74
+ <td class=docs>
75
+ <div class="pilwrap">
76
+ <a class="pilcrow" href="#section-2">&#182;</a>
77
+ </div>
78
+ <p>XXX not mutation covered</p>
79
+
80
+ </td>
81
+ <td class=code>
82
+ <div class='highlight'><pre> <span class="k">module</span> <span class="nn">Setup</span>
83
+ <span class="k">def</span> <span class="nf">setup_handlers</span>
84
+ <span class="vi">@handlers</span> <span class="o">=</span> <span class="ss">Support</span><span class="p">:</span><span class="ss">:HandlerManager</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="vi">@config</span><span class="o">[</span><span class="ss">:handlers</span><span class="o">]</span> <span class="o">||</span> <span class="o">[]</span><span class="p">)</span>
85
+ <span class="vi">@handlers</span><span class="o">.</span><span class="n">invoke</span><span class="p">(</span><span class="ss">:setup</span><span class="p">,</span> <span class="vi">@config</span><span class="p">,</span> <span class="nb">self</span><span class="p">,</span> <span class="vi">@connection</span><span class="p">)</span>
86
+ <span class="k">end</span>
87
+ <span class="k">end</span>
88
+ <span class="k">end</span>
89
+ <span class="k">end</span>
90
+ <span class="k">end</span></pre></div>
91
+ </td>
92
+ </tr>
93
+ </table>
94
+ </div>
95
+ </body>