curb 0.9.2 → 0.9.11

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: c2d299f9e0dce739a74ea53589cc402c4dc2ae2b
4
- data.tar.gz: efd8d73f02b9da758c3861a93489e78bb770e4af
2
+ SHA256:
3
+ metadata.gz: ecd73a0ad8d98960321b8d523e25bad95ff25e8900e8acb187051ca40c7a1cba
4
+ data.tar.gz: c154996d92946fe83fa12d695b073d5026e4a55e92efd177bfad021461f2b313
5
5
  SHA512:
6
- metadata.gz: 364eed3e88338d6c1c7fc8028181b82e945d8d605d171d470d319a434ad7198a2900fe600e4870ac2acc680a35df4e4506471d923cee020d707888168920276d
7
- data.tar.gz: ad15467a00c66ee255ed5a605ed48426400a12901e673181c873cf56c7e793534b4b17304cd75b02fd7c15d8e51e2b7a6f1bd24e5dc36c3ffc35096ef6c1b030
6
+ metadata.gz: 48854a4f0d77befe0e81b31a3d39e826b2ef65d58d0226b617a355ba8d063ab4998853a8709ae6d2e3c4629c09ff987099398a1c884b76d95dcf956d941fc660
7
+ data.tar.gz: 3291675a74eb40f42d936bb65689da7d5f295e038ed019482d2cf115ba878232ce4e40aeb125d0fe786b5e82428320938ff3c75592a5c54a2d51fbe8589a0931
data/README.markdown CHANGED
@@ -7,19 +7,35 @@ Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the
7
7
  libcurl(3), a fully-featured client-side URL transfer library.
8
8
  cURL and libcurl live at [http://curl.haxx.se/](http://curl.haxx.se/) .
9
9
 
10
- Curb is a work-in-progress, and currently only supports libcurl's 'easy' and 'multi' modes.
10
+ Curb is a work-in-progress, and currently only supports libcurl's `easy` and `multi` modes.
11
11
 
12
12
  ## License
13
13
 
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.
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.
16
16
 
17
17
  ## You will need
18
18
 
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)
19
+ * A working Ruby installation (`1.8.7+` will work but `2.1+` preferred)
20
+ * A working libcurl development installation
21
+ (Ideally one of the versions listed in the compatibility chart below that maps to your `curb` version)
21
22
  * A sane build environment (e.g. gcc, make)
22
23
 
24
+ ## Version Compatibility chart
25
+
26
+ A **non-exhaustive** set of compatibility versions of the libcurl library
27
+ with this gem are as follows. (Note that these are only the ones that have been
28
+ tested and reported to work across a variety of platforms / rubies)
29
+
30
+ | Gem Version | Release Date | libcurl versions |
31
+ | ----------- | ----------- | ---------------- |
32
+ | 0.9.8 | Jan 2019 | 7.58 - 7.63 |
33
+ | 0.9.7 | Nov 2018 | 7.56 - 7.60 |
34
+ | 0.9.6 | May 2018 | 7.51 - 7.59 |
35
+ | 0.9.5 | May 2018 | 7.51 - 7.59 |
36
+ | 0.9.4 | Aug 2017 | 7.41 - 7.58 |
37
+ | 0.9.3 | Apr 2016 | 7.26 - 7.58 |
38
+
23
39
  ## Installation...
24
40
 
25
41
  ... will usually be as simple as:
@@ -30,19 +46,23 @@ On Windows, make sure you're using the [DevKit](http://rubyinstaller.org/downloa
30
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
31
47
  line (alter paths to your curl location, but remember to use forward slashes):
32
48
 
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
49
+ 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
50
+
51
+ Note that with Windows moving from one method of compiling to another as of Ruby `2.4` (DevKit -> MYSYS2),
52
+ the usage of Ruby `2.4+` with this gem on windows is unlikely to work. It is advised to use the
53
+ latest version of Ruby 2.3 available [HERE](https://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.3.3.exe)
34
54
 
35
- Or, if you downloaded the archive:
55
+ Or, if you downloaded the archive:
36
56
 
37
- $ rake install
57
+ $ rake compile && rake install
38
58
 
39
59
  If you have a weird setup, you might need extconf options. In this case, pass
40
60
  them like so:
41
61
 
42
- $ rake install EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever'
43
-
62
+ $ rake compile EXTCONF_OPTS='--with-curl-dir=/path/to/libcurl --prefix=/what/ever' && rake install
63
+
44
64
  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
65
+ If you do use another platform and experience problems, or if you can
46
66
  expand on the above instructions, please report the issue at http://github.com/taf2/curb/issues
47
67
 
48
68
  On Ubuntu, the dependencies can be satisfied by installing the following packages:
@@ -52,7 +72,7 @@ On Ubuntu, the dependencies can be satisfied by installing the following package
52
72
  On RedHat:
53
73
 
54
74
  $ sudo yum install ruby-devel libcurl-devel openssl-devel
55
-
75
+
56
76
  Curb has fairly extensive RDoc comments in the source. You can build the
57
77
  documentation with:
58
78
 
@@ -65,6 +85,12 @@ Curb provides two classes:
65
85
  * `Curl::Easy` - simple API, for day-to-day tasks.
66
86
  * `Curl::Multi` - more advanced API, for operating on multiple URLs simultaneously.
67
87
 
88
+ To use either, you will need to require the curb gem:
89
+
90
+ ```ruby
91
+ require 'curb'
92
+ ```
93
+
68
94
  ### Super simple API (less typing)
69
95
 
70
96
  ```ruby
@@ -74,7 +100,7 @@ puts http.body_str
74
100
  http = Curl.post("http://www.google.com/", {:foo => "bar"})
75
101
  puts http.body_str
76
102
 
77
- http = Curl.get("http://www.google.com/") do|http|
103
+ http = Curl.get("http://www.google.com/") do |http|
78
104
  http.headers['Cookie'] = 'foo=1;bar=2'
79
105
  end
80
106
  puts http.body_str
@@ -98,7 +124,7 @@ puts c.body_str
98
124
  ### Additional config:
99
125
 
100
126
  ```ruby
101
- Curl::Easy.perform("http://www.google.co.uk") do |curl|
127
+ Curl::Easy.perform("http://www.google.co.uk") do |curl|
102
128
  curl.headers["User-Agent"] = "myapp-0.0"
103
129
  curl.verbose = true
104
130
  end
@@ -107,7 +133,7 @@ end
107
133
  Same thing, more manual:
108
134
 
109
135
  ```ruby
110
- c = Curl::Easy.new("http://www.google.co.uk") do |curl|
136
+ c = Curl::Easy.new("http://www.google.co.uk") do |curl|
111
137
  curl.headers["User-Agent"] = "myapp-0.0"
112
138
  curl.verbose = true
113
139
  end
@@ -128,9 +154,9 @@ c.perform
128
154
  ### HTTP "insecure" SSL connections (like curl -k, --insecure) to avoid Curl::Err::SSLCACertificateError:
129
155
 
130
156
  ```ruby
131
- c = Curl::Easy.new("http://github.com/")
132
- c.ssl_verify_peer = false
133
- c.perform
157
+ c = Curl::Easy.new("https://github.com/")
158
+ c.ssl_verify_peer = false
159
+ c.perform
134
160
  ```
135
161
 
136
162
  ### Supplying custom handlers:
@@ -188,7 +214,7 @@ puts (c.body_str.include? "You are using HTTP/2 right now!") ? "HTTP/2" : "HTTP/
188
214
  # make multiple GET requests
189
215
  easy_options = {:follow_location => true}
190
216
  # Use Curl::CURLPIPE_MULTIPLEX for HTTP/2 multiplexing
191
- multi_options = {:pipeline => Curl::CURLPIPE_HTTP1}
217
+ multi_options = {:pipeline => Curl::CURLPIPE_HTTP1}
192
218
 
193
219
  Curl::Multi.get(['url1','url2','url3','url4','url5'], easy_options, multi_options) do|easy|
194
220
  # 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,22 @@ CLOBBER.include '**/*.log'
15
10
  CLOBBER.include '**/Makefile'
16
11
  CLOBBER.include '**/extconf.h'
17
12
 
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
+ # Load support ruby and rake files (in this order)
21
+ Dir.glob('tasks/*.rb').each { |r| load r}
22
+ Dir.glob('tasks/*.rake').each { |r| load r}
23
+
24
+ desc 'Print Ruby major version (ie "2_5")'
25
+ task :ruby_version do
26
+ print current_ruby_major
27
+ end
28
+
18
29
  def announce(msg='')
19
30
  $stderr.puts msg
20
31
  end
@@ -43,12 +54,11 @@ end
43
54
  make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
44
55
  MAKECMD = ENV['MAKE_CMD'] || make_program
45
56
  MAKEOPTS = ENV['MAKE_OPTS'] || ''
46
-
47
57
  CURB_SO = "ext/curb_core.#{(defined?(RbConfig) ? RbConfig : Config)::MAKEFILE_CONFIG['DLEXT']}"
48
58
 
49
59
  file 'ext/Makefile' => 'ext/extconf.rb' do
50
60
  Dir.chdir('ext') do
51
- ruby "extconf.rb #{ENV['EXTCONF_OPTS']}"
61
+ shell('ruby', 'extconf.rb', ENV['EXTCONF_OPTS'].to_s, live_stdout: STDOUT)
52
62
  end
53
63
  end
54
64
 
@@ -89,12 +99,12 @@ if ENV['RELTEST']
89
99
  else
90
100
  task :alltests => [:unittests, :bugtests]
91
101
  end
92
-
102
+
93
103
  Rake::TestTask.new(:unittests) do |t|
94
104
  t.test_files = FileList['tests/tc_*.rb']
95
105
  t.verbose = false
96
106
  end
97
-
107
+
98
108
  Rake::TestTask.new(:bugtests) do |t|
99
109
  t.test_files = FileList['tests/bug_*.rb']
100
110
  t.verbose = false
@@ -136,6 +146,12 @@ end
136
146
 
137
147
  desc "Publish the RDoc documentation to project web site"
138
148
  task :doc_upload => [ :doc ] do
149
+ begin
150
+ require 'rdoc/task'
151
+ rescue LoadError => e
152
+ require 'rake/rdoctask'
153
+ end
154
+
139
155
  if ENV['RELTEST']
140
156
  announce "Release Task Testing, skipping doc upload"
141
157
  else
@@ -170,7 +186,7 @@ else
170
186
  spec_source = File.read File.join(File.dirname(__FILE__),'curb.gemspec')
171
187
  spec = nil
172
188
  # see: http://gist.github.com/16215
173
- Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
189
+ Thread.new { spec = eval("#{spec_source}") }.join
174
190
  spec.validate
175
191
  Gem::Package.build(spec)
176
192
  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
@@ -272,15 +272,15 @@ void Init_curb_core() {
272
272
  /* Passed to on_debug handler to indicate that the data is protocol data sent to the peer. */
273
273
  rb_define_const(mCurl, "CURLINFO_DATA_OUT", LONG2NUM(CURLINFO_DATA_OUT));
274
274
 
275
- #ifdef HAVE_CURLFTPMETHOD_MULTICWD
275
+ #ifdef HAVE_CURLFTPMETHOD_MULTICWD
276
276
  rb_define_const(mCurl, "CURL_MULTICWD", LONG2NUM(CURLFTPMETHOD_MULTICWD));
277
277
  #endif
278
278
 
279
- #ifdef HAVE_CURLFTPMETHOD_NOCWD
279
+ #ifdef HAVE_CURLFTPMETHOD_NOCWD
280
280
  rb_define_const(mCurl, "CURL_NOCWD", LONG2NUM(CURLFTPMETHOD_NOCWD));
281
281
  #endif
282
282
 
283
- #ifdef HAVE_CURLFTPMETHOD_SINGLECWD
283
+ #ifdef HAVE_CURLFTPMETHOD_SINGLECWD
284
284
  rb_define_const(mCurl, "CURL_SINGLECWD", LONG2NUM(CURLFTPMETHOD_SINGLECWD));
285
285
  #endif
286
286
 
@@ -296,9 +296,15 @@ void Init_curb_core() {
296
296
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", LONG2NUM(CURL_SSLVERSION_TLSv1));
297
297
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", LONG2NUM(CURL_SSLVERSION_SSLv2));
298
298
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", LONG2NUM(CURL_SSLVERSION_SSLv3));
299
+ #if HAVE_CURL_SSLVERSION_TLSV1_0
299
300
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(CURL_SSLVERSION_TLSv1_0));
301
+ #endif
302
+ #if HAVE_CURL_SSLVERSION_TLSV1_1
300
303
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(CURL_SSLVERSION_TLSv1_1));
304
+ #endif
305
+ #if HAVE_CURL_SSLVERSION_TLSV1_2
301
306
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(CURL_SSLVERSION_TLSv1_2));
307
+ #endif
302
308
 
303
309
  rb_define_const(mCurl, "CURL_USESSL_CONTROL", LONG2NUM(CURB_FTPSSL_CONTROL));
304
310
  rb_define_const(mCurl, "CURL_USESSL_NONE", LONG2NUM(CURB_FTPSSL_NONE));
@@ -309,9 +315,15 @@ void Init_curb_core() {
309
315
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1", LONG2NUM(-1));
310
316
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv2", LONG2NUM(-1));
311
317
  rb_define_const(mCurl, "CURL_SSLVERSION_SSLv3", LONG2NUM(-1));
318
+ #if HAVE_CURL_SSLVERSION_TLSv1_0
312
319
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_0", LONG2NUM(-1));
320
+ #endif
321
+ #if HAVE_CURL_SSLVERSION_TLSv1_1
313
322
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_1", LONG2NUM(-1));
323
+ #endif
324
+ #if HAVE_CURL_SSLVERSION_TLSv1_2
314
325
  rb_define_const(mCurl, "CURL_SSLVERSION_TLSv1_2", LONG2NUM(-1));
326
+ #endif
315
327
 
316
328
  rb_define_const(mCurl, "CURL_USESSL_CONTROL", LONG2NUM(-1));
317
329
  rb_define_const(mCurl, "CURL_USESSL_NONE", LONG2NUM(-1));
@@ -340,6 +352,13 @@ void Init_curb_core() {
340
352
  rb_define_const(mCurl, "CURLPROXY_SOCKS5", LONG2NUM(-2));
341
353
  #endif
342
354
 
355
+ /* 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) */
356
+ #ifdef HAVE_CURLPROXY_SOCKS5_HOSTNAME
357
+ rb_define_const(mCurl, "CURLPROXY_SOCKS5_HOSTNAME", LONG2NUM(CURLPROXY_SOCKS5_HOSTNAME));
358
+ #else
359
+ rb_define_const(mCurl, "CURLPROXY_SOCKS5_HOSTNAME", LONG2NUM(-2));
360
+ #endif
361
+
343
362
  /* When passed to Curl::Easy#http_auth_types or Curl::Easy#proxy_auth_types, directs libcurl to use Basic authentication. */
344
363
  #ifdef HAVE_CURLAUTH_BASIC
345
364
  rb_define_const(mCurl, "CURLAUTH_BASIC", LONG2NUM(CURLAUTH_BASIC));
@@ -386,6 +405,9 @@ void Init_curb_core() {
386
405
  CURB_DEFINE(CURLOPT_HEADER);
387
406
  CURB_DEFINE(CURLOPT_NOPROGRESS);
388
407
  CURB_DEFINE(CURLOPT_NOSIGNAL);
408
+ #if HAVE_CURLOPT_PATH_AS_IS
409
+ CURB_DEFINE(CURLOPT_PATH_AS_IS);
410
+ #endif
389
411
  CURB_DEFINE(CURLOPT_WRITEFUNCTION);
390
412
  CURB_DEFINE(CURLOPT_WRITEDATA);
391
413
  CURB_DEFINE(CURLOPT_READFUNCTION);
@@ -570,6 +592,9 @@ void Init_curb_core() {
570
592
  CURB_DEFINE(CURLOPT_REFERER);
571
593
  CURB_DEFINE(CURLOPT_USERAGENT);
572
594
  CURB_DEFINE(CURLOPT_HTTPHEADER);
595
+ #if HAVE_CURLOPT_PROXYHEADER
596
+ CURB_DEFINE(CURLOPT_PROXYHEADER);
597
+ #endif
573
598
  #if HAVE_CURLOPT_HTTP200ALIASES
574
599
  CURB_DEFINE(CURLOPT_HTTP200ALIASES);
575
600
  #endif
@@ -594,6 +619,9 @@ void Init_curb_core() {
594
619
  #if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
595
620
  CURB_DEFINE(CURL_HTTP_VERSION_2_0);
596
621
  #endif
622
+ #if LIBCURL_VERSION_NUM >= 0x072f00 /* 7.47.0 */
623
+ CURB_DEFINE(CURL_HTTP_VERSION_2TLS);
624
+ #endif
597
625
  #if HAVE_CURLOPT_IGNORE_CONTENT_LENGTH
598
626
  CURB_DEFINE(CURLOPT_IGNORE_CONTENT_LENGTH);
599
627
  #endif
@@ -1008,6 +1036,20 @@ void Init_curb_core() {
1008
1036
  CURB_DEFINE(CURLOPT_UNIX_SOCKET_PATH);
1009
1037
  #endif
1010
1038
 
1039
+ #if HAVE_CURLOPT_PIPEWAIT
1040
+ CURB_DEFINE(CURLOPT_PIPEWAIT);
1041
+ #endif
1042
+
1043
+ #if HAVE_CURLOPT_TCP_KEEPALIVE
1044
+ CURB_DEFINE(CURLOPT_TCP_KEEPALIVE);
1045
+ CURB_DEFINE(CURLOPT_TCP_KEEPIDLE);
1046
+ CURB_DEFINE(CURLOPT_TCP_KEEPINTVL);
1047
+ #endif
1048
+
1049
+ #if HAVE_CURLOPT_HAPROXYPROTOCOL
1050
+ CURB_DEFINE(CURLOPT_HAPROXYPROTOCOL);
1051
+ #endif
1052
+
1011
1053
  #if LIBCURL_VERSION_NUM >= 0x072B00 /* 7.43.0 */
1012
1054
  CURB_DEFINE(CURLPIPE_NOTHING);
1013
1055
  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.2"
24
- #define CURB_VER_NUM 902
31
+ #define CURB_VERSION "0.9.11"
32
+ #define CURB_VER_NUM 9011
25
33
  #define CURB_VER_MAJ 0
26
- #define CURB_VER_MIN 2
27
- #define CURB_VER_MIC 0
34
+ #define CURB_VER_MIN 9
35
+ #define CURB_VER_MIC 11
28
36
  #define CURB_VER_PATCH 0
29
37
 
30
38