siffer 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/doc/rdoc/classes/Siffer.html +253 -368
- data/doc/rdoc/classes/Siffer/Agent.html +169 -288
- data/doc/rdoc/classes/Siffer/Container.html +158 -279
- data/doc/rdoc/classes/Siffer/Messages.html +79 -139
- data/doc/rdoc/classes/Siffer/Messages/Ack.html +109 -210
- data/doc/rdoc/classes/Siffer/Messages/Acl.html +78 -155
- data/doc/rdoc/classes/Siffer/Messages/Error.html +151 -242
- data/doc/rdoc/classes/Siffer/Messages/Message.html +227 -351
- data/doc/rdoc/classes/Siffer/Messages/Message/Header.html +102 -176
- data/doc/rdoc/classes/Siffer/Messages/Register.html +147 -250
- data/doc/rdoc/classes/Siffer/Messages/RequestBody.html +177 -292
- data/doc/rdoc/classes/Siffer/Messages/Status.html +149 -262
- data/doc/rdoc/classes/Siffer/Messaging.html +204 -323
- data/doc/rdoc/classes/Siffer/Protocol.html +246 -380
- data/doc/rdoc/classes/Siffer/Protocol/NonPostRequest.html +53 -110
- data/doc/rdoc/classes/Siffer/Protocol/UnknownPath.html +53 -110
- data/doc/rdoc/classes/Siffer/Registration.html +243 -383
- data/doc/rdoc/classes/Siffer/Request.html +97 -203
- data/doc/rdoc/classes/Siffer/RequestLogger.html +102 -204
- data/doc/rdoc/classes/Siffer/Response.html +85 -176
- data/doc/rdoc/classes/Siffer/Server.html +150 -236
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/LICENSE.html +75 -128
- data/doc/rdoc/files/README_rdoc.html +130 -183
- data/doc/rdoc/files/lib/siffer/agent_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/container_rb.html +57 -0
- data/doc/rdoc/files/lib/siffer/messages/ack_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages/acl_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages/error_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages/message_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages/register_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages/request_body_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages/status_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/messages_rb.html +63 -0
- data/doc/rdoc/files/lib/siffer/messaging_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/protocol_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/registration_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/request_logger_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/request_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/response_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer/server_rb.html +49 -0
- data/doc/rdoc/files/lib/siffer_rb.html +62 -113
- data/doc/rdoc/fr_class_index.html +25 -47
- data/doc/rdoc/fr_file_index.html +39 -46
- data/doc/rdoc/fr_method_index.html +4539 -96
- data/doc/rdoc/index.html +14 -23
- data/doc/rdoc/rdoc-style.css +314 -203
- data/lib/siffer.rb +6 -6
- data/lib/{agent.rb → siffer/agent.rb} +5 -3
- data/lib/{container.rb → siffer/container.rb} +3 -5
- data/lib/siffer/messages.rb +7 -0
- data/lib/{messages → siffer/messages}/ack.rb +0 -0
- data/lib/{messages → siffer/messages}/acl.rb +0 -0
- data/lib/{messages → siffer/messages}/error.rb +0 -0
- data/lib/{messages → siffer/messages}/message.rb +0 -0
- data/lib/{messages → siffer/messages}/register.rb +0 -0
- data/lib/{messages → siffer/messages}/request_body.rb +0 -0
- data/lib/{messages → siffer/messages}/status.rb +0 -0
- data/lib/{messaging.rb → siffer/messaging.rb} +8 -5
- data/lib/{protocol.rb → siffer/protocol.rb} +37 -32
- data/lib/{registration.rb → siffer/registration.rb} +2 -2
- data/lib/siffer/request.rb +28 -0
- data/lib/{request_logger.rb → siffer/request_logger.rb} +8 -7
- data/lib/{response.rb → siffer/response.rb} +1 -1
- data/lib/{server.rb → siffer/server.rb} +5 -3
- data/spec/agent_spec.rb +6 -11
- data/spec/container_spec.rb +2 -2
- data/spec/default_agent +1 -1
- data/spec/messaging_spec.rb +3 -6
- data/spec/protocol_spec.rb +27 -26
- data/spec/registration_spec.rb +2 -2
- data/spec/request_logger_spec.rb +22 -9
- data/spec/request_spec.rb +15 -0
- data/spec/response_spec.rb +2 -2
- data/spec/server_spec.rb +0 -5
- data/spec/spec_helper.rb +9 -0
- metadata +40 -38
- data/doc/rdoc/files/lib/agent_rb.html +0 -101
- data/doc/rdoc/files/lib/container_rb.html +0 -108
- data/doc/rdoc/files/lib/messages/ack_rb.html +0 -101
- data/doc/rdoc/files/lib/messages/acl_rb.html +0 -101
- data/doc/rdoc/files/lib/messages/error_rb.html +0 -101
- data/doc/rdoc/files/lib/messages/message_rb.html +0 -101
- data/doc/rdoc/files/lib/messages/register_rb.html +0 -101
- data/doc/rdoc/files/lib/messages/request_body_rb.html +0 -101
- data/doc/rdoc/files/lib/messages/status_rb.html +0 -101
- data/doc/rdoc/files/lib/messages_rb.html +0 -114
- data/doc/rdoc/files/lib/messaging_rb.html +0 -101
- data/doc/rdoc/files/lib/protocol_rb.html +0 -101
- data/doc/rdoc/files/lib/registration_rb.html +0 -101
- data/doc/rdoc/files/lib/request_logger_rb.html +0 -101
- data/doc/rdoc/files/lib/request_rb.html +0 -101
- data/doc/rdoc/files/lib/response_rb.html +0 -101
- data/doc/rdoc/files/lib/server_rb.html +0 -101
- data/lib/messages.rb +0 -7
- data/lib/request.rb +0 -25
@@ -1,388 +1,254 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Siffer::Protocol</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/protocol_rb.html">
|
59
|
-
lib/protocol.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
</table>
|
66
|
-
</div>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<div id="contextContent">
|
74
|
-
|
75
|
-
<div id="description">
|
76
|
-
<p>
|
77
|
-
The <a href="Protocol.html">Protocol</a> module deals with the transport
|
78
|
-
validation. Provides constants for HTTP statuses as well as acceptable
|
79
|
-
paths for <a href="../Siffer.html">Siffer</a> Servers and Agents.
|
80
|
-
</p>
|
81
|
-
|
82
|
-
</div>
|
83
|
-
|
84
|
-
|
85
|
-
</div>
|
86
|
-
|
87
|
-
<div id="method-list">
|
88
|
-
<h3 class="section-bar">Methods</h3>
|
89
|
-
|
90
|
-
<div class="name-list">
|
91
|
-
<a href="#M000008">check_path_against_protocol</a>
|
92
|
-
<a href="#M000011">error_response</a>
|
93
|
-
<a href="#M000012">no_response_available</a>
|
94
|
-
<a href="#M000007">request_failed_protocol?</a>
|
95
|
-
<a href="#M000009">uri</a>
|
96
|
-
<a href="#M000010">with_each_request</a>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
</div>
|
101
|
-
|
102
|
-
|
103
|
-
<!-- if includes -->
|
104
|
-
<div id="includes">
|
105
|
-
<h3 class="section-bar">Included Modules</h3>
|
106
|
-
|
107
|
-
<div id="includes-list">
|
108
|
-
<span class="include-name"><a href="Messages.html">Siffer::Messages</a></span>
|
109
|
-
<span class="include-name"><a href="Messaging.html">Siffer::Messaging</a></span>
|
110
|
-
</div>
|
111
|
-
</div>
|
112
|
-
|
113
|
-
<div id="section">
|
114
|
-
|
115
|
-
<div id="class-list">
|
116
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
117
|
-
|
118
|
-
Class <a href="Protocol/NonPostRequest.html" class="link">Siffer::Protocol::NonPostRequest</a><br />
|
119
|
-
Class <a href="Protocol/UnknownPath.html" class="link">Siffer::Protocol::UnknownPath</a><br />
|
120
|
-
|
121
|
-
</div>
|
122
|
-
|
123
|
-
<div id="constants-list">
|
124
|
-
<h3 class="section-bar">Constants</h3>
|
125
|
-
|
126
|
-
<div class="name-list">
|
127
|
-
<table summary="Constants">
|
128
|
-
<tr class="top-aligned-row context-row">
|
129
|
-
<td class="context-item-name">ACCEPTABLE_PATHS</td>
|
130
|
-
<td>=</td>
|
131
|
-
<td class="context-item-value">{ :root => "/", :ping => "/ping", :status => "/status", :register => "/register"</td>
|
132
|
-
<td width="3em"> </td>
|
133
|
-
<td class="context-item-desc">
|
134
|
-
Paths that comply with the messaging protocol determined by the SIF
|
135
|
-
Specification. These are <a href="../Siffer.html">Siffer</a> specific and
|
136
|
-
not spelled out in SIF Specification (rather implied). Each path will
|
137
|
-
generate it‘s own predicate method (i.e. ping?) that can be used to
|
138
|
-
determine the requests path based on the content of the message or the
|
139
|
-
path-info of the request.
|
140
|
-
|
141
|
-
</td>
|
142
|
-
</tr>
|
143
|
-
<tr class="top-aligned-row context-row">
|
144
|
-
<td class="context-item-name">HTTP_STATUS_CODES</td>
|
145
|
-
<td>=</td>
|
146
|
-
<td class="context-item-value">{ 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Moved Temporarily', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported'</td>
|
147
|
-
<td width="3em"> </td>
|
148
|
-
<td class="context-item-desc">
|
149
|
-
Every standard HTTP code mapped to the appropriate message. Stolen from
|
150
|
-
Mongrel.
|
151
|
-
|
152
|
-
</td>
|
153
|
-
</tr>
|
154
|
-
</table>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>Module: Siffer::Protocol [Siffer == h3o(software) SIF]</title>
|
5
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='class' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>
|
29
|
+
<span class='type'>Module</span>
|
30
|
+
Siffer::Protocol
|
31
|
+
</h1>
|
32
|
+
<ol class='paths'>
|
33
|
+
<li>
|
34
|
+
<a href="../../files/lib/siffer/protocol_rb.html">lib/siffer/protocol.rb</a>
|
35
|
+
</li>
|
36
|
+
</ol>
|
155
37
|
</div>
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
<div id="methods">
|
165
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
166
|
-
|
167
|
-
<div id="method-M000008" class="method-detail">
|
168
|
-
<a name="M000008"></a>
|
169
|
-
|
170
|
-
<div class="method-heading">
|
171
|
-
<a href="#M000008" class="method-signature">
|
172
|
-
<span class="method-name">check_path_against_protocol</span><span class="method-args">()</span>
|
173
|
-
</a>
|
174
|
-
</div>
|
175
|
-
|
176
|
-
<div class="method-description">
|
177
|
-
<p>
|
178
|
-
Validates the request object against the Acceptable Paths (<a
|
179
|
-
href="../Siffer.html">Siffer</a> spec) and that the request is a POST.
|
180
|
-
</p>
|
181
|
-
<p><a class="source-toggle" href="#"
|
182
|
-
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
183
|
-
<div class="method-source-code" id="M000008-source">
|
184
|
-
<pre>
|
185
|
-
<span class="ruby-comment cmt"># File lib/protocol.rb, line 34</span>
|
186
|
-
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_path_against_protocol</span>
|
187
|
-
35: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ACCEPTABLE_PATHS</span>.<span class="ruby-identifier">has_value?</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_info</span>
|
188
|
-
36: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownPath</span>
|
189
|
-
37: <span class="ruby-keyword kw">end</span>
|
190
|
-
38: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">post?</span>
|
191
|
-
39: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NonPostRequest</span>
|
192
|
-
40: <span class="ruby-keyword kw">end</span>
|
193
|
-
41: <span class="ruby-keyword kw">end</span>
|
194
|
-
</pre>
|
38
|
+
<div id='content'>
|
39
|
+
<div id='text'>
|
40
|
+
<div id='description'>
|
41
|
+
<p>
|
42
|
+
The <a href="Protocol.html">Protocol</a> module deals with the transport
|
43
|
+
validation. Provides constants for HTTP statuses as well as acceptable
|
44
|
+
paths for <a href="../Siffer.html">Siffer</a> Servers and Agents.
|
45
|
+
</p>
|
195
46
|
</div>
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
<div class="method-description">
|
209
|
-
<p>
|
210
|
-
Sets the @response to a <a
|
211
|
-
href="Messages/Ack.html">Siffer::Messages::Ack</a> message with the
|
212
|
-
appropriate Error category and code. Optional description is allowed and
|
213
|
-
placed in the ExtendedDesc node.
|
214
|
-
</p>
|
215
|
-
<p><a class="source-toggle" href="#"
|
216
|
-
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
217
|
-
<div class="method-source-code" id="M000011-source">
|
218
|
-
<pre>
|
219
|
-
<span class="ruby-comment cmt"># File lib/protocol.rb, line 70</span>
|
220
|
-
70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error_response</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>, <span class="ruby-identifier">desc</span> = <span class="ruby-keyword kw">nil</span>)
|
221
|
-
71: <span class="ruby-identifier">error</span> = <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>,<span class="ruby-identifier">desc</span>)
|
222
|
-
72: <span class="ruby-identifier">ack</span> = <span class="ruby-constant">Ack</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">original</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">error</span>)
|
223
|
-
73: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ack</span>)
|
224
|
-
74: <span class="ruby-keyword kw">end</span>
|
225
|
-
</pre>
|
47
|
+
<div id='method-list'>
|
48
|
+
<h2>Methods</h2>
|
49
|
+
<h3>public instance</h3>
|
50
|
+
<ol>
|
51
|
+
<li><a href="#M000008">check_path_against_protocol</a></li>
|
52
|
+
<li><a href="#M000011">error_response</a></li>
|
53
|
+
<li><a href="#M000012">no_response_available</a></li>
|
54
|
+
<li><a href="#M000007">request_failed_protocol?</a></li>
|
55
|
+
<li><a href="#M000013">root_response</a></li>
|
56
|
+
<li><a href="#M000009">uri</a></li>
|
57
|
+
<li><a href="#M000010">with_each_request</a></li>
|
58
|
+
</ol>
|
226
59
|
</div>
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
<span class="method-name">no_response_available</span><span class="method-args">()</span>
|
236
|
-
</a>
|
237
|
-
</div>
|
238
|
-
|
239
|
-
<div class="method-description">
|
240
|
-
<p>
|
241
|
-
Determines if there is a response instance created. If not it creates one
|
242
|
-
with an Ack/Error describing not having anything to process.
|
243
|
-
</p>
|
244
|
-
<p><a class="source-toggle" href="#"
|
245
|
-
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
246
|
-
<div class="method-source-code" id="M000012-source">
|
247
|
-
<pre>
|
248
|
-
<span class="ruby-comment cmt"># File lib/protocol.rb, line 79</span>
|
249
|
-
79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no_response_available</span>
|
250
|
-
80: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">nil?</span>
|
251
|
-
81: <span class="ruby-identifier">err</span> = <span class="ruby-value str">"You are receiving this message because you failed to \nprovide enough information to respond to. This is likely due\nto the message type missing (i.e. Register,Provide) or possibly\nnot enough information to process effectively. Please check the \nmessage you are sending and resend after any corrections.\n"</span>
|
252
|
-
82: <span class="ruby-operator">!</span><span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">1</span>,<span class="ruby-identifier">err</span>)
|
253
|
-
83: <span class="ruby-keyword kw">end</span>
|
254
|
-
84: <span class="ruby-keyword kw">end</span>
|
255
|
-
</pre>
|
60
|
+
<div id='context'>
|
61
|
+
<div id='includes'>
|
62
|
+
<h2>Included modules</h2>
|
63
|
+
<ol>
|
64
|
+
<li><a href="Messages.html">Siffer::Messages</a></li>
|
65
|
+
<li><a href="Messaging.html">Siffer::Messaging</a></li>
|
66
|
+
</ol>
|
67
|
+
</div>
|
256
68
|
</div>
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
</
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
<
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
69
|
+
<div id='section'>
|
70
|
+
<div id='class-list'>
|
71
|
+
<h2>Classes and Modules</h2>
|
72
|
+
Class <a href="Protocol/NonPostRequest.html" class="link">Siffer::Protocol::NonPostRequest</a><br />
|
73
|
+
Class <a href="Protocol/UnknownPath.html" class="link">Siffer::Protocol::UnknownPath</a><br />
|
74
|
+
</div>
|
75
|
+
<div id='constants-list'>
|
76
|
+
<h2>Constants</h2>
|
77
|
+
<div class='name-list'>
|
78
|
+
<table summary='Constants'>
|
79
|
+
<tr class='top-aligned-row context-row'>
|
80
|
+
<td class='context-item-name'>ACCEPTABLE_PATHS</td>
|
81
|
+
<td>=</td>
|
82
|
+
<td class='context-item-value'>{ :root => "/", :ping => "/ping", :status => "/status", :register => "/register" }</td>
|
83
|
+
<td> </td>
|
84
|
+
<td class='context-item-desc'>
|
85
|
+
|
86
|
+
Paths that comply with the messaging protocol determined by the SIF
|
87
|
+
Specification. These are <a href="../Siffer.html">Siffer</a> specific and
|
88
|
+
not spelled out in SIF Specification (rather implied).
|
89
|
+
</td>
|
90
|
+
</tr>
|
91
|
+
<tr class='top-aligned-row context-row'>
|
92
|
+
<td class='context-item-name'>HTTP_STATUS_CODES</td>
|
93
|
+
<td>=</td>
|
94
|
+
<td class='context-item-value'>{ 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Moved Temporarily', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported' }</td>
|
95
|
+
<td> </td>
|
96
|
+
<td class='context-item-desc'>
|
97
|
+
|
98
|
+
Every standard HTTP code mapped to the appropriate message. Stolen from
|
99
|
+
Mongrel.
|
100
|
+
</td>
|
101
|
+
</tr>
|
102
|
+
</table>
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
<div id='methods'>
|
106
|
+
<h2>Public instance methods</h2>
|
107
|
+
<div class='public-instance method' id='method-M000008'>
|
108
|
+
<a name='M000008'> </a>
|
109
|
+
<div class='synopsis'>
|
110
|
+
<span class='name'>check_path_against_protocol</span>
|
111
|
+
<span class='arguments'>()</span>
|
112
|
+
</div>
|
113
|
+
<div class='description'>
|
114
|
+
<p>
|
115
|
+
Validates the request object against the Acceptable Paths (<a
|
116
|
+
href="../Siffer.html">Siffer</a> spec) and that the request is a POST.
|
117
|
+
</p>
|
118
|
+
</div>
|
119
|
+
<div class='source'>
|
120
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
|
121
|
+
[show source]
|
122
|
+
</a>
|
123
|
+
<pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 38</span>
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_path_against_protocol</span>
39: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ACCEPTABLE_PATHS</span>.<span class="ruby-identifier">has_value?</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_info</span>
40: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownPath</span>
41: <span class="ruby-keyword kw">end</span>
42: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">post?</span>
43: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NonPostRequest</span>
44: <span class="ruby-keyword kw">end</span>
45: <span class="ruby-keyword kw">end</span></pre>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
<div class='public-instance method' id='method-M000011'>
|
127
|
+
<a name='M000011'> </a>
|
128
|
+
<div class='synopsis'>
|
129
|
+
<span class='name'>error_response</span>
|
130
|
+
<span class='arguments'>(category,code, desc = nil)</span>
|
131
|
+
</div>
|
132
|
+
<div class='description'>
|
133
|
+
<p>
|
134
|
+
Sets the @response to a <a
|
135
|
+
href="Messages/Ack.html">Siffer::Messages::Ack</a> message with the
|
136
|
+
appropriate Error category and code. Optional description is allowed and
|
137
|
+
placed in the ExtendedDesc node.
|
138
|
+
</p>
|
139
|
+
</div>
|
140
|
+
<div class='source'>
|
141
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
|
142
|
+
[show source]
|
143
|
+
</a>
|
144
|
+
<pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 74</span>
74: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error_response</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>, <span class="ruby-identifier">desc</span> = <span class="ruby-keyword kw">nil</span>)
75: <span class="ruby-identifier">error</span> = <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>,<span class="ruby-identifier">desc</span>)
76: <span class="ruby-identifier">ack</span> = <span class="ruby-constant">Ack</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">original</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">error</span>)
77: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ack</span>)
78: <span class="ruby-keyword kw">end</span></pre>
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
<div class='public-instance method' id='method-M000012'>
|
148
|
+
<a name='M000012'> </a>
|
149
|
+
<div class='synopsis'>
|
150
|
+
<span class='name'>no_response_available</span>
|
151
|
+
<span class='arguments'>()</span>
|
152
|
+
</div>
|
153
|
+
<div class='description'>
|
154
|
+
<p>
|
155
|
+
Determines if there is a response instance created. If not it creates one
|
156
|
+
with an Ack/Error describing not having anything to process.
|
157
|
+
</p>
|
158
|
+
</div>
|
159
|
+
<div class='source'>
|
160
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
|
161
|
+
[show source]
|
162
|
+
</a>
|
163
|
+
<pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 83</span>
83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no_response_available</span>
84: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">nil?</span>
85: <span class="ruby-identifier">err</span> = <span class="ruby-value str">"You are receiving this message because you failed to \nprovide enough information to respond to. This message \nwent completely through the messaging stack and\nfailed to instigate a response.\n \nPlease check the message you are sending and resend after \nany corrections.\n"</span>
86: <span class="ruby-operator">!</span><span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">1</span>,<span class="ruby-identifier">err</span>)
87: <span class="ruby-keyword kw">end</span>
88: <span class="ruby-keyword kw">end</span></pre>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
<div class='public-instance method' id='method-M000007'>
|
167
|
+
<a name='M000007'> </a>
|
168
|
+
<div class='synopsis'>
|
169
|
+
<span class='name'>request_failed_protocol?</span>
|
170
|
+
<span class='arguments'>()</span>
|
171
|
+
</div>
|
172
|
+
<div class='description'>
|
173
|
+
<p>
|
174
|
+
Checks the incoming request against the following protocol constraints:
|
175
|
+
</p>
|
176
|
+
<ul>
|
177
|
+
<li>Unknown PATH
|
178
|
+
|
179
|
+
</li>
|
180
|
+
<li>Non-POST request
|
181
|
+
|
182
|
+
</li>
|
183
|
+
</ul>
|
184
|
+
</div>
|
185
|
+
<div class='source'>
|
186
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
|
187
|
+
[show source]
|
188
|
+
</a>
|
189
|
+
<pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 16</span>
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_failed_protocol?</span>
17: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">get?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_info</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ACCEPTABLE_PATHS</span>[<span class="ruby-identifier">:root</span>]
18: <span class="ruby-identifier">root_response</span>
19: <span class="ruby-keyword kw">else</span>
20: <span class="ruby-keyword kw">begin</span>
21: <span class="ruby-identifier">check_path_against_protocol</span>
22: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownPath</span>
23: <span class="ruby-comment cmt"># TODO: Make a better Not Found response</span>
24: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">404</span>],
25: <span class="ruby-value">404</span>,
26: {<span class="ruby-value str">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"htm"</span>]})
27: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NonPostRequest</span>
28: <span class="ruby-comment cmt"># TODO: Make a better Method Not Allowed response</span>
29: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">405</span>],
30: <span class="ruby-value">405</span>,
31: {<span class="ruby-value str">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"htm"</span>]})
32: <span class="ruby-keyword kw">end</span>
33: <span class="ruby-keyword kw">end</span>
34: <span class="ruby-keyword kw">end</span></pre>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
<div class='public-instance method' id='method-M000013'>
|
193
|
+
<a name='M000013'> </a>
|
194
|
+
<div class='synopsis'>
|
195
|
+
<span class='name'>root_response</span>
|
196
|
+
<span class='arguments'>()</span>
|
197
|
+
</div>
|
198
|
+
<div class='source'>
|
199
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
|
200
|
+
[show source]
|
201
|
+
</a>
|
202
|
+
<pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 99</span>
 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">root_response</span>
100: <span class="ruby-identifier">html</span> = <span class="ruby-value str">"<html>\n <body>\n <h1>Siffer Endpoint</h1>\n <p>You have reached a Siffer component.</p>\n </body>\n</html>\n"</span>
101: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">html</span>,<span class="ruby-value">200</span>,{<span class="ruby-value str">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"htm"</span>]})
102: <span class="ruby-keyword kw">end</span></pre>
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
<div class='public-instance method' id='method-M000009'>
|
206
|
+
<a name='M000009'> </a>
|
207
|
+
<div class='synopsis'>
|
208
|
+
<span class='name'>uri</span>
|
209
|
+
<span class='arguments'>()</span>
|
210
|
+
</div>
|
211
|
+
<div class='description'>
|
212
|
+
<p>
|
213
|
+
Returns the URI of the component (<a href="Server.html">Server</a> or <a
|
214
|
+
href="Agent.html">Agent</a>)
|
215
|
+
</p>
|
216
|
+
</div>
|
217
|
+
<div class='source'>
|
218
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
|
219
|
+
[show source]
|
220
|
+
</a>
|
221
|
+
<pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 48</span>
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri</span>
49: <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">"http://#{host.gsub(/(http|https):\/\//,"")}:#{port}"</span>).<span class="ruby-identifier">to_s</span>
50: <span class="ruby-keyword kw">end</span></pre>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
<div class='public-instance method' id='method-M000010'>
|
225
|
+
<a name='M000010'> </a>
|
226
|
+
<div class='synopsis'>
|
227
|
+
<span class='name'>with_each_request</span>
|
228
|
+
<span class='arguments'>(env) {|if block_given?| ...}</span>
|
229
|
+
</div>
|
230
|
+
<div class='description'>
|
231
|
+
<pre>Provides a context for each request. Creates the @request, @response and
@original objects to use throughout the call.
Validates against Protocol as well as Messaging using #request_failed
predicates respectively.

Yields the block if provided to allow further processing.</pre>
|
232
|
+
<p>
|
233
|
+
Finishes by calling finish on the response object or returns the generic
|
234
|
+
</p>
|
235
|
+
<pre>response message.</pre>
|
236
|
+
</div>
|
237
|
+
<div class='source'>
|
238
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
|
239
|
+
[show source]
|
240
|
+
</a>
|
241
|
+
<pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 61</span>
61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_each_request</span>(<span class="ruby-identifier">env</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
62: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
63: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">request_failed_protocol?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">request_failed_messaging?</span>
64: <span class="ruby-identifier">using_message_from</span> <span class="ruby-ivar">@request</span> <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt"># possibly a concurrency issue here</span>
65: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
66: <span class="ruby-keyword kw">end</span>
67: <span class="ruby-keyword kw">end</span>
68: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">no_response_available</span>
69: <span class="ruby-keyword kw">end</span></pre>
|
242
|
+
</div>
|
243
|
+
</div>
|
244
|
+
</div>
|
302
245
|
</div>
|
303
246
|
</div>
|
304
247
|
</div>
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<div class="method-heading">
|
310
|
-
<a href="#M000009" class="method-signature">
|
311
|
-
<span class="method-name">uri</span><span class="method-args">()</span>
|
312
|
-
</a>
|
313
|
-
</div>
|
314
|
-
|
315
|
-
<div class="method-description">
|
316
|
-
<p>
|
317
|
-
Returns the URI of the component (<a href="Server.html">Server</a> or <a
|
318
|
-
href="Agent.html">Agent</a>)
|
319
|
-
</p>
|
320
|
-
<p><a class="source-toggle" href="#"
|
321
|
-
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
322
|
-
<div class="method-source-code" id="M000009-source">
|
323
|
-
<pre>
|
324
|
-
<span class="ruby-comment cmt"># File lib/protocol.rb, line 44</span>
|
325
|
-
44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri</span>
|
326
|
-
45: <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">"http://#{host}:#{port}"</span>).<span class="ruby-identifier">to_s</span>
|
327
|
-
46: <span class="ruby-keyword kw">end</span>
|
328
|
-
</pre>
|
329
|
-
</div>
|
330
|
-
</div>
|
331
|
-
</div>
|
332
|
-
|
333
|
-
<div id="method-M000010" class="method-detail">
|
334
|
-
<a name="M000010"></a>
|
335
|
-
|
336
|
-
<div class="method-heading">
|
337
|
-
<a href="#M000010" class="method-signature">
|
338
|
-
<span class="method-name">with_each_request</span><span class="method-args">(env) {|if block_given?| ...}</span>
|
339
|
-
</a>
|
340
|
-
</div>
|
341
|
-
|
342
|
-
<div class="method-description">
|
343
|
-
<pre>
|
344
|
-
Provides a context for each request. Creates the @request, @response and
|
345
|
-
@original objects to use throughout the call.
|
346
|
-
Validates against Protocol as well as Messaging using #request_failed
|
347
|
-
predicates respectively.
|
348
|
-
|
349
|
-
Yields the block if provided to allow further processing.
|
350
|
-
</pre>
|
351
|
-
<p>
|
352
|
-
Finishes by calling finish on the response object or returns the generic
|
353
|
-
</p>
|
354
|
-
<pre>
|
355
|
-
response message.
|
356
|
-
</pre>
|
357
|
-
<p><a class="source-toggle" href="#"
|
358
|
-
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
359
|
-
<div class="method-source-code" id="M000010-source">
|
360
|
-
<pre>
|
361
|
-
<span class="ruby-comment cmt"># File lib/protocol.rb, line 57</span>
|
362
|
-
57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_each_request</span>(<span class="ruby-identifier">env</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
363
|
-
58: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
|
364
|
-
59: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">request_failed_protocol?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">request_failed_messaging?</span>
|
365
|
-
60: <span class="ruby-identifier">using_message_from</span> <span class="ruby-ivar">@request</span> <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt"># possibly a concurrency issue here</span>
|
366
|
-
61: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
367
|
-
62: <span class="ruby-keyword kw">end</span>
|
368
|
-
63: <span class="ruby-keyword kw">end</span>
|
369
|
-
64: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">no_response_available</span>
|
370
|
-
65: <span class="ruby-keyword kw">end</span>
|
371
|
-
</pre>
|
372
|
-
</div>
|
373
|
-
</div>
|
374
|
-
</div>
|
375
|
-
|
376
|
-
|
248
|
+
<div id='footer-push'></div>
|
249
|
+
</div>
|
250
|
+
<div id='footer'>
|
251
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
377
252
|
</div>
|
378
|
-
|
379
|
-
|
380
|
-
</div>
|
381
|
-
|
382
|
-
|
383
|
-
<div id="validator-badges">
|
384
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
385
|
-
</div>
|
386
|
-
|
387
|
-
</body>
|
388
|
-
</html>
|
253
|
+
</body>
|
254
|
+
</html>
|