ovirt-engine-sdk 4.1.13 → 4.2.0.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.adoc +2 -96
- data/README.adoc +22 -74
- data/ext/ovirtsdk4c/ov_http_client.c +27 -140
- data/ext/ovirtsdk4c/ov_http_client.h +1 -6
- data/ext/ovirtsdk4c/ov_http_request.c +40 -79
- data/ext/ovirtsdk4c/ov_http_request.h +10 -11
- data/ext/ovirtsdk4c/ov_http_response.c +0 -14
- data/ext/ovirtsdk4c/ov_http_transfer.c +0 -11
- data/ext/ovirtsdk4c/ov_module.h +2 -2
- data/lib/ovirtsdk4/connection.rb +57 -122
- data/lib/ovirtsdk4/probe.rb +2 -55
- data/lib/ovirtsdk4/reader.rb +3 -3
- data/lib/ovirtsdk4/readers.rb +91 -206
- data/lib/ovirtsdk4/service.rb +31 -104
- data/lib/ovirtsdk4/services.rb +9612 -7822
- data/lib/ovirtsdk4/types.rb +225 -491
- data/lib/ovirtsdk4/version.rb +1 -1
- data/lib/ovirtsdk4/writers.rb +36 -73
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 734038b717ae55b9d1335c8740cfdbd5ed1f0b3f
|
4
|
+
data.tar.gz: e3cf776841605c2a8cd66fdb77e37fde1b09a8d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1b0abae867f5b48a430a02d257d6d9f723da92256a4a9141b1252d88be0a0169679b2d929aad9ead3eabaa9c43c55c2bcf7bfdc4357841b1152f5034ed9b96
|
7
|
+
data.tar.gz: 786ded331b9d30f7cfa99437d98bd6be32ef2d189837ae24b8fa2de8d35664974d90cf225df2f45eb6e5143bee2ec810d75b7e7219f95ae67a684f7a265cc596
|
data/CHANGES.adoc
CHANGED
@@ -2,105 +2,11 @@
|
|
2
2
|
|
3
3
|
This document describes the relevant changes between releases of the SDK.
|
4
4
|
|
5
|
-
== 4.
|
5
|
+
== 4.2.0-alpha1 / Jun 6 2017
|
6
6
|
|
7
7
|
Bug fixes:
|
8
8
|
|
9
|
-
*
|
10
|
-
https://bugzilla.redhat.com/1513620[#1513620].
|
11
|
-
|
12
|
-
== 4.1.12 / Nov 6 2017
|
13
|
-
|
14
|
-
Bug fixes:
|
15
|
-
|
16
|
-
* Virtual machine remove fails due to spelling mistake
|
17
|
-
https://bugzilla.redhat.com/1509020[#1509020].
|
18
|
-
|
19
|
-
== 4.1.11 / Nov 6 2017
|
20
|
-
|
21
|
-
Bug fixes:
|
22
|
-
|
23
|
-
* Improve error message for empty response body
|
24
|
-
https://bugzilla.redhat.com/1509020[#1509020].
|
25
|
-
|
26
|
-
* Don't send `Expect: 100-continue`
|
27
|
-
https://bugzilla.redhat.com/1509910[#1509910].
|
28
|
-
|
29
|
-
== 4.1.10 / Nov 3 2017
|
30
|
-
|
31
|
-
Update to model 4.1.40:
|
32
|
-
|
33
|
-
* Add `image` parameter to `HostService.upgrade`
|
34
|
-
https://bugzilla.redhat.com/1488434[#1488434].
|
35
|
-
|
36
|
-
New features:
|
37
|
-
|
38
|
-
* Add support for cookies.
|
39
|
-
|
40
|
-
* Add `connect_timeout` parameter
|
41
|
-
https://bugzilla.redhat.com/1508944[#1508944].
|
42
|
-
|
43
|
-
Bug fixes:
|
44
|
-
|
45
|
-
* Check the types of the `HttpClient` constructor parameters.
|
46
|
-
|
47
|
-
* Require `redhat-rpm-config` for building
|
48
|
-
https://bugzilla.redhat.com/1505427[#1505427].
|
49
|
-
|
50
|
-
== 4.1.9 / Oct 13 2017
|
51
|
-
|
52
|
-
Update to model 4.1.39:
|
53
|
-
|
54
|
-
* Add a `refresh` parameter to `FilesService.list`.
|
55
|
-
|
56
|
-
* Add support for Link Layer Discovery Protocol (LLDP).
|
57
|
-
|
58
|
-
* Add support for listing cluster level features, and enabling/disabing
|
59
|
-
them for clusters.
|
60
|
-
|
61
|
-
New features:
|
62
|
-
|
63
|
-
* Improve log messages so that in addition to the response codes they
|
64
|
-
also contain the request method and URL.
|
65
|
-
|
66
|
-
Bug fixes:
|
67
|
-
|
68
|
-
* Add support for multiple threads
|
69
|
-
https://bugzilla.redhat.com/1496846[#1496846].
|
70
|
-
|
71
|
-
== 4.1.8 / Jul 17 2017
|
72
|
-
|
73
|
-
Update to model 4.1.37:
|
74
|
-
|
75
|
-
* Add the `all_content` parameter to `Host.Get` and `Hosts.List`
|
76
|
-
https://bugzilla.redhat.com/1444081[#1444081].
|
77
|
-
|
78
|
-
* Fix the documentation of the method that lists events
|
79
|
-
https://bugzilla.redhat.com/1447622[#1447622].
|
80
|
-
|
81
|
-
* Fix the direction of the main parameter of the method that adds a
|
82
|
-
CDROM to a virtual machine. It should be input and output.
|
83
|
-
|
84
|
-
* Improve the documentation explaining that in general the order of the
|
85
|
-
results of _list_ methods isn't guaranteed.
|
86
|
-
|
87
|
-
* Add the `index` attribute to the `Event` type
|
88
|
-
https://bugzilla.redhat.com/1448511[#1448511].
|
89
|
-
|
90
|
-
New features:
|
91
|
-
|
92
|
-
* Add a new `Probe.exists?` method to check whether an oVirt instance
|
93
|
-
exists.
|
94
|
-
|
95
|
-
Bug fixes:
|
96
|
-
|
97
|
-
* Handle correctly HTTP 201 and 200 response codes.
|
98
|
-
|
99
|
-
* Ignore unreleated responses from server
|
100
|
-
https://bugzilla.redhat.com/1459254[#1459254].
|
101
|
-
|
102
|
-
* Use `bundler` instead of `bundle`
|
103
|
-
https://bugzilla.redhat.com/1462664[#1462664].
|
9
|
+
* Handle correctly actions that return HTTP 201 and 202 response codes.
|
104
10
|
|
105
11
|
== 4.1.7 / Jun 2 2017
|
106
12
|
|
data/README.adoc
CHANGED
@@ -41,41 +41,16 @@ CentOS:
|
|
41
41
|
gcc \
|
42
42
|
libcurl-devel \
|
43
43
|
libxml2-devel \
|
44
|
-
|
45
|
-
ruby \
|
46
|
-
ruby-devel \
|
47
|
-
rubygems \
|
48
|
-
rubygems-devel
|
49
|
-
|
50
|
-
NOTE: The installation of the `ruby`, `ruby-devel`, `rubygems` and
|
51
|
-
`rubygems-devel` packages is necessary if you are going to use the Ruby
|
52
|
-
version included in your distribution. If you are using tools like
|
53
|
-
`rbenv` or `rvm` then this is not necessary.
|
44
|
+
ruby-devel
|
54
45
|
|
55
46
|
If you are using distributions like Debian, or Ubuntu:
|
56
47
|
|
57
48
|
# apt-get --assume-yes install \
|
58
49
|
gcc \
|
59
|
-
libcurl4-openssl-dev \
|
60
50
|
libxml2-dev \
|
61
|
-
|
51
|
+
libcurl-dev \
|
62
52
|
ruby-dev
|
63
53
|
|
64
|
-
NOTE: The installation of the `ruby` and `ruby-dev` packages is
|
65
|
-
necessary if you are going to use the Ruby version included in your
|
66
|
-
distribution. If you are using tools like `rbenv` or `rvm` then this is
|
67
|
-
not necessary.
|
68
|
-
|
69
|
-
Some Linux distributions, like Debian and Ubuntu, provide multiple
|
70
|
-
versions of `libcurl`, compiled with support for different TLS
|
71
|
-
libraries: OpenSSL, NSS and GnuTLS. Currently the SDK only supports
|
72
|
-
OpenSSL, so make sure that you have that version of `libcurl` installed.
|
73
|
-
For example, in Ubuntu 16.04 if you have the NSS version installed, you
|
74
|
-
will have to remove it and then install the OpenSSL version:
|
75
|
-
|
76
|
-
# apt-get --assume-yes remove libcurl4-nss-dev
|
77
|
-
# apt-get --assume-yes install libcurl4-openssl-dev
|
78
|
-
|
79
54
|
NOTE: The examples above use the `dnf` command, which is the default in
|
80
55
|
Fedora 24. In CentOS 7 you may need to use the `yum` command, as `dnf`
|
81
56
|
is optional.
|
@@ -131,7 +106,7 @@ locators_ and _service methods_ (described later) may change in the
|
|
131
106
|
future.
|
132
107
|
|
133
108
|
There are other classes, like HTTP client classes, readers and writers.
|
134
|
-
These are used to implement the HTTP communication, and for XML
|
109
|
+
These are used to implement the HTTP communication, and to for XML
|
135
110
|
parsing and rendering. Refrain from using them, as they are internal
|
136
111
|
implementation details that may change in the future: backwards
|
137
112
|
compatibility isn't guaranteed.
|
@@ -152,9 +127,6 @@ connection = OvirtSDK4::Connection.new(
|
|
152
127
|
password: '...',
|
153
128
|
ca_file: 'ca.pem',
|
154
129
|
)
|
155
|
-
|
156
|
-
# Get the reference to the root of the tree of services:
|
157
|
-
system_service = connection.system_service
|
158
130
|
----
|
159
131
|
|
160
132
|
The connection holds expensive resources, including a pool of HTTP
|
@@ -167,8 +139,7 @@ important to free these resources when they are no longer in use:
|
|
167
139
|
connection.close
|
168
140
|
----
|
169
141
|
|
170
|
-
|
171
|
-
can't be used after the connection has been closed.
|
142
|
+
Once a connection is closed it can't be reused.
|
172
143
|
|
173
144
|
The `ca.pem` file is required when connecting to a server protected
|
174
145
|
with TLS. In an usual oVirt installation it will be in
|
@@ -185,9 +156,9 @@ The type classes are pure data containers, they don't have any logic or
|
|
185
156
|
operations. Instances can be created and modified at will.
|
186
157
|
|
187
158
|
Creating or modifying one of this instances does *not* have any effect
|
188
|
-
in the server side, unless they are explicitly passed to a call to
|
189
|
-
of the service methods described below. Changes in the server side
|
190
|
-
*not* automatically reflected in the instances that already exist in
|
159
|
+
in the server side, unless one they are explicitly passed to a call to
|
160
|
+
one of the service methods described below. Changes in the server side
|
161
|
+
are *not* automatically reflected in the instances that already exist in
|
191
162
|
memory.
|
192
163
|
|
193
164
|
The constructors of these classes have multiple optional arguments, one
|
@@ -210,28 +181,6 @@ vm = OvirtSDK4::Vm.new(
|
|
210
181
|
)
|
211
182
|
----
|
212
183
|
|
213
|
-
The hashes passed to these constructors are processed recursively. For
|
214
|
-
example, in the above code instead of explicitly calling the constructor
|
215
|
-
for the `Cluster` and `Template` classes it is also possible to use
|
216
|
-
plain hashes:
|
217
|
-
|
218
|
-
[source,ruby]
|
219
|
-
----
|
220
|
-
vm = OvirtSDK4::Vm.new(
|
221
|
-
name: 'myvm',
|
222
|
-
cluster: {
|
223
|
-
name: 'mycluster'
|
224
|
-
},
|
225
|
-
template: {
|
226
|
-
name: 'mytemplate'
|
227
|
-
},
|
228
|
-
memory: 1073741824
|
229
|
-
)
|
230
|
-
----
|
231
|
-
|
232
|
-
The SDK will internally convert those hashes to the required classes, so
|
233
|
-
the result will be exactly the same.
|
234
|
-
|
235
184
|
Using the constructors in this way is recommended, but not mandatory.
|
236
185
|
You can also create the instance with no arguments in the call to the
|
237
186
|
constructor, and then populate the object step by step, using the
|
@@ -243,7 +192,7 @@ vm = OvirtSDK4::Vm.new
|
|
243
192
|
vm.name = 'myvm'
|
244
193
|
vm.cluster = OvirtSDK4::Cluster.new(name: 'mycluster')
|
245
194
|
vm.template = OvirtSDK4::Template.new(name: 'mytemplate')
|
246
|
-
vm.memory
|
195
|
+
vm.memory=1073741824
|
247
196
|
----
|
248
197
|
|
249
198
|
Attributes that are defined as lists of objects in the specification of
|
@@ -350,7 +299,7 @@ manages the collection of virtual machines of the system lives in
|
|
350
299
|
|
351
300
|
In the SDK the root of that tree of services is implemented by the
|
352
301
|
_system service_. It is obtained calling the
|
353
|
-
{
|
302
|
+
{rererence}/Connection#system_service-instance_method[system_service]
|
354
303
|
method of the connection:
|
355
304
|
|
356
305
|
[source,ruby]
|
@@ -403,8 +352,7 @@ The services that manage a single object usually have the `get`,
|
|
403
352
|
|
404
353
|
Both kinds of services can also have additional _action methods_, which
|
405
354
|
perform actions other than retrieving, creating, updating or removing.
|
406
|
-
Most frequently they
|
407
|
-
object.
|
355
|
+
Most frequently they available in services that manage a single object.
|
408
356
|
|
409
357
|
==== Using the _get_ methods
|
410
358
|
|
@@ -479,7 +427,7 @@ vms_service = system_service.vms_service
|
|
479
427
|
vms = vms_service.list
|
480
428
|
----
|
481
429
|
|
482
|
-
The result will be a Ruby array containing the instances of
|
430
|
+
The result will be a Ruby array containing the instances of
|
483
431
|
corresponding types. For example, in this case, the result will be a
|
484
432
|
list of instances of the Ruby class {reference}/Vm[Vm].
|
485
433
|
|
@@ -508,8 +456,8 @@ of the failure.
|
|
508
456
|
|
509
457
|
==== Using the _add_ methods
|
510
458
|
|
511
|
-
These service methods add new elements to
|
512
|
-
instance of the relevant type describing the object to add, send the
|
459
|
+
These service methods add new elements to the collection. They receive
|
460
|
+
an instance of the relevant type describing the object to add, send the
|
513
461
|
request to add it, and return an instance of the type describing the
|
514
462
|
added object.
|
515
463
|
|
@@ -521,12 +469,12 @@ For example, to add a new virtual machine named `myvm`:
|
|
521
469
|
vm = vms_service.add(
|
522
470
|
OvirtSDK4::Vm.new(
|
523
471
|
name: 'myvm',
|
524
|
-
cluster:
|
472
|
+
cluster: OvirtSDK4::Cluster.new(
|
525
473
|
name: 'mycluster'
|
526
|
-
|
527
|
-
template:
|
474
|
+
),
|
475
|
+
template: OvirtSDK4::Template.new(
|
528
476
|
name: 'mytemplate'
|
529
|
-
|
477
|
+
)
|
530
478
|
)
|
531
479
|
)
|
532
480
|
----
|
@@ -591,10 +539,10 @@ updated.
|
|
591
539
|
|
592
540
|
==== Using the _update_ methods
|
593
541
|
|
594
|
-
These service methods update existing objects. They receive
|
595
|
-
of the relevant type describing the update to perform, send
|
596
|
-
to update it, and return an instance of the type describing
|
597
|
-
object.
|
542
|
+
These service methods update existing objects. They receive
|
543
|
+
an instance of the relevant type describing the update to perform, send
|
544
|
+
the request to update it, and return an instance of the type describing
|
545
|
+
the updated object.
|
598
546
|
|
599
547
|
For example, to update the name of a virtual machine from `myvm` to
|
600
548
|
`newvm`:
|
@@ -621,7 +569,7 @@ update. For example, try to *avoid* this:
|
|
621
569
|
[source,ruby]
|
622
570
|
----
|
623
571
|
# Retrieve the current representation:
|
624
|
-
vm = vm_service.get
|
572
|
+
vm = vm_service.get()
|
625
573
|
|
626
574
|
# Update the representation, in memory, no request sent
|
627
575
|
# to the server:
|
@@ -50,8 +50,7 @@ static VALUE PROXY_PASSWORD_SYMBOL;
|
|
50
50
|
static VALUE PROXY_URL_SYMBOL;
|
51
51
|
static VALUE PROXY_USERNAME_SYMBOL;
|
52
52
|
static VALUE TIMEOUT_SYMBOL;
|
53
|
-
static VALUE
|
54
|
-
static VALUE COOKIES_SYMBOL;
|
53
|
+
static VALUE USERNAME_SYMBOL;
|
55
54
|
|
56
55
|
/* Method identifiers: */
|
57
56
|
static ID COMPARE_BY_IDENTITY_ID;
|
@@ -155,7 +154,6 @@ static void ov_http_client_free(void* vptr) {
|
|
155
154
|
/* Release the resources used by libcurl: */
|
156
155
|
if (ptr->handle != NULL) {
|
157
156
|
curl_multi_cleanup(ptr->handle);
|
158
|
-
curl_share_cleanup(ptr->share);
|
159
157
|
ptr->handle = NULL;
|
160
158
|
}
|
161
159
|
|
@@ -164,7 +162,6 @@ static void ov_http_client_free(void* vptr) {
|
|
164
162
|
ov_string_free(ptr->proxy_url);
|
165
163
|
ov_string_free(ptr->proxy_username);
|
166
164
|
ov_string_free(ptr->proxy_password);
|
167
|
-
ov_string_free(ptr->cookies);
|
168
165
|
|
169
166
|
/* Free this object: */
|
170
167
|
xfree(ptr);
|
@@ -189,21 +186,6 @@ static VALUE ov_http_client_alloc(VALUE klass) {
|
|
189
186
|
ov_http_client_object* ptr;
|
190
187
|
|
191
188
|
ptr = ALLOC(ov_http_client_object);
|
192
|
-
ptr->handle = NULL;
|
193
|
-
ptr->share = NULL;
|
194
|
-
ptr->log = Qnil;
|
195
|
-
ptr->pending = Qnil;
|
196
|
-
ptr->completed = Qnil;
|
197
|
-
ptr->compress = false;
|
198
|
-
ptr->debug = false;
|
199
|
-
ptr->insecure = false;
|
200
|
-
ptr->ca_file = NULL;
|
201
|
-
ptr->proxy_url = NULL;
|
202
|
-
ptr->proxy_username = NULL;
|
203
|
-
ptr->proxy_password = NULL;
|
204
|
-
ptr->timeout = 0;
|
205
|
-
ptr->connect_timeout = 0;
|
206
|
-
ptr->cookies = NULL;
|
207
189
|
return TypedData_Wrap_Struct(klass, &ov_http_client_type, ptr);
|
208
190
|
}
|
209
191
|
|
@@ -329,17 +311,9 @@ static void* ov_http_client_header_task(void* data) {
|
|
329
311
|
/* We should always tell the library that we processed all the data: */
|
330
312
|
context_ptr->result = context_ptr->size * context_ptr->nitems;
|
331
313
|
|
332
|
-
/*
|
333
|
-
requests used for authentication negotation. We are interested only in the headers of the last response, so
|
334
|
-
if the given data is the begin of a new response, we clear the headers hash. */
|
314
|
+
/* Remove trailing white space: */
|
335
315
|
length = context_ptr->result;
|
336
316
|
buffer = context_ptr->buffer;
|
337
|
-
if (length >= 5 && strncmp("HTTP/", buffer, 5) == 0) {
|
338
|
-
rb_hash_clear(response_ptr->headers);
|
339
|
-
return NULL;
|
340
|
-
}
|
341
|
-
|
342
|
-
/* Remove trailing white space: */
|
343
317
|
while (length > 0 && isspace(buffer[length - 1])) {
|
344
318
|
length--;
|
345
319
|
}
|
@@ -484,13 +458,7 @@ static VALUE ov_http_client_initialize(int argc, VALUE* argv, VALUE self) {
|
|
484
458
|
|
485
459
|
/* Get the value of the 'ca_file' parameter: */
|
486
460
|
opt = rb_hash_aref(opts, CA_FILE_SYMBOL);
|
487
|
-
|
488
|
-
ptr->ca_file = NULL;
|
489
|
-
}
|
490
|
-
else {
|
491
|
-
Check_Type(opt, T_STRING);
|
492
|
-
ptr->ca_file = ov_string_dup(opt);
|
493
|
-
}
|
461
|
+
ptr->ca_file = ov_string_dup(opt);
|
494
462
|
|
495
463
|
/* Get the value of the 'insecure' parameter: */
|
496
464
|
opt = rb_hash_aref(opts, INSECURE_SYMBOL);
|
@@ -514,45 +482,17 @@ static VALUE ov_http_client_initialize(int argc, VALUE* argv, VALUE self) {
|
|
514
482
|
ptr->timeout = NUM2INT(opt);
|
515
483
|
}
|
516
484
|
|
517
|
-
/* Get the value of the 'connect_timeout' parameter: */
|
518
|
-
opt = rb_hash_aref(opts, CONNECT_TIMEOUT_SYMBOL);
|
519
|
-
if (NIL_P(opt)) {
|
520
|
-
ptr->connect_timeout = 0;
|
521
|
-
}
|
522
|
-
else {
|
523
|
-
Check_Type(opt, T_FIXNUM);
|
524
|
-
ptr->connect_timeout = NUM2INT(opt);
|
525
|
-
}
|
526
|
-
|
527
485
|
/* Get the value of the 'proxy_url' parameter: */
|
528
486
|
opt = rb_hash_aref(opts, PROXY_URL_SYMBOL);
|
529
|
-
|
530
|
-
ptr->proxy_url = NULL;
|
531
|
-
}
|
532
|
-
else {
|
533
|
-
Check_Type(opt, T_STRING);
|
534
|
-
ptr->proxy_url = ov_string_dup(opt);
|
535
|
-
}
|
487
|
+
ptr->proxy_url = ov_string_dup(opt);
|
536
488
|
|
537
489
|
/* Get the value of the 'proxy_username' parameter: */
|
538
490
|
opt = rb_hash_aref(opts, PROXY_USERNAME_SYMBOL);
|
539
|
-
|
540
|
-
ptr->proxy_username = NULL;
|
541
|
-
}
|
542
|
-
else {
|
543
|
-
Check_Type(opt, T_STRING);
|
544
|
-
ptr->proxy_username = ov_string_dup(opt);
|
545
|
-
}
|
491
|
+
ptr->proxy_username = ov_string_dup(opt);
|
546
492
|
|
547
493
|
/* Get the value of the 'proxy_password' parameter: */
|
548
494
|
opt = rb_hash_aref(opts, PROXY_PASSWORD_SYMBOL);
|
549
|
-
|
550
|
-
ptr->proxy_password = NULL;
|
551
|
-
}
|
552
|
-
else {
|
553
|
-
Check_Type(opt, T_STRING);
|
554
|
-
ptr->proxy_password = ov_string_dup(opt);
|
555
|
-
}
|
495
|
+
ptr->proxy_password = ov_string_dup(opt);
|
556
496
|
|
557
497
|
/* Get the value of the 'log' parameter: */
|
558
498
|
opt = rb_hash_aref(opts, LOG_SYMBOL);
|
@@ -578,20 +518,6 @@ static VALUE ov_http_client_initialize(int argc, VALUE* argv, VALUE self) {
|
|
578
518
|
connections = NUM2LONG(opt);
|
579
519
|
}
|
580
520
|
|
581
|
-
/* Get the value of the 'cookies' parameter. If it is a string it will be used as the path of the file where the
|
582
|
-
cookies will be stored. If it is any other thing it will be treated as a boolean flag indicating if cookies
|
583
|
-
should be enabled but not loaded/saved from/to any file. */
|
584
|
-
opt = rb_hash_aref(opts, COOKIES_SYMBOL);
|
585
|
-
if (TYPE(opt) == T_STRING) {
|
586
|
-
ptr->cookies = ov_string_dup(opt);
|
587
|
-
}
|
588
|
-
else if (RTEST(opt)) {
|
589
|
-
ptr->cookies = ov_string_dup(rb_str_new2(""));
|
590
|
-
}
|
591
|
-
else {
|
592
|
-
ptr->cookies = NULL;
|
593
|
-
}
|
594
|
-
|
595
521
|
/* Create the hash that contains the transfers are pending an completed. Both use the identity of the request
|
596
522
|
as key. */
|
597
523
|
ptr->completed = rb_funcall(rb_hash_new(), COMPARE_BY_IDENTITY_ID, 0);
|
@@ -600,16 +526,7 @@ static VALUE ov_http_client_initialize(int argc, VALUE* argv, VALUE self) {
|
|
600
526
|
/* Create the libcurl multi handle: */
|
601
527
|
ptr->handle = curl_multi_init();
|
602
528
|
if (ptr->handle == NULL) {
|
603
|
-
rb_raise(ov_error_class, "Can't create libcurl
|
604
|
-
}
|
605
|
-
|
606
|
-
/* Create the libcurl share handle in order to share cookie data: */
|
607
|
-
ptr->share = curl_share_init();
|
608
|
-
if (ptr->share == NULL) {
|
609
|
-
rb_raise(ov_error_class, "Can't create libcurl share object");
|
610
|
-
}
|
611
|
-
if (ptr->cookies != NULL) {
|
612
|
-
curl_share_setopt(ptr->share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
|
529
|
+
rb_raise(ov_error_class, "Can't create libcurl object");
|
613
530
|
}
|
614
531
|
|
615
532
|
/* Enable pipelining: */
|
@@ -662,7 +579,6 @@ static void* ov_http_client_complete_task(void* data) {
|
|
662
579
|
VALUE transfer;
|
663
580
|
long code;
|
664
581
|
ov_http_client_object* client_ptr;
|
665
|
-
ov_http_request_object* request_ptr;
|
666
582
|
ov_http_response_object* response_ptr;
|
667
583
|
ov_http_transfer_object* transfer_ptr;
|
668
584
|
|
@@ -676,7 +592,6 @@ static void* ov_http_client_complete_task(void* data) {
|
|
676
592
|
/* Get the pointers to the transfer, client and response: */
|
677
593
|
ov_http_transfer_ptr(transfer, transfer_ptr);
|
678
594
|
ov_http_client_ptr(transfer_ptr->client, client_ptr);
|
679
|
-
ov_http_request_ptr(transfer_ptr->request, request_ptr);
|
680
595
|
ov_http_response_ptr(transfer_ptr->response, response_ptr);
|
681
596
|
|
682
597
|
/* Remove the transfer from the pending hash: */
|
@@ -694,10 +609,8 @@ static void* ov_http_client_complete_task(void* data) {
|
|
694
609
|
/* Send a summary of the response to the log: */
|
695
610
|
ov_http_client_log_info(
|
696
611
|
client_ptr->log,
|
697
|
-
"Received response code
|
698
|
-
response_ptr->code
|
699
|
-
request_ptr->method,
|
700
|
-
request_ptr->url
|
612
|
+
"Received response code '%"PRIsVALUE"'.",
|
613
|
+
response_ptr->code
|
701
614
|
);
|
702
615
|
}
|
703
616
|
else {
|
@@ -797,14 +710,6 @@ static void ov_http_client_prepare_handle(ov_http_client_object* client_ptr, ov_
|
|
797
710
|
VALUE header;
|
798
711
|
VALUE url;
|
799
712
|
int timeout;
|
800
|
-
int connect_timeout;
|
801
|
-
|
802
|
-
/* Configure sharing of cookies with other handlers created by the client: */
|
803
|
-
curl_easy_setopt(handle, CURLOPT_SHARE, client_ptr->share);
|
804
|
-
if (client_ptr->cookies != NULL && strlen(client_ptr->cookies) > 0) {
|
805
|
-
curl_easy_setopt(handle, CURLOPT_COOKIEFILE, client_ptr->cookies);
|
806
|
-
curl_easy_setopt(handle, CURLOPT_COOKIEJAR, client_ptr->cookies);
|
807
|
-
}
|
808
713
|
|
809
714
|
/* Configure TLS parameters: */
|
810
715
|
if (client_ptr->insecure) {
|
@@ -815,20 +720,13 @@ static void ov_http_client_prepare_handle(ov_http_client_object* client_ptr, ov_
|
|
815
720
|
curl_easy_setopt(handle, CURLOPT_CAINFO, client_ptr->ca_file);
|
816
721
|
}
|
817
722
|
|
818
|
-
/* Configure the
|
723
|
+
/* Configure the timeout: */
|
819
724
|
timeout = client_ptr->timeout;
|
820
725
|
if (!NIL_P(request_ptr->timeout)) {
|
821
726
|
timeout = NUM2INT(request_ptr->timeout);
|
822
727
|
}
|
823
728
|
curl_easy_setopt(handle, CURLOPT_TIMEOUT, timeout);
|
824
729
|
|
825
|
-
/* Configure the connect timeout: */
|
826
|
-
connect_timeout = client_ptr->connect_timeout;
|
827
|
-
if (!NIL_P(request_ptr->connect_timeout)) {
|
828
|
-
connect_timeout = NUM2INT(request_ptr->connect_timeout);
|
829
|
-
}
|
830
|
-
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, connect_timeout);
|
831
|
-
|
832
730
|
/* Configure compression of responses (setting the value to zero length string means accepting all the
|
833
731
|
compression types that libcurl supports): */
|
834
732
|
if (client_ptr->compress) {
|
@@ -866,7 +764,6 @@ static void ov_http_client_prepare_handle(ov_http_client_object* client_ptr, ov_
|
|
866
764
|
curl_easy_setopt(handle, CURLOPT_POST, 1L);
|
867
765
|
}
|
868
766
|
else if (rb_eql(request_ptr->method, PUT_SYMBOL)) {
|
869
|
-
*headers = curl_slist_append(*headers, "Expect:");
|
870
767
|
curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L);
|
871
768
|
curl_easy_setopt(handle, CURLOPT_PUT, 1L);
|
872
769
|
}
|
@@ -901,7 +798,7 @@ static void ov_http_client_prepare_handle(ov_http_client_object* client_ptr, ov_
|
|
901
798
|
/* Send a summary of the request to the log: */
|
902
799
|
ov_http_client_log_info(
|
903
800
|
client_ptr->log,
|
904
|
-
"Sending %"PRIsVALUE" request to URL '%"PRIsVALUE"'.",
|
801
|
+
"Sending '%"PRIsVALUE"' request to URL '%"PRIsVALUE"'.",
|
905
802
|
request_ptr->method,
|
906
803
|
url
|
907
804
|
);
|
@@ -1012,13 +909,6 @@ static VALUE ov_http_client_wait(VALUE self, VALUE request) {
|
|
1012
909
|
return Qnil;
|
1013
910
|
}
|
1014
911
|
|
1015
|
-
static VALUE ov_http_client_inspect(VALUE self) {
|
1016
|
-
ov_http_client_object* ptr;
|
1017
|
-
|
1018
|
-
ov_http_client_ptr(self, ptr);
|
1019
|
-
return rb_sprintf("#<%"PRIsVALUE":%p>", ov_http_client_class, ptr);
|
1020
|
-
}
|
1021
|
-
|
1022
912
|
void ov_http_client_define(void) {
|
1023
913
|
CURLcode code;
|
1024
914
|
|
@@ -1034,27 +924,24 @@ void ov_http_client_define(void) {
|
|
1034
924
|
rb_define_method(ov_http_client_class, "initialize", ov_http_client_initialize, -1);
|
1035
925
|
|
1036
926
|
/* Define the methods: */
|
1037
|
-
rb_define_method(ov_http_client_class, "close",
|
1038
|
-
rb_define_method(ov_http_client_class, "
|
1039
|
-
rb_define_method(ov_http_client_class, "
|
1040
|
-
rb_define_method(ov_http_client_class, "to_s", ov_http_client_inspect, 0);
|
1041
|
-
rb_define_method(ov_http_client_class, "wait", ov_http_client_wait, 1);
|
927
|
+
rb_define_method(ov_http_client_class, "close", ov_http_client_close, 0);
|
928
|
+
rb_define_method(ov_http_client_class, "send", ov_http_client_send, 1);
|
929
|
+
rb_define_method(ov_http_client_class, "wait", ov_http_client_wait, 1);
|
1042
930
|
|
1043
931
|
/* Define the symbols: */
|
1044
|
-
CA_FILE_SYMBOL
|
1045
|
-
COMPRESS_SYMBOL
|
1046
|
-
CONNECTIONS_SYMBOL
|
1047
|
-
DEBUG_SYMBOL
|
1048
|
-
INSECURE_SYMBOL
|
1049
|
-
LOG_SYMBOL
|
1050
|
-
PASSWORD_SYMBOL
|
1051
|
-
PIPELINE_SYMBOL
|
1052
|
-
PROXY_PASSWORD_SYMBOL
|
1053
|
-
PROXY_URL_SYMBOL
|
1054
|
-
PROXY_USERNAME_SYMBOL
|
1055
|
-
TIMEOUT_SYMBOL
|
1056
|
-
|
1057
|
-
COOKIES_SYMBOL = ID2SYM(rb_intern("cookies"));
|
932
|
+
CA_FILE_SYMBOL = ID2SYM(rb_intern("ca_file"));
|
933
|
+
COMPRESS_SYMBOL = ID2SYM(rb_intern("compress"));
|
934
|
+
CONNECTIONS_SYMBOL = ID2SYM(rb_intern("connections"));
|
935
|
+
DEBUG_SYMBOL = ID2SYM(rb_intern("debug"));
|
936
|
+
INSECURE_SYMBOL = ID2SYM(rb_intern("insecure"));
|
937
|
+
LOG_SYMBOL = ID2SYM(rb_intern("log"));
|
938
|
+
PASSWORD_SYMBOL = ID2SYM(rb_intern("password"));
|
939
|
+
PIPELINE_SYMBOL = ID2SYM(rb_intern("pipeline"));
|
940
|
+
PROXY_PASSWORD_SYMBOL = ID2SYM(rb_intern("proxy_password"));
|
941
|
+
PROXY_URL_SYMBOL = ID2SYM(rb_intern("proxy_url"));
|
942
|
+
PROXY_USERNAME_SYMBOL = ID2SYM(rb_intern("proxy_username"));
|
943
|
+
TIMEOUT_SYMBOL = ID2SYM(rb_intern("timeout"));
|
944
|
+
USERNAME_SYMBOL = ID2SYM(rb_intern("username"));
|
1058
945
|
|
1059
946
|
/* Define the method identifiers: */
|
1060
947
|
COMPARE_BY_IDENTITY_ID = rb_intern("compare_by_identity");
|