curb 0.9.11 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecd73a0ad8d98960321b8d523e25bad95ff25e8900e8acb187051ca40c7a1cba
4
- data.tar.gz: c154996d92946fe83fa12d695b073d5026e4a55e92efd177bfad021461f2b313
3
+ metadata.gz: e28b1d05b46460867acfadc87bbe422d58d8f2cdb93397fa6ded906b01cd7dab
4
+ data.tar.gz: 33e7037c1c2b23a793ec96c73bc80c008939c880702f884d2b258d4afd18c368
5
5
  SHA512:
6
- metadata.gz: 48854a4f0d77befe0e81b31a3d39e826b2ef65d58d0226b617a355ba8d063ab4998853a8709ae6d2e3c4629c09ff987099398a1c884b76d95dcf956d941fc660
7
- data.tar.gz: 3291675a74eb40f42d936bb65689da7d5f295e038ed019482d2cf115ba878232ce4e40aeb125d0fe786b5e82428320938ff3c75592a5c54a2d51fbe8589a0931
6
+ metadata.gz: 6eb448726a4fdce1e0832e36a45b2c8e0a078fbc2c04b3fe34f87fc38397f5c4ecc4fe621aed5637750c5c7a7a9d05b30c03f9f7db153c23d3694eb6adb464e8
7
+ data.tar.gz: 624e3f39af79eff874784a662776debc2b405378c6cdc963a50dee525d36aa225cc5f40558f9b35b396c222416006f66c29fc6193e651b5aa84093fdd52cb2ba
data/README.markdown CHANGED
@@ -1,22 +1,57 @@
1
- # Curb - Libcurl bindings for Ruby [![Build Status](https://travis-ci.org/taf2/curb.svg?branch=master)](https://travis-ci.org/taf2/curb)
1
+ # Curb - Libcurl bindings for Ruby
2
2
 
3
+ * [CI Build Status](https://github.com/taf2/curb/actions/workflows/CI.yml)
3
4
  * [rubydoc rdoc](http://www.rubydoc.info/github/taf2/curb/)
4
5
  * [github project](http://github.com/taf2/curb/tree/master)
5
6
 
6
7
  Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
7
8
  libcurl(3), a fully-featured client-side URL transfer library.
8
- cURL and libcurl live at [http://curl.haxx.se/](http://curl.haxx.se/) .
9
+ cURL and libcurl live at [https://curl.se/libcurl/](https://curl.se/libcurl/) .
9
10
 
10
11
  Curb is a work-in-progress, and currently only supports libcurl's `easy` and `multi` modes.
11
12
 
12
13
  ## License
13
14
 
14
- Curb is copyright (c)2006 Ross Bamford, and released under the terms of the
15
+ Curb is copyright (c) 2006 Ross Bamford, and released under the terms of the
15
16
  Ruby license. See the LICENSE file for the gory details.
16
17
 
18
+ ## Easy mode
19
+
20
+ GET request
21
+ ```
22
+ res = Curl.get("https://www.google.com/") {|http|
23
+ http.timeout = 10 # raise exception if request/response not handled within 10 seconds
24
+ }
25
+ puts res.code
26
+ puts res.head
27
+ puts res.body
28
+ ```
29
+
30
+ POST request
31
+ ```
32
+ res = Curl.post("https://your-server.com/endpoint", {post: "this"}.to_json) {|http|
33
+ http.headers["Content-Type"] = "application/json"
34
+ }
35
+ puts res.code
36
+ puts res.head
37
+ puts res.body
38
+ ```
39
+
40
+ PATCH request
41
+ ```
42
+ res = Curl.patch("https://your-server.com/endpoint", {post: "this"}.to_json) {|http|
43
+ http.headers["Content-Type"] = "application/json"
44
+ }
45
+ puts res.code
46
+ puts res.head
47
+ puts res.body
48
+ ```
49
+
50
+
51
+
17
52
  ## You will need
18
53
 
19
- * A working Ruby installation (`1.8.7+` will work but `2.1+` preferred)
54
+ * A working Ruby installation (`2.0.0+` will work but `2.1+` preferred) (it's possible it still works with 1.8.7 but you'd have to tell me if not...)
20
55
  * A working libcurl development installation
21
56
  (Ideally one of the versions listed in the compatibility chart below that maps to your `curb` version)
22
57
  * A sane build environment (e.g. gcc, make)
@@ -29,7 +64,8 @@ tested and reported to work across a variety of platforms / rubies)
29
64
 
30
65
  | Gem Version | Release Date | libcurl versions |
31
66
  | ----------- | ----------- | ---------------- |
32
- | 0.9.8 | Jan 2019 | 7.58 - 7.63 |
67
+ | 1.0.0 | Jan 2022 | 7.58 - 7.81 |
68
+ | 0.9.8 | Jan 2019 | 7.58 - 7.81 |
33
69
  | 0.9.7 | Nov 2018 | 7.56 - 7.60 |
34
70
  | 0.9.6 | May 2018 | 7.51 - 7.59 |
35
71
  | 0.9.5 | May 2018 | 7.51 - 7.59 |
@@ -43,7 +79,7 @@ tested and reported to work across a variety of platforms / rubies)
43
79
  $ gem install curb
44
80
 
45
81
  On Windows, make sure you're using the [DevKit](http://rubyinstaller.org/downloads/) and
46
- the [development version of libcurl](http://curl.haxx.se/gknw.net/7.39.0/dist-w32/curl-7.39.0-devel-mingw32.zip). Unzip, then run this in your command
82
+ the [development version of libcurl](http://curl.se/gknw.net/7.39.0/dist-w32/curl-7.39.0-devel-mingw32.zip). Unzip, then run this in your command
47
83
  line (alter paths to your curl location, but remember to use forward slashes):
48
84
 
49
85
  gem install curb --platform=ruby -- --with-curl-lib=C:/curl-7.39.0-devel-mingw32/lib --with-curl-include=C:/curl-7.39.0-devel-mingw32/include
@@ -67,6 +103,12 @@ expand on the above instructions, please report the issue at http://github.com/t
67
103
 
68
104
  On Ubuntu, the dependencies can be satisfied by installing the following packages:
69
105
 
106
+ 18.04 and onwards
107
+
108
+ $ sudo apt-get install libcurl4 libcurl3-gnutls libcurl4-openssl-dev
109
+
110
+ < 18.04
111
+
70
112
  $ sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev
71
113
 
72
114
  On RedHat:
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
  #
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
+ require "ruby_memcheck"
5
6
 
6
7
  CLEAN.include '**/*.o'
7
8
  CLEAN.include "**/*.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
@@ -10,13 +11,6 @@ CLOBBER.include '**/*.log'
10
11
  CLOBBER.include '**/Makefile'
11
12
  CLOBBER.include '**/extconf.h'
12
13
 
13
- # Not available for really old rubies, but that's ok.
14
- begin
15
- require 'pry'
16
- rescue LoadError
17
- puts "Failed to load pry."
18
- end
19
-
20
14
  # Load support ruby and rake files (in this order)
21
15
  Dir.glob('tasks/*.rb').each { |r| load r}
22
16
  Dir.glob('tasks/*.rake').each { |r| load r}
@@ -57,22 +51,20 @@ MAKEOPTS = ENV['MAKE_OPTS'] || ''
57
51
  CURB_SO = "ext/curb_core.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
58
52
 
59
53
  file 'ext/Makefile' => 'ext/extconf.rb' do
60
- Dir.chdir('ext') do
61
- shell('ruby', 'extconf.rb', ENV['EXTCONF_OPTS'].to_s, live_stdout: STDOUT)
62
- end
54
+ shell(['ruby', 'extconf.rb', ENV['EXTCONF_OPTS'].to_s],
55
+ { :live_stdout => STDOUT , :cwd => "#{Dir.pwd}/ext" }
56
+ ).error!
63
57
  end
64
58
 
65
59
  def make(target = '')
66
- Dir.chdir('ext') do
67
- pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
68
- $?.exitstatus
69
- end
60
+ shell(["#{MAKECMD}", "#{MAKEOPTS}", "#{target}"].reject(&:empty?),
61
+ { :live_stdout => STDOUT, :cwd => "#{Dir.pwd}/ext" }
62
+ ).error!
70
63
  end
71
64
 
72
65
  # Let make handle dependencies between c/o/so - we'll just run it.
73
66
  file CURB_SO => (['ext/Makefile'] + Dir['ext/*.c'] + Dir['ext/*.h']) do
74
- m = make
75
- fail "Make failed (status #{m})" unless m == 0
67
+ make
76
68
  end
77
69
 
78
70
  desc "Compile the shared object"
@@ -80,8 +72,7 @@ task :compile => [CURB_SO]
80
72
 
81
73
  desc "Install to your site_ruby directory"
82
74
  task :install do
83
- m = make 'install'
84
- fail "Make install failed (status #{m})" unless m == 0
75
+ make 'install'
85
76
  end
86
77
 
87
78
  # Test Tasks ---------------------------------------------------------
@@ -100,6 +91,14 @@ else
100
91
  task :alltests => [:unittests, :bugtests]
101
92
  end
102
93
 
94
+ RubyMemcheck.config(binary_name: 'curb_core')
95
+ namespace :test do
96
+ RubyMemcheck::TestTask.new(valgrind: :compile) do|t|
97
+ t.test_files = FileList['tests/tc_*.rb']
98
+ t.verbose = false
99
+ end
100
+ end
101
+
103
102
  Rake::TestTask.new(:unittests) do |t|
104
103
  t.test_files = FileList['tests/tc_*.rb']
105
104
  t.verbose = false
data/ext/curb.c CHANGED
@@ -235,12 +235,16 @@ static VALUE ruby_curl_http2_q(VALUE mod) {
235
235
  #endif
236
236
  }
237
237
 
238
+ static void finalize_curb_core(VALUE data) {
239
+ curl_global_cleanup();
240
+ }
241
+
238
242
  void Init_curb_core() {
239
- // TODO we need to call curl_global_cleanup at exit!
240
243
  curl_version_info_data *ver;
241
244
  VALUE curlver, curllongver, curlvernum;
242
245
 
243
246
  curl_global_init(CURL_GLOBAL_ALL);
247
+ rb_set_end_proc(finalize_curb_core, Qnil);
244
248
  ver = curl_version_info(CURLVERSION_NOW);
245
249
 
246
250
  mCurl = rb_define_module("Curl");
@@ -292,18 +296,26 @@ void Init_curb_core() {
292
296
  #endif
293
297
 
294
298
  #ifdef CURL_VERSION_SSL
295
- rb_define_const(mCurl, "CURL_SSLVERSION_DEFAULT", LONG2NUM(CURL_SSLVERSION_DEFAULT));
299
+ rb_define_const(mCurl, "CURL_SSLVERSION_DEFAULT", LONG2NUM(CURL_SSLVERSION_DEFAULT));
300
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_DEFAULT", LONG2NUM(CURL_SSLVERSION_MAX_DEFAULT));
296
301
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", LONG2NUM(CURL_SSLVERSION_TLSv1));
297
302
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", LONG2NUM(CURL_SSLVERSION_SSLv2));
298
303
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", LONG2NUM(CURL_SSLVERSION_SSLv3));
299
304
  #if HAVE_CURL_SSLVERSION_TLSV1_0
300
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(CURL_SSLVERSION_TLSv1_0));
305
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(CURL_SSLVERSION_TLSv1_0));
306
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_0", LONG2NUM(CURL_SSLVERSION_MAX_TLSv1_0));
301
307
  #endif
302
308
  #if HAVE_CURL_SSLVERSION_TLSV1_1
303
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(CURL_SSLVERSION_TLSv1_1));
309
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(CURL_SSLVERSION_TLSv1_1));
310
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_1", LONG2NUM(CURL_SSLVERSION_MAX_TLSv1_1));
304
311
  #endif
305
312
  #if HAVE_CURL_SSLVERSION_TLSV1_2
306
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(CURL_SSLVERSION_TLSv1_2));
313
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(CURL_SSLVERSION_TLSv1_2));
314
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_2", LONG2NUM(CURL_SSLVERSION_MAX_TLSv1_2));
315
+ #endif
316
+ #if HAVE_CURL_SSLVERSION_TLSV1_3
317
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_3", LONG2NUM(CURL_SSLVERSION_TLSv1_3));
318
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_3", LONG2NUM(CURL_SSLVERSION_MAX_TLSv1_3));
307
319
  #endif
308
320
 
309
321
  rb_define_const(mCurl, "CURL_USESSL_CONTROL", LONG2NUM(CURB_FTPSSL_CONTROL));
@@ -316,13 +328,20 @@ void Init_curb_core() {
316
328
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", LONG2NUM(-1));
317
329
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", LONG2NUM(-1));
318
330
  #if HAVE_CURL_SSLVERSION_TLSv1_0
319
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(-1));
331
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(-1));
332
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_0", LONG2NUM(-1));
320
333
  #endif
321
334
  #if HAVE_CURL_SSLVERSION_TLSv1_1
322
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(-1));
335
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(-1));
336
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_1", LONG2NUM(-1));
323
337
  #endif
324
338
  #if HAVE_CURL_SSLVERSION_TLSv1_2
325
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(-1));
339
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(-1));
340
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_2", LONG2NUM(-1));
341
+ #endif
342
+ #if HAVE_CURL_SSLVERSION_TLSv1_3
343
+ rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_3", LONG2NUM(-1));
344
+ rb_define_const(mCurl, "CURL_SSLVERSION_MAX_TLSv1_3", LONG2NUM(-1));
326
345
  #endif
327
346
 
328
347
  rb_define_const(mCurl, "CURL_USESSL_CONTROL", LONG2NUM(-1));
@@ -925,12 +944,19 @@ void Init_curb_core() {
925
944
  #endif
926
945
  #if HAVE_CURL_SSLVERSION_TLSv1_0
927
946
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_0);
947
+ CURB_DEFINE(CURL_SSLVERSION_MAX_TLSv1_0);
928
948
  #endif
929
949
  #if HAVE_CURL_SSLVERSION_TLSv1_1
930
950
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_1);
951
+ CURB_DEFINE(CURL_SSLVERSION_MAX_TLSv1_1);
931
952
  #endif
932
953
  #if HAVE_CURL_SSLVERSION_TLSv1_2
933
954
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_2);
955
+ CURB_DEFINE(CURL_SSLVERSION_MAX_TLSv1_2);
956
+ #endif
957
+ #if HAVE_CURL_SSLVERSION_TLSv1_3
958
+ CURB_DEFINE(CURL_SSLVERSION_TLSv1_3);
959
+ CURB_DEFINE(CURL_SSLVERSION_MAX_TLSv1_3);
934
960
  #endif
935
961
  #if HAVE_CURLOPT_SSL_VERIFYPEER
936
962
  CURB_DEFINE(CURLOPT_SSL_VERIFYPEER);
@@ -1050,6 +1076,126 @@ void Init_curb_core() {
1050
1076
  CURB_DEFINE(CURLOPT_HAPROXYPROTOCOL);
1051
1077
  #endif
1052
1078
 
1079
+ #if HAVE_CURLOPT_PROXY_SSL_VERIFYHOST
1080
+ CURB_DEFINE(CURLOPT_PROXY_SSL_VERIFYHOST);
1081
+ #endif
1082
+
1083
+ #if HAVE_CURLPROTO_RTMPTE
1084
+ CURB_DEFINE(CURLPROTO_RTMPTE);
1085
+ #endif
1086
+
1087
+ #if HAVE_CURLPROTO_RTMPTS
1088
+ CURB_DEFINE(CURLPROTO_RTMPTS);
1089
+ #endif
1090
+
1091
+ #if HAVE_CURLPROTO_SMBS
1092
+ CURB_DEFINE(CURLPROTO_SMBS);
1093
+ #endif
1094
+
1095
+ #if HAVE_CURLPROTO_LDAP
1096
+ CURB_DEFINE(CURLPROTO_LDAP);
1097
+ #endif
1098
+
1099
+ #if HAVE_CURLPROTO_FTP
1100
+ CURB_DEFINE(CURLPROTO_FTP);
1101
+ #endif
1102
+
1103
+ #if HAVE_CURLPROTO_SMTPS
1104
+ CURB_DEFINE(CURLPROTO_SMTPS);
1105
+ #endif
1106
+
1107
+ #if HAVE_CURLPROTO_HTTP
1108
+ CURB_DEFINE(CURLPROTO_HTTP);
1109
+ #endif
1110
+
1111
+ #if HAVE_CURLPROTO_SMTP
1112
+ CURB_DEFINE(CURLPROTO_SMTP);
1113
+ #endif
1114
+
1115
+ #if HAVE_CURLPROTO_TFTP
1116
+ CURB_DEFINE(CURLPROTO_TFTP);
1117
+ #endif
1118
+
1119
+ #if HAVE_CURLPROTO_LDAPS
1120
+ CURB_DEFINE(CURLPROTO_LDAPS);
1121
+ #endif
1122
+
1123
+ #if HAVE_CURLPROTO_IMAPS
1124
+ CURB_DEFINE(CURLPROTO_IMAPS);
1125
+ #endif
1126
+
1127
+ #if HAVE_CURLPROTO_SCP
1128
+ CURB_DEFINE(CURLPROTO_SCP);
1129
+ #endif
1130
+
1131
+ #if HAVE_CURLPROTO_SFTP
1132
+ CURB_DEFINE(CURLPROTO_SFTP);
1133
+ #endif
1134
+
1135
+ #if HAVE_CURLPROTO_TELNET
1136
+ CURB_DEFINE(CURLPROTO_TELNET);
1137
+ #endif
1138
+
1139
+ #if HAVE_CURLPROTO_FILE
1140
+ CURB_DEFINE(CURLPROTO_FILE);
1141
+ #endif
1142
+
1143
+ #if HAVE_CURLPROTO_FTPS
1144
+ CURB_DEFINE(CURLPROTO_FTPS);
1145
+ #endif
1146
+
1147
+ #if HAVE_CURLPROTO_HTTPS
1148
+ CURB_DEFINE(CURLPROTO_HTTPS);
1149
+ #endif
1150
+
1151
+ #if HAVE_CURLPROTO_IMAP
1152
+ CURB_DEFINE(CURLPROTO_IMAP);
1153
+ #endif
1154
+
1155
+ #if HAVE_CURLPROTO_POP3
1156
+ CURB_DEFINE(CURLPROTO_POP3);
1157
+ #endif
1158
+
1159
+ #if HAVE_CURLPROTO_GOPHER
1160
+ CURB_DEFINE(CURLPROTO_GOPHER);
1161
+ #endif
1162
+
1163
+ #if HAVE_CURLPROTO_DICT
1164
+ CURB_DEFINE(CURLPROTO_DICT);
1165
+ #endif
1166
+
1167
+ #if HAVE_CURLPROTO_SMB
1168
+ CURB_DEFINE(CURLPROTO_SMB);
1169
+ #endif
1170
+
1171
+ #if HAVE_CURLPROTO_RTMP
1172
+ CURB_DEFINE(CURLPROTO_RTMP);
1173
+ #endif
1174
+
1175
+ #if HAVE_CURLPROTO_ALL
1176
+ CURB_DEFINE(CURLPROTO_ALL);
1177
+ #endif
1178
+
1179
+ #if HAVE_CURLPROTO_RTMPE
1180
+ CURB_DEFINE(CURLPROTO_RTMPE);
1181
+ #endif
1182
+
1183
+ #if HAVE_CURLPROTO_RTMPS
1184
+ CURB_DEFINE(CURLPROTO_RTMPS);
1185
+ #endif
1186
+
1187
+ #if HAVE_CURLPROTO_RTMPT
1188
+ CURB_DEFINE(CURLPROTO_RTMPT);
1189
+ #endif
1190
+
1191
+ #if HAVE_CURLPROTO_POP3S
1192
+ CURB_DEFINE(CURLPROTO_POP3S);
1193
+ #endif
1194
+
1195
+ #if HAVE_CURLPROTO_RTSP
1196
+ CURB_DEFINE(CURLPROTO_RTSP);
1197
+ #endif
1198
+
1053
1199
  #if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
1054
1200
  CURB_DEFINE(CURLPIPE_NOTHING);
1055
1201
  CURB_DEFINE(CURLPIPE_HTTP1);
data/ext/curb.h CHANGED
@@ -28,11 +28,11 @@
28
28
  #include "curb_macros.h"
29
29
 
30
30
  // These should be managed from the Rake 'release' task.
31
- #define CURB_VERSION "0.9.11"
32
- #define CURB_VER_NUM 9011
33
- #define CURB_VER_MAJ 0
34
- #define CURB_VER_MIN 9
35
- #define CURB_VER_MIC 11
31
+ #define CURB_VERSION "1.0.5"
32
+ #define CURB_VER_NUM 1005
33
+ #define CURB_VER_MAJ 1
34
+ #define CURB_VER_MIN 0
35
+ #define CURB_VER_MIC 5
36
36
  #define CURB_VER_PATCH 0
37
37
 
38
38
 
@@ -49,6 +49,11 @@
49
49
  #define RHASH_SIZE(hash) RHASH(hash)->tbl->num_entries
50
50
  #endif
51
51
 
52
+ // ruby 1.8 does not provide the macro
53
+ #ifndef DBL2NUM
54
+ #define DBL2NUM(dbl) rb_float_new(dbl)
55
+ #endif
56
+
52
57
  extern VALUE mCurl;
53
58
 
54
59
  extern void Init_curb_core();