curb 0.9.3 → 1.0.2

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
- SHA1:
3
- metadata.gz: 2964444d7cc4bfb4e2e5f64e9abe3ecaa7b0dacc
4
- data.tar.gz: 170341c4d16f2f3974ab95b170a5dbe89710785f
2
+ SHA256:
3
+ metadata.gz: b338d766fda8dfadab0c602cdad4a9f15a529bb495725b15ca5def63a9d8390a
4
+ data.tar.gz: 5b074f1154e3da7ce37eee89e6e5a577a2c09202b6baee72afd2098eac986bd7
5
5
  SHA512:
6
- metadata.gz: bea120408008fed02a50784ba8655547c9f79a4217b8754ec8cd5605f687b6a414151d0e561294bf33713968e823dc204fce1952bd18af14ab94cf577416be5c
7
- data.tar.gz: e31a107d26330271becb884c663b64944d614057a6918bc345a8926155b52d6fc25798f9f956e9b62bcd94daf619afee54c8f6a6a809df752331a53eb54d5fc1
6
+ metadata.gz: 59a25fdf7add62512432495a89d6c8832513ecbc94bb14e7e5720abbfbfea24e0ae52c77fe10497871c6683f39e6988ff184088318e06a14848ab764db38bea2
7
+ data.tar.gz: 4fc8fb4b8111f102107cabc002f1b1a11d2f73e9b66d188ebaf3027a803c90868184c751a3448639bf23ca62eace0a227769aff716a4ba0a8a39b23888346097
data/README.markdown CHANGED
@@ -1,25 +1,65 @@
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
- Curb is a work-in-progress, and currently only supports libcurl's 'easy' and 'multi' modes.
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
- Ruby license. See the LICENSE file for the gory details.
15
+ Curb is copyright (c)2006 Ross Bamford, and released under the terms of the
16
+ Ruby license. See the LICENSE file for the gory details.
17
+
18
+ ## Easy mode
19
+
20
+ Get stuff
21
+ ```
22
+ res = Curl.get("https://www.google.com/")
23
+ puts res.response_code
24
+ puts res.header_str
25
+ puts res.body
26
+ ```
27
+
28
+ Post stuff
29
+ ```
30
+ res = Curl.post("https://your-server.com/endpoint", {post: "this"}.to_json) {|http|
31
+ http.headers["Content-Type"] = "application/json"
32
+ }
33
+ puts res.response_code
34
+ puts res.header_str
35
+ puts res.body
36
+ ```
37
+
38
+
16
39
 
17
40
  ## You will need
18
41
 
19
- * A working Ruby installation (1.8+, tested with 1.8.6, 1.8.7, 1.9.1, and 1.9.2)
20
- * A working (lib)curl installation, with development stuff (7.5+, tested with 7.19.x)
42
+ * 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...)
43
+ * A working libcurl development installation
44
+ (Ideally one of the versions listed in the compatibility chart below that maps to your `curb` version)
21
45
  * A sane build environment (e.g. gcc, make)
22
46
 
47
+ ## Version Compatibility chart
48
+
49
+ A **non-exhaustive** set of compatibility versions of the libcurl library
50
+ with this gem are as follows. (Note that these are only the ones that have been
51
+ tested and reported to work across a variety of platforms / rubies)
52
+
53
+ | Gem Version | Release Date | libcurl versions |
54
+ | ----------- | ----------- | ---------------- |
55
+ | 1.0.0 | Jan 2022 | 7.58 - 7.81 |
56
+ | 0.9.8 | Jan 2019 | 7.58 - 7.81 |
57
+ | 0.9.7 | Nov 2018 | 7.56 - 7.60 |
58
+ | 0.9.6 | May 2018 | 7.51 - 7.59 |
59
+ | 0.9.5 | May 2018 | 7.51 - 7.59 |
60
+ | 0.9.4 | Aug 2017 | 7.41 - 7.58 |
61
+ | 0.9.3 | Apr 2016 | 7.26 - 7.58 |
62
+
23
63
  ## Installation...
24
64
 
25
65
  ... will usually be as simple as:
@@ -27,32 +67,42 @@ Ruby license. See the LICENSE file for the gory details.
27
67
  $ gem install curb
28
68
 
29
69
  On Windows, make sure you're using the [DevKit](http://rubyinstaller.org/downloads/) and
30
- 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
70
+ 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
31
71
  line (alter paths to your curl location, but remember to use forward slashes):
32
72
 
33
- gem install curb --platform=ruby -- --with-curl-lib=C:/curl-7.39.0-devel-mingw32/bin --with-curl-include=C:/curl-7.39.0-devel-mingw32/include
73
+ 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
74
+
75
+ Note that with Windows moving from one method of compiling to another as of Ruby `2.4` (DevKit -> MYSYS2),
76
+ the usage of Ruby `2.4+` with this gem on windows is unlikely to work. It is advised to use the
77
+ latest version of Ruby 2.3 available [HERE](https://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.3.3.exe)
34
78
 
35
- Or, if you downloaded the archive:
79
+ Or, if you downloaded the archive:
36
80
 
37
- $ rake install
81
+ $ rake compile && rake install
38
82
 
39
83
  If you have a weird setup, you might need extconf options. In this case, pass
40
84
  them like so:
41
85
 
42
- $ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'
43
-
86
+ $ rake compile EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever' && rake install
87
+
44
88
  Curb is tested only on GNU/Linux x86 and Mac OSX - YMMV on other platforms.
45
- If you do use another platform and experience problems, or if you can
89
+ If you do use another platform and experience problems, or if you can
46
90
  expand on the above instructions, please report the issue at http://github.com/taf2/curb/issues
47
91
 
48
92
  On Ubuntu, the dependencies can be satisfied by installing the following packages:
49
93
 
94
+ 18.04 and onwards
95
+
96
+ $ sudo apt-get install libcurl4 libcurl3-gnutls libcurl4-openssl-dev
97
+
98
+ < 18.04
99
+
50
100
  $ sudo apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev
51
101
 
52
102
  On RedHat:
53
103
 
54
104
  $ sudo yum install ruby-devel libcurl-devel openssl-devel
55
-
105
+
56
106
  Curb has fairly extensive RDoc comments in the source. You can build the
57
107
  documentation with:
58
108
 
@@ -65,6 +115,12 @@ Curb provides two classes:
65
115
  * `Curl::Easy` - simple API, for day-to-day tasks.
66
116
  * `Curl::Multi` - more advanced API, for operating on multiple URLs simultaneously.
67
117
 
118
+ To use either, you will need to require the curb gem:
119
+
120
+ ```ruby
121
+ require 'curb'
122
+ ```
123
+
68
124
  ### Super simple API (less typing)
69
125
 
70
126
  ```ruby
@@ -74,7 +130,7 @@ puts http.body_str
74
130
  http = Curl.post("http://www.google.com/", {:foo => "bar"})
75
131
  puts http.body_str
76
132
 
77
- http = Curl.get("http://www.google.com/") do|http|
133
+ http = Curl.get("http://www.google.com/") do |http|
78
134
  http.headers['Cookie'] = 'foo=1;bar=2'
79
135
  end
80
136
  puts http.body_str
@@ -98,7 +154,7 @@ puts c.body_str
98
154
  ### Additional config:
99
155
 
100
156
  ```ruby
101
- Curl::Easy.perform("http://www.google.co.uk") do |curl|
157
+ Curl::Easy.perform("http://www.google.co.uk") do |curl|
102
158
  curl.headers["User-Agent"] = "myapp-0.0"
103
159
  curl.verbose = true
104
160
  end
@@ -107,7 +163,7 @@ end
107
163
  Same thing, more manual:
108
164
 
109
165
  ```ruby
110
- c = Curl::Easy.new("http://www.google.co.uk") do |curl|
166
+ c = Curl::Easy.new("http://www.google.co.uk") do |curl|
111
167
  curl.headers["User-Agent"] = "myapp-0.0"
112
168
  curl.verbose = true
113
169
  end
@@ -128,9 +184,9 @@ c.perform
128
184
  ### HTTP "insecure" SSL connections (like curl -k, --insecure) to avoid Curl::Err::SSLCACertificateError:
129
185
 
130
186
  ```ruby
131
- c = Curl::Easy.new("http://github.com/")
132
- c.ssl_verify_peer = false
133
- c.perform
187
+ c = Curl::Easy.new("https://github.com/")
188
+ c.ssl_verify_peer = false
189
+ c.perform
134
190
  ```
135
191
 
136
192
  ### Supplying custom handlers:
@@ -188,7 +244,7 @@ puts (c.body_str.include? "You are using HTTP/2 right now!") ? "HTTP/2" : "HTTP/
188
244
  # make multiple GET requests
189
245
  easy_options = {:follow_location => true}
190
246
  # Use Curl::CURLPIPE_MULTIPLEX for HTTP/2 multiplexing
191
- multi_options = {:pipeline => Curl::CURLPIPE_HTTP1}
247
+ multi_options = {:pipeline => Curl::CURLPIPE_HTTP1}
192
248
 
193
249
  Curl::Multi.get(['url1','url2','url3','url4','url5'], easy_options, multi_options) do|easy|
194
250
  # do something interesting with the easy response
data/Rakefile CHANGED
@@ -2,11 +2,6 @@
2
2
  #
3
3
  require 'rake/clean'
4
4
  require 'rake/testtask'
5
- begin
6
- require 'rdoc/task'
7
- rescue LoadError => e
8
- require 'rake/rdoctask'
9
- end
10
5
 
11
6
  CLEAN.include '**/*.o'
12
7
  CLEAN.include "**/*.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
@@ -15,6 +10,15 @@ CLOBBER.include '**/*.log'
15
10
  CLOBBER.include '**/Makefile'
16
11
  CLOBBER.include '**/extconf.h'
17
12
 
13
+ # Load support ruby and rake files (in this order)
14
+ Dir.glob('tasks/*.rb').each { |r| load r}
15
+ Dir.glob('tasks/*.rake').each { |r| load r}
16
+
17
+ desc 'Print Ruby major version (ie "2_5")'
18
+ task :ruby_version do
19
+ print current_ruby_major
20
+ end
21
+
18
22
  def announce(msg='')
19
23
  $stderr.puts msg
20
24
  end
@@ -43,26 +47,23 @@ end
43
47
  make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
44
48
  MAKECMD = ENV['MAKE_CMD'] || make_program
45
49
  MAKEOPTS = ENV['MAKE_OPTS'] || ''
46
-
47
50
  CURB_SO = "ext/curb_core.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
48
51
 
49
52
  file 'ext/Makefile' => 'ext/extconf.rb' do
50
- Dir.chdir('ext') do
51
- ruby "extconf.rb #{ENV['EXTCONF_OPTS']}"
52
- end
53
+ shell(['ruby', 'extconf.rb', ENV['EXTCONF_OPTS'].to_s],
54
+ { :live_stdout => STDOUT , :cwd => "#{Dir.pwd}/ext" }
55
+ ).error!
53
56
  end
54
57
 
55
58
  def make(target = '')
56
- Dir.chdir('ext') do
57
- pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
58
- $?.exitstatus
59
- end
59
+ shell(["#{MAKECMD}", "#{MAKEOPTS}", "#{target}"].reject(&:empty?),
60
+ { :live_stdout => STDOUT, :cwd => "#{Dir.pwd}/ext" }
61
+ ).error!
60
62
  end
61
63
 
62
64
  # Let make handle dependencies between c/o/so - we'll just run it.
63
65
  file CURB_SO => (['ext/Makefile'] + Dir['ext/*.c'] + Dir['ext/*.h']) do
64
- m = make
65
- fail "Make failed (status #{m})" unless m == 0
66
+ make
66
67
  end
67
68
 
68
69
  desc "Compile the shared object"
@@ -70,8 +71,7 @@ task :compile => [CURB_SO]
70
71
 
71
72
  desc "Install to your site_ruby directory"
72
73
  task :install do
73
- m = make 'install'
74
- fail "Make install failed (status #{m})" unless m == 0
74
+ make 'install'
75
75
  end
76
76
 
77
77
  # Test Tasks ---------------------------------------------------------
@@ -89,12 +89,12 @@ if ENV['RELTEST']
89
89
  else
90
90
  task :alltests => [:unittests, :bugtests]
91
91
  end
92
-
92
+
93
93
  Rake::TestTask.new(:unittests) do |t|
94
94
  t.test_files = FileList['tests/tc_*.rb']
95
95
  t.verbose = false
96
96
  end
97
-
97
+
98
98
  Rake::TestTask.new(:bugtests) do |t|
99
99
  t.test_files = FileList['tests/bug_*.rb']
100
100
  t.verbose = false
@@ -136,6 +136,12 @@ end
136
136
 
137
137
  desc "Publish the RDoc documentation to project web site"
138
138
  task :doc_upload => [ :doc ] do
139
+ begin
140
+ require 'rdoc/task'
141
+ rescue LoadError => e
142
+ require 'rake/rdoctask'
143
+ end
144
+
139
145
  if ENV['RELTEST']
140
146
  announce "Release Task Testing, skipping doc upload"
141
147
  else
@@ -170,7 +176,7 @@ else
170
176
  spec_source = File.read File.join(File.dirname(__FILE__),'curb.gemspec')
171
177
  spec = nil
172
178
  # see: http://gist.github.com/16215
173
- Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
179
+ Thread.new { spec = eval("#{spec_source}") }.join
174
180
  spec.validate
175
181
  Gem::Package.build(spec)
176
182
  end
data/ext/banned.h ADDED
@@ -0,0 +1,32 @@
1
+ #ifndef BANNED_H
2
+ #define BANNED_H
3
+
4
+ /*
5
+ * This header lists functions that have been banned from our code base,
6
+ * because they're too easy to misuse (and even if used correctly,
7
+ * complicate audits). Including this header turns them into compile-time
8
+ * errors.
9
+ */
10
+
11
+ #define BANNED(func) sorry_##func##_is_a_banned_function
12
+
13
+ #undef strcpy
14
+ #define strcpy(x,y) BANNED(strcpy)
15
+ #undef strcat
16
+ #define strcat(x,y) BANNED(strcat)
17
+ #undef strncpy
18
+ #define strncpy(x,y,n) BANNED(strncpy)
19
+ #undef strncat
20
+ #define strncat(x,y,n) BANNED(strncat)
21
+
22
+ #undef sprintf
23
+ #undef vsprintf
24
+ #ifdef HAVE_VARIADIC_MACROS
25
+ #define sprintf(...) BANNED(sprintf)
26
+ #define vsprintf(...) BANNED(vsprintf)
27
+ #else
28
+ #define sprintf(buf,fmt,arg) BANNED(sprintf)
29
+ #define vsprintf(buf,fmt,arg) BANNED(sprintf)
30
+ #endif
31
+
32
+ #endif /* BANNED_H */
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");
@@ -272,15 +276,15 @@ void Init_curb_core() {
272
276
  /* Passed to on_debug handler to indicate that the data is protocol data sent to the peer. */
273
277
  rb_define_const(mCurl, "CURLINFO_DATA_OUT", LONG2NUM(CURLINFO_DATA_OUT));
274
278
 
275
- #ifdef HAVE_CURLFTPMETHOD_MULTICWD
279
+ #ifdef HAVE_CURLFTPMETHOD_MULTICWD
276
280
  rb_define_const(mCurl, "CURL_MULTICWD", LONG2NUM(CURLFTPMETHOD_MULTICWD));
277
281
  #endif
278
282
 
279
- #ifdef HAVE_CURLFTPMETHOD_NOCWD
283
+ #ifdef HAVE_CURLFTPMETHOD_NOCWD
280
284
  rb_define_const(mCurl, "CURL_NOCWD", LONG2NUM(CURLFTPMETHOD_NOCWD));
281
285
  #endif
282
286
 
283
- #ifdef HAVE_CURLFTPMETHOD_SINGLECWD
287
+ #ifdef HAVE_CURLFTPMETHOD_SINGLECWD
284
288
  rb_define_const(mCurl, "CURL_SINGLECWD", LONG2NUM(CURLFTPMETHOD_SINGLECWD));
285
289
  #endif
286
290
 
@@ -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
- #if HAVE_CURL_SSLVERSION_TLSv1_0
300
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(CURL_SSLVERSION_TLSv1_0));
304
+ #if HAVE_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
- #if HAVE_CURL_SSLVERSION_TLSv1_1
303
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(CURL_SSLVERSION_TLSv1_1));
308
+ #if HAVE_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
- #if HAVE_CURL_SSLVERSION_TLSv1_2
306
- rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(CURL_SSLVERSION_TLSv1_2));
312
+ #if HAVE_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));
@@ -352,6 +371,13 @@ void Init_curb_core() {
352
371
  rb_define_const(mCurl, "CURLPROXY_SOCKS5", LONG2NUM(-2));
353
372
  #endif
354
373
 
374
+ /* When passed to Curl::Easy#proxy_type , indicates that the proxy is a SOCKS5 proxy (and that the proxy should resolve the hostname). (libcurl >= 7.17.2) */
375
+ #ifdef HAVE_CURLPROXY_SOCKS5_HOSTNAME
376
+ rb_define_const(mCurl, "CURLPROXY_SOCKS5_HOSTNAME", LONG2NUM(CURLPROXY_SOCKS5_HOSTNAME));
377
+ #else
378
+ rb_define_const(mCurl, "CURLPROXY_SOCKS5_HOSTNAME", LONG2NUM(-2));
379
+ #endif
380
+
355
381
  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Basic authentication. */
356
382
  #ifdef HAVE_CURLAUTH_BASIC
357
383
  rb_define_const(mCurl, "CURLAUTH_BASIC", LONG2NUM(CURLAUTH_BASIC));
@@ -398,6 +424,9 @@ void Init_curb_core() {
398
424
  CURB_DEFINE(CURLOPT_HEADER);
399
425
  CURB_DEFINE(CURLOPT_NOPROGRESS);
400
426
  CURB_DEFINE(CURLOPT_NOSIGNAL);
427
+ #if HAVE_CURLOPT_PATH_AS_IS
428
+ CURB_DEFINE(CURLOPT_PATH_AS_IS);
429
+ #endif
401
430
  CURB_DEFINE(CURLOPT_WRITEFUNCTION);
402
431
  CURB_DEFINE(CURLOPT_WRITEDATA);
403
432
  CURB_DEFINE(CURLOPT_READFUNCTION);
@@ -582,6 +611,9 @@ void Init_curb_core() {
582
611
  CURB_DEFINE(CURLOPT_REFERER);
583
612
  CURB_DEFINE(CURLOPT_USERAGENT);
584
613
  CURB_DEFINE(CURLOPT_HTTPHEADER);
614
+ #if HAVE_CURLOPT_PROXYHEADER
615
+ CURB_DEFINE(CURLOPT_PROXYHEADER);
616
+ #endif
585
617
  #if HAVE_CURLOPT_HTTP200ALIASES
586
618
  CURB_DEFINE(CURLOPT_HTTP200ALIASES);
587
619
  #endif
@@ -606,6 +638,9 @@ void Init_curb_core() {
606
638
  #if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
607
639
  CURB_DEFINE(CURL_HTTP_VERSION_2_0);
608
640
  #endif
641
+ #if LIBCURL_VERSION_NUM >= 0x072f00 /* 7.47.0 */
642
+ CURB_DEFINE(CURL_HTTP_VERSION_2TLS);
643
+ #endif
609
644
  #if HAVE_CURLOPT_IGNORE_CONTENT_LENGTH
610
645
  CURB_DEFINE(CURLOPT_IGNORE_CONTENT_LENGTH);
611
646
  #endif
@@ -909,12 +944,19 @@ void Init_curb_core() {
909
944
  #endif
910
945
  #if HAVE_CURL_SSLVERSION_TLSv1_0
911
946
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_0);
947
+ CURB_DEFINE(CURL_SSLVERSION_MAX_TLSv1_0);
912
948
  #endif
913
949
  #if HAVE_CURL_SSLVERSION_TLSv1_1
914
950
  CURB_DEFINE(CURL_SSLVERSION_TLSv1_1);
951
+ CURB_DEFINE(CURL_SSLVERSION_MAX_TLSv1_1);
915
952
  #endif
916
953
  #if HAVE_CURL_SSLVERSION_TLSv1_2
917
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);
918
960
  #endif
919
961
  #if HAVE_CURLOPT_SSL_VERIFYPEER
920
962
  CURB_DEFINE(CURLOPT_SSL_VERIFYPEER);
@@ -1020,6 +1062,140 @@ void Init_curb_core() {
1020
1062
  CURB_DEFINE(CURLOPT_UNIX_SOCKET_PATH);
1021
1063
  #endif
1022
1064
 
1065
+ #if HAVE_CURLOPT_PIPEWAIT
1066
+ CURB_DEFINE(CURLOPT_PIPEWAIT);
1067
+ #endif
1068
+
1069
+ #if HAVE_CURLOPT_TCP_KEEPALIVE
1070
+ CURB_DEFINE(CURLOPT_TCP_KEEPALIVE);
1071
+ CURB_DEFINE(CURLOPT_TCP_KEEPIDLE);
1072
+ CURB_DEFINE(CURLOPT_TCP_KEEPINTVL);
1073
+ #endif
1074
+
1075
+ #if HAVE_CURLOPT_HAPROXYPROTOCOL
1076
+ CURB_DEFINE(CURLOPT_HAPROXYPROTOCOL);
1077
+ #endif
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
+
1023
1199
  #if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
1024
1200
  CURB_DEFINE(CURLPIPE_NOTHING);
1025
1201
  CURB_DEFINE(CURLPIPE_HTTP1);
data/ext/curb.h CHANGED
@@ -9,8 +9,16 @@
9
9
  #define __CURB_H
10
10
 
11
11
  #include <ruby.h>
12
+
13
+ #ifdef HAVE_RUBY_IO_H
14
+ #include "ruby/io.h"
15
+ #else
16
+ #include "rubyio.h" // ruby 1.8
17
+ #endif
18
+
12
19
  #include <curl/curl.h>
13
20
 
21
+ #include "banned.h"
14
22
  #include "curb_config.h"
15
23
  #include "curb_easy.h"
16
24
  #include "curb_errors.h"
@@ -20,11 +28,11 @@
20
28
  #include "curb_macros.h"
21
29
 
22
30
  // These should be managed from the Rake 'release' task.
23
- #define CURB_VERSION "0.9.3"
24
- #define CURB_VER_NUM 903
25
- #define CURB_VER_MAJ 0
26
- #define CURB_VER_MIN 3
27
- #define CURB_VER_MIC 0
31
+ #define CURB_VERSION "1.0.2"
32
+ #define CURB_VER_NUM 1002
33
+ #define CURB_VER_MAJ 1
34
+ #define CURB_VER_MIN 0
35
+ #define CURB_VER_MIC 2
28
36
  #define CURB_VER_PATCH 0
29
37
 
30
38
 
@@ -41,6 +49,11 @@
41
49
  #define RHASH_SIZE(hash) RHASH(hash)->tbl->num_entries
42
50
  #endif
43
51
 
52
+ // ruby 1.8 does not provide the macro
53
+ #ifndef DBL2NUM
54
+ #define DBL2NUM(dbl) rb_float_new(dbl)
55
+ #endif
56
+
44
57
  extern VALUE mCurl;
45
58
 
46
59
  extern void Init_curb_core();