cft_smartcloud 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/cft_smartcloud +37 -0
- data/cft_smartcloud.gemspec +88 -7
- data/lib/smartcloud.rb +12 -2
- data/lib/smartcloud_logger.rb +1 -1
- data/rdoc/classes/ConfigTable/BoolItem.html +172 -0
- data/rdoc/classes/ConfigTable/ExecItem.html +252 -0
- data/rdoc/classes/ConfigTable/Item.html +308 -0
- data/rdoc/classes/ConfigTable/MetaConfigEnvironment.html +445 -0
- data/rdoc/classes/ConfigTable/PackageSelectionItem.html +188 -0
- data/rdoc/classes/ConfigTable/PathItem.html +148 -0
- data/rdoc/classes/ConfigTable/ProgramItem.html +148 -0
- data/rdoc/classes/ConfigTable/SelectItem.html +175 -0
- data/rdoc/classes/ConfigTable.html +724 -0
- data/rdoc/classes/Enumerable.html +157 -0
- data/rdoc/classes/Errno/ENOTEMPTY.html +111 -0
- data/rdoc/classes/Errno.html +111 -0
- data/rdoc/classes/File.html +197 -0
- data/rdoc/classes/FileOperations.html +600 -0
- data/rdoc/classes/Hash.html +163 -0
- data/rdoc/classes/HookScriptAPI.html +413 -0
- data/rdoc/classes/IBMSmartCloud.html +1484 -0
- data/rdoc/classes/Installer/Shebang.html +245 -0
- data/rdoc/classes/Installer.html +1660 -0
- data/rdoc/classes/MIME/InvalidContentType.html +119 -0
- data/rdoc/classes/MIME/Type.html +1366 -0
- data/rdoc/classes/MIME/Types.html +643 -0
- data/rdoc/classes/MIME.html +124 -0
- data/rdoc/classes/MockSmartCloud.html +376 -0
- data/rdoc/classes/Net/HTTP.html +164 -0
- data/rdoc/classes/Net.html +122 -0
- data/rdoc/classes/RestClient/AbstractResponse.html +417 -0
- data/rdoc/classes/RestClient/Exception.html +305 -0
- data/rdoc/classes/RestClient/ExceptionWithResponse.html +119 -0
- data/rdoc/classes/RestClient/Exceptions.html +130 -0
- data/rdoc/classes/RestClient/MaxRedirectsReached.html +113 -0
- data/rdoc/classes/RestClient/Payload/Base.html +422 -0
- data/rdoc/classes/RestClient/Payload/Multipart.html +372 -0
- data/rdoc/classes/RestClient/Payload/Streamed.html +191 -0
- data/rdoc/classes/RestClient/Payload/UrlEncoded.html +202 -0
- data/rdoc/classes/RestClient/Payload.html +192 -0
- data/rdoc/classes/RestClient/RawResponse.html +236 -0
- data/rdoc/classes/RestClient/Redirect.html +168 -0
- data/rdoc/classes/RestClient/Request.html +950 -0
- data/rdoc/classes/RestClient/RequestFailed.html +178 -0
- data/rdoc/classes/RestClient/Resource.html +607 -0
- data/rdoc/classes/RestClient/Response.html +208 -0
- data/rdoc/classes/RestClient/ResponseForException.html +152 -0
- data/rdoc/classes/RestClient/SSLCertificateNotVerified.html +149 -0
- data/rdoc/classes/RestClient/ServerBrokeConnection.html +157 -0
- data/rdoc/classes/RestClient.html +737 -0
- data/rdoc/classes/SetupError.html +111 -0
- data/rdoc/classes/SmartcloudLogger.html +162 -0
- data/rdoc/classes/TestMIME.html +109 -0
- data/rdoc/classes/ToplevelInstaller.html +987 -0
- data/rdoc/classes/ToplevelInstallerMulti.html +593 -0
- data/rdoc/classes/XmlSimple/Cache.html +372 -0
- data/rdoc/classes/XmlSimple.html +475 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_rdoc.html +198 -0
- data/rdoc/files/lib/hash_fix_rb.html +115 -0
- data/rdoc/files/lib/mime-types-1_16/lib/mime/types_rb.html +107 -0
- data/rdoc/files/lib/mime-types-1_16/setup_rb.html +157 -0
- data/rdoc/files/lib/mime-types-1_16/test/test_mime_type_rb.html +109 -0
- data/rdoc/files/lib/mime-types-1_16/test/test_mime_types_rb.html +109 -0
- data/rdoc/files/lib/mock_smartcloud_rb.html +115 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/rest-client_rb.html +107 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/rest_client_rb.html +108 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/abstract_response_rb.html +108 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/exceptions_rb.html +101 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/net_http_ext_rb.html +113 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/payload_rb.html +110 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/raw_response_rb.html +101 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/request_rb.html +110 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/resource_rb.html +101 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient/response_rb.html +101 -0
- data/rdoc/files/lib/rest-client-1_6_3/lib/restclient_rb.html +111 -0
- data/rdoc/files/lib/restclient_fix_rb.html +115 -0
- data/rdoc/files/lib/smartcloud_logger_rb.html +115 -0
- data/rdoc/files/lib/smartcloud_rb.html +143 -0
- data/rdoc/files/lib/xml-simple-1_0_12/lib/xmlsimple_rb.html +124 -0
- data/rdoc/fr_class_index.html +79 -0
- data/rdoc/fr_file_index.html +48 -0
- data/rdoc/fr_method_index.html +441 -0
- data/rdoc/index.html +26 -0
- data/rdoc/rdoc-style.css +208 -0
- metadata +90 -6
@@ -0,0 +1,950 @@
|
|
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: RestClient::Request</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">RestClient::Request</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/rest-client-1_6_3/lib/restclient/exceptions_rb.html">
|
59
|
+
lib/rest-client-1.6.3/lib/restclient/exceptions.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../../files/lib/rest-client-1_6_3/lib/restclient/request_rb.html">
|
63
|
+
lib/rest-client-1.6.3/lib/restclient/request.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
|
69
|
+
<tr class="top-aligned-row">
|
70
|
+
<td><strong>Parent:</strong></td>
|
71
|
+
<td>
|
72
|
+
Object
|
73
|
+
</td>
|
74
|
+
</tr>
|
75
|
+
</table>
|
76
|
+
</div>
|
77
|
+
<!-- banner header -->
|
78
|
+
|
79
|
+
<div id="bodyContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<div id="contextContent">
|
84
|
+
|
85
|
+
<div id="description">
|
86
|
+
<p>
|
87
|
+
This class is used internally by <a
|
88
|
+
href="../RestClient.html">RestClient</a> to send the request, but you can
|
89
|
+
also call it directly if you‘d like to use a method not supported by
|
90
|
+
the main API. For example:
|
91
|
+
</p>
|
92
|
+
<pre>
|
93
|
+
RestClient::Request.execute(:method => :head, :url => 'http://example.com')
|
94
|
+
</pre>
|
95
|
+
<p>
|
96
|
+
Mandatory parameters:
|
97
|
+
</p>
|
98
|
+
<ul>
|
99
|
+
<li>:method
|
100
|
+
|
101
|
+
</li>
|
102
|
+
<li>:url
|
103
|
+
|
104
|
+
</li>
|
105
|
+
</ul>
|
106
|
+
<p>
|
107
|
+
Optional parameters (have a look at ssl and/or uri for some explanations):
|
108
|
+
</p>
|
109
|
+
<ul>
|
110
|
+
<li>:headers a hash containing the request headers
|
111
|
+
|
112
|
+
</li>
|
113
|
+
<li>:cookies will replace possible cookies in the :headers
|
114
|
+
|
115
|
+
</li>
|
116
|
+
<li>:user and :password for basic auth, will be replaced by a user/password
|
117
|
+
available in the :url
|
118
|
+
|
119
|
+
</li>
|
120
|
+
<li>:block_response call the provided block with the HTTPResponse as parameter
|
121
|
+
|
122
|
+
</li>
|
123
|
+
<li>:raw_response return a low-level <a href="RawResponse.html">RawResponse</a>
|
124
|
+
instead of a <a href="Response.html">Response</a>
|
125
|
+
|
126
|
+
</li>
|
127
|
+
<li>:max_redirects maximum number of redirections (default to 10)
|
128
|
+
|
129
|
+
</li>
|
130
|
+
<li>:verify_ssl enable ssl verification, possible values are constants from
|
131
|
+
OpenSSL::SSL
|
132
|
+
|
133
|
+
</li>
|
134
|
+
<li>:timeout and :open_timeout
|
135
|
+
|
136
|
+
</li>
|
137
|
+
<li>:ssl_client_cert, :ssl_client_key, :ssl_ca_file
|
138
|
+
|
139
|
+
</li>
|
140
|
+
</ul>
|
141
|
+
|
142
|
+
</div>
|
143
|
+
|
144
|
+
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<div id="method-list">
|
148
|
+
<h3 class="section-bar">Methods</h3>
|
149
|
+
|
150
|
+
<div class="name-list">
|
151
|
+
<a href="#M000353">decode</a>
|
152
|
+
<a href="#M000357">default_headers</a>
|
153
|
+
<a href="#M000341">execute</a>
|
154
|
+
<a href="#M000339">execute</a>
|
155
|
+
<a href="#M000351">fetch_body</a>
|
156
|
+
<a href="#M000354">log_request</a>
|
157
|
+
<a href="#M000355">log_response</a>
|
158
|
+
<a href="#M000343">make_headers</a>
|
159
|
+
<a href="#M000344">net_http_class</a>
|
160
|
+
<a href="#M000345">net_http_request_class</a>
|
161
|
+
<a href="#M000340">new</a>
|
162
|
+
<a href="#M000346">parse_url</a>
|
163
|
+
<a href="#M000347">parse_url_with_auth</a>
|
164
|
+
<a href="#M000342">process_get_params</a>
|
165
|
+
<a href="#M000348">process_payload</a>
|
166
|
+
<a href="#M000352">process_result</a>
|
167
|
+
<a href="#M000350">setup_credentials</a>
|
168
|
+
<a href="#M000356">stringify_headers</a>
|
169
|
+
<a href="#M000349">transmit</a>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
|
176
|
+
<!-- if includes -->
|
177
|
+
|
178
|
+
<div id="section">
|
179
|
+
|
180
|
+
|
181
|
+
<div id="constants-list">
|
182
|
+
<h3 class="section-bar">Constants</h3>
|
183
|
+
|
184
|
+
<div class="name-list">
|
185
|
+
<table summary="Constants">
|
186
|
+
<tr class="top-aligned-row context-row">
|
187
|
+
<td class="context-item-name">Redirect</td>
|
188
|
+
<td>=</td>
|
189
|
+
<td class="context-item-value">RestClient::Redirect</td>
|
190
|
+
</tr>
|
191
|
+
<tr class="top-aligned-row context-row">
|
192
|
+
<td class="context-item-name">Unauthorized</td>
|
193
|
+
<td>=</td>
|
194
|
+
<td class="context-item-value">RestClient::Unauthorized</td>
|
195
|
+
</tr>
|
196
|
+
<tr class="top-aligned-row context-row">
|
197
|
+
<td class="context-item-name">RequestFailed</td>
|
198
|
+
<td>=</td>
|
199
|
+
<td class="context-item-value">RestClient::RequestFailed</td>
|
200
|
+
</tr>
|
201
|
+
</table>
|
202
|
+
</div>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<div id="attribute-list">
|
208
|
+
<h3 class="section-bar">Attributes</h3>
|
209
|
+
|
210
|
+
<div class="name-list">
|
211
|
+
<table>
|
212
|
+
<tr class="top-aligned-row context-row">
|
213
|
+
<td class="context-item-name">args</td>
|
214
|
+
<td class="context-item-value"> [R] </td>
|
215
|
+
<td class="context-item-desc"></td>
|
216
|
+
</tr>
|
217
|
+
<tr class="top-aligned-row context-row">
|
218
|
+
<td class="context-item-name">cookies</td>
|
219
|
+
<td class="context-item-value"> [R] </td>
|
220
|
+
<td class="context-item-desc"></td>
|
221
|
+
</tr>
|
222
|
+
<tr class="top-aligned-row context-row">
|
223
|
+
<td class="context-item-name">headers</td>
|
224
|
+
<td class="context-item-value"> [R] </td>
|
225
|
+
<td class="context-item-desc"></td>
|
226
|
+
</tr>
|
227
|
+
<tr class="top-aligned-row context-row">
|
228
|
+
<td class="context-item-name">max_redirects</td>
|
229
|
+
<td class="context-item-value"> [R] </td>
|
230
|
+
<td class="context-item-desc"></td>
|
231
|
+
</tr>
|
232
|
+
<tr class="top-aligned-row context-row">
|
233
|
+
<td class="context-item-name">method</td>
|
234
|
+
<td class="context-item-value"> [R] </td>
|
235
|
+
<td class="context-item-desc"></td>
|
236
|
+
</tr>
|
237
|
+
<tr class="top-aligned-row context-row">
|
238
|
+
<td class="context-item-name">open_timeout</td>
|
239
|
+
<td class="context-item-value"> [R] </td>
|
240
|
+
<td class="context-item-desc"></td>
|
241
|
+
</tr>
|
242
|
+
<tr class="top-aligned-row context-row">
|
243
|
+
<td class="context-item-name">password</td>
|
244
|
+
<td class="context-item-value"> [R] </td>
|
245
|
+
<td class="context-item-desc"></td>
|
246
|
+
</tr>
|
247
|
+
<tr class="top-aligned-row context-row">
|
248
|
+
<td class="context-item-name">payload</td>
|
249
|
+
<td class="context-item-value"> [R] </td>
|
250
|
+
<td class="context-item-desc"></td>
|
251
|
+
</tr>
|
252
|
+
<tr class="top-aligned-row context-row">
|
253
|
+
<td class="context-item-name">processed_headers</td>
|
254
|
+
<td class="context-item-value"> [R] </td>
|
255
|
+
<td class="context-item-desc"></td>
|
256
|
+
</tr>
|
257
|
+
<tr class="top-aligned-row context-row">
|
258
|
+
<td class="context-item-name">raw_response</td>
|
259
|
+
<td class="context-item-value"> [R] </td>
|
260
|
+
<td class="context-item-desc"></td>
|
261
|
+
</tr>
|
262
|
+
<tr class="top-aligned-row context-row">
|
263
|
+
<td class="context-item-name">ssl_ca_file</td>
|
264
|
+
<td class="context-item-value"> [R] </td>
|
265
|
+
<td class="context-item-desc"></td>
|
266
|
+
</tr>
|
267
|
+
<tr class="top-aligned-row context-row">
|
268
|
+
<td class="context-item-name">ssl_client_cert</td>
|
269
|
+
<td class="context-item-value"> [R] </td>
|
270
|
+
<td class="context-item-desc"></td>
|
271
|
+
</tr>
|
272
|
+
<tr class="top-aligned-row context-row">
|
273
|
+
<td class="context-item-name">ssl_client_key</td>
|
274
|
+
<td class="context-item-value"> [R] </td>
|
275
|
+
<td class="context-item-desc"></td>
|
276
|
+
</tr>
|
277
|
+
<tr class="top-aligned-row context-row">
|
278
|
+
<td class="context-item-name">timeout</td>
|
279
|
+
<td class="context-item-value"> [R] </td>
|
280
|
+
<td class="context-item-desc"></td>
|
281
|
+
</tr>
|
282
|
+
<tr class="top-aligned-row context-row">
|
283
|
+
<td class="context-item-name">url</td>
|
284
|
+
<td class="context-item-value"> [R] </td>
|
285
|
+
<td class="context-item-desc"></td>
|
286
|
+
</tr>
|
287
|
+
<tr class="top-aligned-row context-row">
|
288
|
+
<td class="context-item-name">user</td>
|
289
|
+
<td class="context-item-value"> [R] </td>
|
290
|
+
<td class="context-item-desc"></td>
|
291
|
+
</tr>
|
292
|
+
<tr class="top-aligned-row context-row">
|
293
|
+
<td class="context-item-name">verify_ssl</td>
|
294
|
+
<td class="context-item-value"> [R] </td>
|
295
|
+
<td class="context-item-desc"></td>
|
296
|
+
</tr>
|
297
|
+
</table>
|
298
|
+
</div>
|
299
|
+
</div>
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
<!-- if method_list -->
|
304
|
+
<div id="methods">
|
305
|
+
<h3 class="section-bar">Public Class methods</h3>
|
306
|
+
|
307
|
+
<div id="method-M000353" class="method-detail">
|
308
|
+
<a name="M000353"></a>
|
309
|
+
|
310
|
+
<div class="method-heading">
|
311
|
+
<a href="#M000353" class="method-signature">
|
312
|
+
<span class="method-name">decode</span><span class="method-args">(content_encoding, body)</span>
|
313
|
+
</a>
|
314
|
+
</div>
|
315
|
+
|
316
|
+
<div class="method-description">
|
317
|
+
<p><a class="source-toggle" href="#"
|
318
|
+
onclick="toggleCode('M000353-source');return false;">[Source]</a></p>
|
319
|
+
<div class="method-source-code" id="M000353-source">
|
320
|
+
<pre>
|
321
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 233</span>
|
322
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decode</span> <span class="ruby-identifier">content_encoding</span>, <span class="ruby-identifier">body</span>
|
323
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">body</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">empty?</span>
|
324
|
+
<span class="ruby-identifier">body</span>
|
325
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">content_encoding</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'gzip'</span>
|
326
|
+
<span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipReader</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">body</span>)).<span class="ruby-identifier">read</span>
|
327
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">content_encoding</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'deflate'</span>
|
328
|
+
<span class="ruby-keyword kw">begin</span>
|
329
|
+
<span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Inflate</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">inflate</span> <span class="ruby-identifier">body</span>
|
330
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">DataError</span>
|
331
|
+
<span class="ruby-comment cmt"># No luck with Zlib decompression. Let's try with raw deflate,</span>
|
332
|
+
<span class="ruby-comment cmt"># like some broken web servers do.</span>
|
333
|
+
<span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">Inflate</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">-</span><span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">MAX_WBITS</span>).<span class="ruby-identifier">inflate</span> <span class="ruby-identifier">body</span>
|
334
|
+
<span class="ruby-keyword kw">end</span>
|
335
|
+
<span class="ruby-keyword kw">else</span>
|
336
|
+
<span class="ruby-identifier">body</span>
|
337
|
+
<span class="ruby-keyword kw">end</span>
|
338
|
+
<span class="ruby-keyword kw">end</span>
|
339
|
+
</pre>
|
340
|
+
</div>
|
341
|
+
</div>
|
342
|
+
</div>
|
343
|
+
|
344
|
+
<div id="method-M000339" class="method-detail">
|
345
|
+
<a name="M000339"></a>
|
346
|
+
|
347
|
+
<div class="method-heading">
|
348
|
+
<a href="#M000339" class="method-signature">
|
349
|
+
<span class="method-name">execute</span><span class="method-args">(args, & block)</span>
|
350
|
+
</a>
|
351
|
+
</div>
|
352
|
+
|
353
|
+
<div class="method-description">
|
354
|
+
<p><a class="source-toggle" href="#"
|
355
|
+
onclick="toggleCode('M000339-source');return false;">[Source]</a></p>
|
356
|
+
<div class="method-source-code" id="M000339-source">
|
357
|
+
<pre>
|
358
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 32</span>
|
359
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>)
|
360
|
+
<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>).<span class="ruby-identifier">execute</span>(<span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>)
|
361
|
+
<span class="ruby-keyword kw">end</span>
|
362
|
+
</pre>
|
363
|
+
</div>
|
364
|
+
</div>
|
365
|
+
</div>
|
366
|
+
|
367
|
+
<div id="method-M000340" class="method-detail">
|
368
|
+
<a name="M000340"></a>
|
369
|
+
|
370
|
+
<div class="method-heading">
|
371
|
+
<a href="#M000340" class="method-signature">
|
372
|
+
<span class="method-name">new</span><span class="method-args">(args)</span>
|
373
|
+
</a>
|
374
|
+
</div>
|
375
|
+
|
376
|
+
<div class="method-description">
|
377
|
+
<p><a class="source-toggle" href="#"
|
378
|
+
onclick="toggleCode('M000340-source');return false;">[Source]</a></p>
|
379
|
+
<div class="method-source-code" id="M000340-source">
|
380
|
+
<pre>
|
381
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 36</span>
|
382
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-identifier">args</span>
|
383
|
+
<span class="ruby-ivar">@method</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:method</span>] <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"must pass :method"</span>
|
384
|
+
<span class="ruby-ivar">@headers</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:headers</span>] <span class="ruby-operator">||</span> {}
|
385
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:url</span>]
|
386
|
+
<span class="ruby-ivar">@url</span> = <span class="ruby-identifier">process_get_params</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:url</span>], <span class="ruby-identifier">headers</span>)
|
387
|
+
<span class="ruby-keyword kw">else</span>
|
388
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"must pass :url"</span>
|
389
|
+
<span class="ruby-keyword kw">end</span>
|
390
|
+
<span class="ruby-ivar">@cookies</span> = <span class="ruby-ivar">@headers</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:cookies</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:cookies</span>] <span class="ruby-operator">||</span> {}
|
391
|
+
<span class="ruby-ivar">@payload</span> = <span class="ruby-constant">Payload</span>.<span class="ruby-identifier">generate</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:payload</span>])
|
392
|
+
<span class="ruby-ivar">@user</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:user</span>]
|
393
|
+
<span class="ruby-ivar">@password</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:password</span>]
|
394
|
+
<span class="ruby-ivar">@timeout</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:timeout</span>]
|
395
|
+
<span class="ruby-ivar">@open_timeout</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:open_timeout</span>]
|
396
|
+
<span class="ruby-ivar">@block_response</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:block_response</span>]
|
397
|
+
<span class="ruby-ivar">@raw_response</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:raw_response</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
|
398
|
+
<span class="ruby-ivar">@verify_ssl</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:verify_ssl</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
|
399
|
+
<span class="ruby-ivar">@ssl_client_cert</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:ssl_client_cert</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
|
400
|
+
<span class="ruby-ivar">@ssl_client_key</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:ssl_client_key</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
|
401
|
+
<span class="ruby-ivar">@ssl_ca_file</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:ssl_ca_file</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
|
402
|
+
<span class="ruby-ivar">@tf</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># If you are a raw request, this is your tempfile</span>
|
403
|
+
<span class="ruby-ivar">@max_redirects</span> = <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:max_redirects</span>] <span class="ruby-operator">||</span> <span class="ruby-value">10</span>
|
404
|
+
<span class="ruby-ivar">@processed_headers</span> = <span class="ruby-identifier">make_headers</span> <span class="ruby-identifier">headers</span>
|
405
|
+
<span class="ruby-ivar">@args</span> = <span class="ruby-identifier">args</span>
|
406
|
+
<span class="ruby-keyword kw">end</span>
|
407
|
+
</pre>
|
408
|
+
</div>
|
409
|
+
</div>
|
410
|
+
</div>
|
411
|
+
|
412
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
413
|
+
|
414
|
+
<div id="method-M000357" class="method-detail">
|
415
|
+
<a name="M000357"></a>
|
416
|
+
|
417
|
+
<div class="method-heading">
|
418
|
+
<a href="#M000357" class="method-signature">
|
419
|
+
<span class="method-name">default_headers</span><span class="method-args">()</span>
|
420
|
+
</a>
|
421
|
+
</div>
|
422
|
+
|
423
|
+
<div class="method-description">
|
424
|
+
<p><a class="source-toggle" href="#"
|
425
|
+
onclick="toggleCode('M000357-source');return false;">[Source]</a></p>
|
426
|
+
<div class="method-source-code" id="M000357-source">
|
427
|
+
<pre>
|
428
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 292</span>
|
429
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default_headers</span>
|
430
|
+
{<span class="ruby-identifier">:accept</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'*/*; q=0.5, application/xml'</span>, <span class="ruby-identifier">:accept_encoding</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'gzip, deflate'</span>}
|
431
|
+
<span class="ruby-keyword kw">end</span>
|
432
|
+
</pre>
|
433
|
+
</div>
|
434
|
+
</div>
|
435
|
+
</div>
|
436
|
+
|
437
|
+
<div id="method-M000341" class="method-detail">
|
438
|
+
<a name="M000341"></a>
|
439
|
+
|
440
|
+
<div class="method-heading">
|
441
|
+
<a href="#M000341" class="method-signature">
|
442
|
+
<span class="method-name">execute</span><span class="method-args">(& block)</span>
|
443
|
+
</a>
|
444
|
+
</div>
|
445
|
+
|
446
|
+
<div class="method-description">
|
447
|
+
<p><a class="source-toggle" href="#"
|
448
|
+
onclick="toggleCode('M000341-source');return false;">[Source]</a></p>
|
449
|
+
<div class="method-source-code" id="M000341-source">
|
450
|
+
<pre>
|
451
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 62</span>
|
452
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span> <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>
|
453
|
+
<span class="ruby-identifier">uri</span> = <span class="ruby-identifier">parse_url_with_auth</span>(<span class="ruby-identifier">url</span>)
|
454
|
+
<span class="ruby-identifier">transmit</span> <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">net_http_request_class</span>(<span class="ruby-identifier">method</span>).<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">request_uri</span>, <span class="ruby-identifier">processed_headers</span>), <span class="ruby-identifier">payload</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>
|
455
|
+
<span class="ruby-keyword kw">end</span>
|
456
|
+
</pre>
|
457
|
+
</div>
|
458
|
+
</div>
|
459
|
+
</div>
|
460
|
+
|
461
|
+
<div id="method-M000351" class="method-detail">
|
462
|
+
<a name="M000351"></a>
|
463
|
+
|
464
|
+
<div class="method-heading">
|
465
|
+
<a href="#M000351" class="method-signature">
|
466
|
+
<span class="method-name">fetch_body</span><span class="method-args">(http_response)</span>
|
467
|
+
</a>
|
468
|
+
</div>
|
469
|
+
|
470
|
+
<div class="method-description">
|
471
|
+
<p><a class="source-toggle" href="#"
|
472
|
+
onclick="toggleCode('M000351-source');return false;">[Source]</a></p>
|
473
|
+
<div class="method-source-code" id="M000351-source">
|
474
|
+
<pre>
|
475
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 189</span>
|
476
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">fetch_body</span>(<span class="ruby-identifier">http_response</span>)
|
477
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@raw_response</span>
|
478
|
+
<span class="ruby-comment cmt"># Taken from Chef, which as in turn...</span>
|
479
|
+
<span class="ruby-comment cmt"># Stolen from http://www.ruby-forum.com/topic/166423</span>
|
480
|
+
<span class="ruby-comment cmt"># Kudos to _why!</span>
|
481
|
+
<span class="ruby-ivar">@tf</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"rest-client"</span>)
|
482
|
+
<span class="ruby-identifier">size</span>, <span class="ruby-identifier">total</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">http_response</span>.<span class="ruby-identifier">header</span>[<span class="ruby-value str">'Content-Length'</span>].<span class="ruby-identifier">to_i</span>
|
483
|
+
<span class="ruby-identifier">http_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">chunk</span><span class="ruby-operator">|</span>
|
484
|
+
<span class="ruby-ivar">@tf</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">chunk</span>
|
485
|
+
<span class="ruby-identifier">size</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">chunk</span>.<span class="ruby-identifier">size</span>
|
486
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span>
|
487
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
488
|
+
<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{@method} #{@url} done (0 length file\n)"</span>
|
489
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">total</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
490
|
+
<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{@method} #{@url} (zero content length)\n"</span>
|
491
|
+
<span class="ruby-keyword kw">else</span>
|
492
|
+
<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{@method} #{@url} %d%% done (%d of %d)\n"</span> <span class="ruby-operator">%</span> [(<span class="ruby-identifier">size</span> <span class="ruby-operator">*</span> <span class="ruby-value">100</span>) <span class="ruby-operator">/</span> <span class="ruby-identifier">total</span>, <span class="ruby-identifier">size</span>, <span class="ruby-identifier">total</span>]
|
493
|
+
<span class="ruby-keyword kw">end</span>
|
494
|
+
<span class="ruby-keyword kw">end</span>
|
495
|
+
<span class="ruby-keyword kw">end</span>
|
496
|
+
<span class="ruby-ivar">@tf</span>.<span class="ruby-identifier">close</span>
|
497
|
+
<span class="ruby-ivar">@tf</span>
|
498
|
+
<span class="ruby-keyword kw">else</span>
|
499
|
+
<span class="ruby-identifier">http_response</span>.<span class="ruby-identifier">read_body</span>
|
500
|
+
<span class="ruby-keyword kw">end</span>
|
501
|
+
<span class="ruby-identifier">http_response</span>
|
502
|
+
<span class="ruby-keyword kw">end</span>
|
503
|
+
</pre>
|
504
|
+
</div>
|
505
|
+
</div>
|
506
|
+
</div>
|
507
|
+
|
508
|
+
<div id="method-M000354" class="method-detail">
|
509
|
+
<a name="M000354"></a>
|
510
|
+
|
511
|
+
<div class="method-heading">
|
512
|
+
<a href="#M000354" class="method-signature">
|
513
|
+
<span class="method-name">log_request</span><span class="method-args">()</span>
|
514
|
+
</a>
|
515
|
+
</div>
|
516
|
+
|
517
|
+
<div class="method-description">
|
518
|
+
<p><a class="source-toggle" href="#"
|
519
|
+
onclick="toggleCode('M000354-source');return false;">[Source]</a></p>
|
520
|
+
<div class="method-source-code" id="M000354-source">
|
521
|
+
<pre>
|
522
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 251</span>
|
523
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log_request</span>
|
524
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span>
|
525
|
+
<span class="ruby-identifier">out</span> = []
|
526
|
+
<span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"RestClient.#{method} #{url.inspect}"</span>
|
527
|
+
<span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">payload</span>.<span class="ruby-identifier">short_inspect</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">payload</span>
|
528
|
+
<span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">processed_headers</span>.<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>)<span class="ruby-operator">|</span> [<span class="ruby-identifier">k</span>.<span class="ruby-identifier">inspect</span>, <span class="ruby-identifier">v</span>.<span class="ruby-identifier">inspect</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">"=>"</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">", "</span>)
|
529
|
+
<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">out</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">', '</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">"\n"</span>
|
530
|
+
<span class="ruby-keyword kw">end</span>
|
531
|
+
<span class="ruby-keyword kw">end</span>
|
532
|
+
</pre>
|
533
|
+
</div>
|
534
|
+
</div>
|
535
|
+
</div>
|
536
|
+
|
537
|
+
<div id="method-M000355" class="method-detail">
|
538
|
+
<a name="M000355"></a>
|
539
|
+
|
540
|
+
<div class="method-heading">
|
541
|
+
<a href="#M000355" class="method-signature">
|
542
|
+
<span class="method-name">log_response</span><span class="method-args">(res)</span>
|
543
|
+
</a>
|
544
|
+
</div>
|
545
|
+
|
546
|
+
<div class="method-description">
|
547
|
+
<p><a class="source-toggle" href="#"
|
548
|
+
onclick="toggleCode('M000355-source');return false;">[Source]</a></p>
|
549
|
+
<div class="method-source-code" id="M000355-source">
|
550
|
+
<pre>
|
551
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 261</span>
|
552
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log_response</span> <span class="ruby-identifier">res</span>
|
553
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span>
|
554
|
+
<span class="ruby-identifier">size</span> = <span class="ruby-ivar">@raw_response</span> <span class="ruby-operator">?</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-ivar">@tf</span>.<span class="ruby-identifier">path</span>) <span class="ruby-operator">:</span> (<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">size</span>)
|
555
|
+
<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">log</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"# => #{res.code} #{res.class.to_s.gsub(/^Net::HTTP/, '')} | #{(res['Content-type'] || '').gsub(/;.*$/, '')} #{size} bytes\n"</span>
|
556
|
+
<span class="ruby-keyword kw">end</span>
|
557
|
+
<span class="ruby-keyword kw">end</span>
|
558
|
+
</pre>
|
559
|
+
</div>
|
560
|
+
</div>
|
561
|
+
</div>
|
562
|
+
|
563
|
+
<div id="method-M000343" class="method-detail">
|
564
|
+
<a name="M000343"></a>
|
565
|
+
|
566
|
+
<div class="method-heading">
|
567
|
+
<a href="#M000343" class="method-signature">
|
568
|
+
<span class="method-name">make_headers</span><span class="method-args">(user_headers)</span>
|
569
|
+
</a>
|
570
|
+
</div>
|
571
|
+
|
572
|
+
<div class="method-description">
|
573
|
+
<p><a class="source-toggle" href="#"
|
574
|
+
onclick="toggleCode('M000343-source');return false;">[Source]</a></p>
|
575
|
+
<div class="method-source-code" id="M000343-source">
|
576
|
+
<pre>
|
577
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 90</span>
|
578
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">make_headers</span> <span class="ruby-identifier">user_headers</span>
|
579
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@cookies</span>.<span class="ruby-identifier">empty?</span>
|
580
|
+
<span class="ruby-identifier">user_headers</span>[<span class="ruby-identifier">:cookie</span>] = <span class="ruby-ivar">@cookies</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>)<span class="ruby-operator">|</span> <span class="ruby-node">"#{key.to_s}=#{CGI::unescape(val)}"</span> }.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">';'</span>)
|
581
|
+
<span class="ruby-keyword kw">end</span>
|
582
|
+
<span class="ruby-identifier">headers</span> = <span class="ruby-identifier">stringify_headers</span>(<span class="ruby-identifier">default_headers</span>).<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">stringify_headers</span>(<span class="ruby-identifier">user_headers</span>))
|
583
|
+
<span class="ruby-identifier">headers</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-ivar">@payload</span>.<span class="ruby-identifier">headers</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@payload</span>
|
584
|
+
<span class="ruby-identifier">headers</span>
|
585
|
+
<span class="ruby-keyword kw">end</span>
|
586
|
+
</pre>
|
587
|
+
</div>
|
588
|
+
</div>
|
589
|
+
</div>
|
590
|
+
|
591
|
+
<div id="method-M000344" class="method-detail">
|
592
|
+
<a name="M000344"></a>
|
593
|
+
|
594
|
+
<div class="method-heading">
|
595
|
+
<a href="#M000344" class="method-signature">
|
596
|
+
<span class="method-name">net_http_class</span><span class="method-args">()</span>
|
597
|
+
</a>
|
598
|
+
</div>
|
599
|
+
|
600
|
+
<div class="method-description">
|
601
|
+
<p><a class="source-toggle" href="#"
|
602
|
+
onclick="toggleCode('M000344-source');return false;">[Source]</a></p>
|
603
|
+
<div class="method-source-code" id="M000344-source">
|
604
|
+
<pre>
|
605
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 99</span>
|
606
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">net_http_class</span>
|
607
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">proxy</span>
|
608
|
+
<span class="ruby-identifier">proxy_uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">proxy</span>)
|
609
|
+
<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">Proxy</span>(<span class="ruby-identifier">proxy_uri</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">proxy_uri</span>.<span class="ruby-identifier">port</span>, <span class="ruby-identifier">proxy_uri</span>.<span class="ruby-identifier">user</span>, <span class="ruby-identifier">proxy_uri</span>.<span class="ruby-identifier">password</span>)
|
610
|
+
<span class="ruby-keyword kw">else</span>
|
611
|
+
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>
|
612
|
+
<span class="ruby-keyword kw">end</span>
|
613
|
+
<span class="ruby-keyword kw">end</span>
|
614
|
+
</pre>
|
615
|
+
</div>
|
616
|
+
</div>
|
617
|
+
</div>
|
618
|
+
|
619
|
+
<div id="method-M000345" class="method-detail">
|
620
|
+
<a name="M000345"></a>
|
621
|
+
|
622
|
+
<div class="method-heading">
|
623
|
+
<a href="#M000345" class="method-signature">
|
624
|
+
<span class="method-name">net_http_request_class</span><span class="method-args">(method)</span>
|
625
|
+
</a>
|
626
|
+
</div>
|
627
|
+
|
628
|
+
<div class="method-description">
|
629
|
+
<p><a class="source-toggle" href="#"
|
630
|
+
onclick="toggleCode('M000345-source');return false;">[Source]</a></p>
|
631
|
+
<div class="method-source-code" id="M000345-source">
|
632
|
+
<pre>
|
633
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 108</span>
|
634
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">net_http_request_class</span>(<span class="ruby-identifier">method</span>)
|
635
|
+
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">method</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">capitalize</span>)
|
636
|
+
<span class="ruby-keyword kw">end</span>
|
637
|
+
</pre>
|
638
|
+
</div>
|
639
|
+
</div>
|
640
|
+
</div>
|
641
|
+
|
642
|
+
<div id="method-M000346" class="method-detail">
|
643
|
+
<a name="M000346"></a>
|
644
|
+
|
645
|
+
<div class="method-heading">
|
646
|
+
<a href="#M000346" class="method-signature">
|
647
|
+
<span class="method-name">parse_url</span><span class="method-args">(url)</span>
|
648
|
+
</a>
|
649
|
+
</div>
|
650
|
+
|
651
|
+
<div class="method-description">
|
652
|
+
<p><a class="source-toggle" href="#"
|
653
|
+
onclick="toggleCode('M000346-source');return false;">[Source]</a></p>
|
654
|
+
<div class="method-source-code" id="M000346-source">
|
655
|
+
<pre>
|
656
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 112</span>
|
657
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_url</span>(<span class="ruby-identifier">url</span>)
|
658
|
+
<span class="ruby-identifier">url</span> = <span class="ruby-node">"http://#{url}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">url</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/^http/</span>)
|
659
|
+
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>)
|
660
|
+
<span class="ruby-keyword kw">end</span>
|
661
|
+
</pre>
|
662
|
+
</div>
|
663
|
+
</div>
|
664
|
+
</div>
|
665
|
+
|
666
|
+
<div id="method-M000347" class="method-detail">
|
667
|
+
<a name="M000347"></a>
|
668
|
+
|
669
|
+
<div class="method-heading">
|
670
|
+
<a href="#M000347" class="method-signature">
|
671
|
+
<span class="method-name">parse_url_with_auth</span><span class="method-args">(url)</span>
|
672
|
+
</a>
|
673
|
+
</div>
|
674
|
+
|
675
|
+
<div class="method-description">
|
676
|
+
<p><a class="source-toggle" href="#"
|
677
|
+
onclick="toggleCode('M000347-source');return false;">[Source]</a></p>
|
678
|
+
<div class="method-source-code" id="M000347-source">
|
679
|
+
<pre>
|
680
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 117</span>
|
681
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_url_with_auth</span>(<span class="ruby-identifier">url</span>)
|
682
|
+
<span class="ruby-identifier">uri</span> = <span class="ruby-identifier">parse_url</span>(<span class="ruby-identifier">url</span>)
|
683
|
+
<span class="ruby-ivar">@user</span> = <span class="ruby-constant">CGI</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span>
|
684
|
+
<span class="ruby-ivar">@password</span> = <span class="ruby-constant">CGI</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span>
|
685
|
+
<span class="ruby-identifier">uri</span>
|
686
|
+
<span class="ruby-keyword kw">end</span>
|
687
|
+
</pre>
|
688
|
+
</div>
|
689
|
+
</div>
|
690
|
+
</div>
|
691
|
+
|
692
|
+
<div id="method-M000342" class="method-detail">
|
693
|
+
<a name="M000342"></a>
|
694
|
+
|
695
|
+
<div class="method-heading">
|
696
|
+
<a href="#M000342" class="method-signature">
|
697
|
+
<span class="method-name">process_get_params</span><span class="method-args">(url, headers)</span>
|
698
|
+
</a>
|
699
|
+
</div>
|
700
|
+
|
701
|
+
<div class="method-description">
|
702
|
+
<p>
|
703
|
+
Extract the query parameters for get request and append them to the url
|
704
|
+
</p>
|
705
|
+
<p><a class="source-toggle" href="#"
|
706
|
+
onclick="toggleCode('M000342-source');return false;">[Source]</a></p>
|
707
|
+
<div class="method-source-code" id="M000342-source">
|
708
|
+
<pre>
|
709
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 68</span>
|
710
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_get_params</span> <span class="ruby-identifier">url</span>, <span class="ruby-identifier">headers</span>
|
711
|
+
<span class="ruby-keyword kw">if</span> [<span class="ruby-identifier">:get</span>, <span class="ruby-identifier">:head</span>, <span class="ruby-identifier">:delete</span>].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">method</span>
|
712
|
+
<span class="ruby-identifier">get_params</span> = {}
|
713
|
+
<span class="ruby-identifier">headers</span>.<span class="ruby-identifier">delete_if</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
714
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-value str">'params'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
715
|
+
<span class="ruby-identifier">get_params</span>.<span class="ruby-identifier">merge!</span> <span class="ruby-identifier">value</span>
|
716
|
+
<span class="ruby-keyword kw">true</span>
|
717
|
+
<span class="ruby-keyword kw">else</span>
|
718
|
+
<span class="ruby-keyword kw">false</span>
|
719
|
+
<span class="ruby-keyword kw">end</span>
|
720
|
+
<span class="ruby-keyword kw">end</span>
|
721
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">get_params</span>.<span class="ruby-identifier">empty?</span>
|
722
|
+
<span class="ruby-identifier">query_string</span> = <span class="ruby-identifier">get_params</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-node">"#{k.to_s}=#{CGI::escape(v.to_s)}"</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'&'</span>)
|
723
|
+
<span class="ruby-identifier">url</span> <span class="ruby-operator">+</span> <span class="ruby-node">"?#{query_string}"</span>
|
724
|
+
<span class="ruby-keyword kw">else</span>
|
725
|
+
<span class="ruby-identifier">url</span>
|
726
|
+
<span class="ruby-keyword kw">end</span>
|
727
|
+
<span class="ruby-keyword kw">else</span>
|
728
|
+
<span class="ruby-identifier">url</span>
|
729
|
+
<span class="ruby-keyword kw">end</span>
|
730
|
+
<span class="ruby-keyword kw">end</span>
|
731
|
+
</pre>
|
732
|
+
</div>
|
733
|
+
</div>
|
734
|
+
</div>
|
735
|
+
|
736
|
+
<div id="method-M000348" class="method-detail">
|
737
|
+
<a name="M000348"></a>
|
738
|
+
|
739
|
+
<div class="method-heading">
|
740
|
+
<a href="#M000348" class="method-signature">
|
741
|
+
<span class="method-name">process_payload</span><span class="method-args">(p=nil, parent_key=nil)</span>
|
742
|
+
</a>
|
743
|
+
</div>
|
744
|
+
|
745
|
+
<div class="method-description">
|
746
|
+
<p><a class="source-toggle" href="#"
|
747
|
+
onclick="toggleCode('M000348-source');return false;">[Source]</a></p>
|
748
|
+
<div class="method-source-code" id="M000348-source">
|
749
|
+
<pre>
|
750
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 124</span>
|
751
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_payload</span>(<span class="ruby-identifier">p</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">parent_key</span>=<span class="ruby-keyword kw">nil</span>)
|
752
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
753
|
+
<span class="ruby-identifier">p</span>
|
754
|
+
<span class="ruby-keyword kw">else</span>
|
755
|
+
<span class="ruby-ivar">@headers</span>[<span class="ruby-identifier">:content_type</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">'application/x-www-form-urlencoded'</span>
|
756
|
+
<span class="ruby-identifier">p</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
757
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">parent_key</span> <span class="ruby-value">? </span><span class="ruby-node">"#{parent_key}[#{k}]"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">k</span>
|
758
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">p</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
759
|
+
<span class="ruby-identifier">process_payload</span>(<span class="ruby-identifier">p</span>[<span class="ruby-identifier">k</span>], <span class="ruby-identifier">key</span>)
|
760
|
+
<span class="ruby-keyword kw">else</span>
|
761
|
+
<span class="ruby-identifier">value</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">p</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">to_s</span>, <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"[^#{URI::PATTERN::UNRESERVED}]"</span>))
|
762
|
+
<span class="ruby-node">"#{key}=#{value}"</span>
|
763
|
+
<span class="ruby-keyword kw">end</span>
|
764
|
+
<span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"&"</span>)
|
765
|
+
<span class="ruby-keyword kw">end</span>
|
766
|
+
<span class="ruby-keyword kw">end</span>
|
767
|
+
</pre>
|
768
|
+
</div>
|
769
|
+
</div>
|
770
|
+
</div>
|
771
|
+
|
772
|
+
<div id="method-M000352" class="method-detail">
|
773
|
+
<a name="M000352"></a>
|
774
|
+
|
775
|
+
<div class="method-heading">
|
776
|
+
<a href="#M000352" class="method-signature">
|
777
|
+
<span class="method-name">process_result</span><span class="method-args">(res, & block)</span>
|
778
|
+
</a>
|
779
|
+
</div>
|
780
|
+
|
781
|
+
<div class="method-description">
|
782
|
+
<p><a class="source-toggle" href="#"
|
783
|
+
onclick="toggleCode('M000352-source');return false;">[Source]</a></p>
|
784
|
+
<div class="method-source-code" id="M000352-source">
|
785
|
+
<pre>
|
786
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 217</span>
|
787
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_result</span> <span class="ruby-identifier">res</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>
|
788
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@raw_response</span>
|
789
|
+
<span class="ruby-comment cmt"># We don't decode raw requests</span>
|
790
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-constant">RawResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@tf</span>, <span class="ruby-identifier">res</span>, <span class="ruby-identifier">args</span>)
|
791
|
+
<span class="ruby-keyword kw">else</span>
|
792
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">create</span>(<span class="ruby-constant">Request</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">res</span>[<span class="ruby-value str">'content-encoding'</span>], <span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>), <span class="ruby-identifier">res</span>, <span class="ruby-identifier">args</span>)
|
793
|
+
<span class="ruby-keyword kw">end</span>
|
794
|
+
|
795
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
796
|
+
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">response</span>, <span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">res</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>)
|
797
|
+
<span class="ruby-keyword kw">else</span>
|
798
|
+
<span class="ruby-identifier">response</span>.<span class="ruby-identifier">return!</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">res</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>)
|
799
|
+
<span class="ruby-keyword kw">end</span>
|
800
|
+
|
801
|
+
<span class="ruby-keyword kw">end</span>
|
802
|
+
</pre>
|
803
|
+
</div>
|
804
|
+
</div>
|
805
|
+
</div>
|
806
|
+
|
807
|
+
<div id="method-M000350" class="method-detail">
|
808
|
+
<a name="M000350"></a>
|
809
|
+
|
810
|
+
<div class="method-heading">
|
811
|
+
<a href="#M000350" class="method-signature">
|
812
|
+
<span class="method-name">setup_credentials</span><span class="method-args">(req)</span>
|
813
|
+
</a>
|
814
|
+
</div>
|
815
|
+
|
816
|
+
<div class="method-description">
|
817
|
+
<p><a class="source-toggle" href="#"
|
818
|
+
onclick="toggleCode('M000350-source');return false;">[Source]</a></p>
|
819
|
+
<div class="method-source-code" id="M000350-source">
|
820
|
+
<pre>
|
821
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 185</span>
|
822
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup_credentials</span>(<span class="ruby-identifier">req</span>)
|
823
|
+
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">basic_auth</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">user</span>
|
824
|
+
<span class="ruby-keyword kw">end</span>
|
825
|
+
</pre>
|
826
|
+
</div>
|
827
|
+
</div>
|
828
|
+
</div>
|
829
|
+
|
830
|
+
<div id="method-M000356" class="method-detail">
|
831
|
+
<a name="M000356"></a>
|
832
|
+
|
833
|
+
<div class="method-heading">
|
834
|
+
<a href="#M000356" class="method-signature">
|
835
|
+
<span class="method-name">stringify_headers</span><span class="method-args">(headers)</span>
|
836
|
+
</a>
|
837
|
+
</div>
|
838
|
+
|
839
|
+
<div class="method-description">
|
840
|
+
<p>
|
841
|
+
Return a hash of headers whose keys are capitalized strings
|
842
|
+
</p>
|
843
|
+
<p><a class="source-toggle" href="#"
|
844
|
+
onclick="toggleCode('M000356-source');return false;">[Source]</a></p>
|
845
|
+
<div class="method-source-code" id="M000356-source">
|
846
|
+
<pre>
|
847
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 269</span>
|
848
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stringify_headers</span> <span class="ruby-identifier">headers</span>
|
849
|
+
<span class="ruby-identifier">headers</span>.<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">result</span>, (<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)<span class="ruby-operator">|</span>
|
850
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>
|
851
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/_/</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span> <span class="ruby-identifier">w</span>.<span class="ruby-identifier">capitalize</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">'-'</span>)
|
852
|
+
<span class="ruby-keyword kw">end</span>
|
853
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-value str">'CONTENT-TYPE'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">upcase</span>
|
854
|
+
<span class="ruby-identifier">target_value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
|
855
|
+
<span class="ruby-identifier">result</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>.<span class="ruby-identifier">type_for_extension</span> <span class="ruby-identifier">target_value</span>
|
856
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-value str">'ACCEPT'</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">upcase</span>
|
857
|
+
<span class="ruby-comment cmt"># Accept can be composed of several comma-separated values</span>
|
858
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Array</span>
|
859
|
+
<span class="ruby-identifier">target_values</span> = <span class="ruby-identifier">value</span>
|
860
|
+
<span class="ruby-keyword kw">else</span>
|
861
|
+
<span class="ruby-identifier">target_values</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span> <span class="ruby-value str">','</span>
|
862
|
+
<span class="ruby-keyword kw">end</span>
|
863
|
+
<span class="ruby-identifier">result</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">target_values</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ext</span><span class="ruby-operator">|</span> <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>.<span class="ruby-identifier">type_for_extension</span>(<span class="ruby-identifier">ext</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">', '</span>)
|
864
|
+
<span class="ruby-keyword kw">else</span>
|
865
|
+
<span class="ruby-identifier">result</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>
|
866
|
+
<span class="ruby-keyword kw">end</span>
|
867
|
+
<span class="ruby-identifier">result</span>
|
868
|
+
<span class="ruby-keyword kw">end</span>
|
869
|
+
<span class="ruby-keyword kw">end</span>
|
870
|
+
</pre>
|
871
|
+
</div>
|
872
|
+
</div>
|
873
|
+
</div>
|
874
|
+
|
875
|
+
<div id="method-M000349" class="method-detail">
|
876
|
+
<a name="M000349"></a>
|
877
|
+
|
878
|
+
<div class="method-heading">
|
879
|
+
<a href="#M000349" class="method-signature">
|
880
|
+
<span class="method-name">transmit</span><span class="method-args">(uri, req, payload, & block)</span>
|
881
|
+
</a>
|
882
|
+
</div>
|
883
|
+
|
884
|
+
<div class="method-description">
|
885
|
+
<p><a class="source-toggle" href="#"
|
886
|
+
onclick="toggleCode('M000349-source');return false;">[Source]</a></p>
|
887
|
+
<div class="method-source-code" id="M000349-source">
|
888
|
+
<pre>
|
889
|
+
<span class="ruby-comment cmt"># File lib/rest-client-1.6.3/lib/restclient/request.rb, line 141</span>
|
890
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transmit</span> <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">req</span>, <span class="ruby-identifier">payload</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>
|
891
|
+
<span class="ruby-identifier">setup_credentials</span> <span class="ruby-identifier">req</span>
|
892
|
+
|
893
|
+
<span class="ruby-identifier">net</span> = <span class="ruby-identifier">net_http_class</span>.<span class="ruby-identifier">new</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>)
|
894
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPS</span>)
|
895
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@verify_ssl</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>) <span class="ruby-operator">||</span> (<span class="ruby-ivar">@verify_ssl</span> <span class="ruby-operator">==</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>)
|
896
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
|
897
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@verify_ssl</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Integer</span>
|
898
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-ivar">@verify_ssl</span>
|
899
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">verify_callback</span> = <span class="ruby-identifier">lambda</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">preverify_ok</span>, <span class="ruby-identifier">ssl_context</span><span class="ruby-operator">|</span>
|
900
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">preverify_ok</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">ssl_context</span>.<span class="ruby-identifier">error</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
901
|
+
<span class="ruby-identifier">err_msg</span> = <span class="ruby-node">"SSL Verification failed -- Preverify: #{preverify_ok}, Error: #{ssl_context.error_string} (#{ssl_context.error})"</span>
|
902
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">SSLCertificateNotVerified</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">err_msg</span>)
|
903
|
+
<span class="ruby-keyword kw">end</span>
|
904
|
+
<span class="ruby-keyword kw">true</span>
|
905
|
+
<span class="ruby-keyword kw">end</span>
|
906
|
+
<span class="ruby-keyword kw">end</span>
|
907
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">cert</span> = <span class="ruby-ivar">@ssl_client_cert</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@ssl_client_cert</span>
|
908
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">key</span> = <span class="ruby-ivar">@ssl_client_key</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@ssl_client_key</span>
|
909
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">ca_file</span> = <span class="ruby-ivar">@ssl_ca_file</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@ssl_ca_file</span>
|
910
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">read_timeout</span> = <span class="ruby-ivar">@timeout</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@timeout</span>
|
911
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">open_timeout</span> = <span class="ruby-ivar">@open_timeout</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@open_timeout</span>
|
912
|
+
|
913
|
+
<span class="ruby-constant">RestClient</span>.<span class="ruby-identifier">before_execution_procs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">before_proc</span><span class="ruby-operator">|</span>
|
914
|
+
<span class="ruby-identifier">before_proc</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">args</span>)
|
915
|
+
<span class="ruby-keyword kw">end</span>
|
916
|
+
|
917
|
+
<span class="ruby-identifier">log_request</span>
|
918
|
+
|
919
|
+
<span class="ruby-identifier">net</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
|
920
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@block_response</span>
|
921
|
+
<span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">payload</span> <span class="ruby-value">? </span><span class="ruby-identifier">payload</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span> <span class="ruby-ivar">@block_response</span>)
|
922
|
+
<span class="ruby-keyword kw">else</span>
|
923
|
+
<span class="ruby-identifier">res</span> = <span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">payload</span> <span class="ruby-value">? </span><span class="ruby-identifier">payload</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">http_response</span><span class="ruby-operator">|</span> <span class="ruby-identifier">fetch_body</span>(<span class="ruby-identifier">http_response</span>) }
|
924
|
+
<span class="ruby-identifier">log_response</span> <span class="ruby-identifier">res</span>
|
925
|
+
<span class="ruby-identifier">process_result</span> <span class="ruby-identifier">res</span>, <span class="ruby-operator">&</span> <span class="ruby-identifier">block</span>
|
926
|
+
<span class="ruby-keyword kw">end</span>
|
927
|
+
<span class="ruby-keyword kw">end</span>
|
928
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>
|
929
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">RestClient</span><span class="ruby-operator">::</span><span class="ruby-constant">ServerBrokeConnection</span>
|
930
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
|
931
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">RestClient</span><span class="ruby-operator">::</span><span class="ruby-constant">RequestTimeout</span>
|
932
|
+
<span class="ruby-keyword kw">end</span>
|
933
|
+
</pre>
|
934
|
+
</div>
|
935
|
+
</div>
|
936
|
+
</div>
|
937
|
+
|
938
|
+
|
939
|
+
</div>
|
940
|
+
|
941
|
+
|
942
|
+
</div>
|
943
|
+
|
944
|
+
|
945
|
+
<div id="validator-badges">
|
946
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
947
|
+
</div>
|
948
|
+
|
949
|
+
</body>
|
950
|
+
</html>
|