ethon 0.4.1 → 0.4.2

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.
@@ -2,7 +2,18 @@
2
2
 
3
3
  ## Master
4
4
 
5
- [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.4.1...master)
5
+ [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.4.2...master)
6
+
7
+ # Changelog
8
+
9
+ ## 0.4.2
10
+
11
+ [Full Changelog](http://github.com/typhoeus/ethon/compare/v0.4.1...v0.4.2)
12
+
13
+ Enhancements:
14
+
15
+ * New libcurl option forbid_reuse
16
+ * Use libcurls escape instead of CGI::escape
6
17
 
7
18
  ## 0.4.1
8
19
 
@@ -3,7 +3,6 @@ require 'ffi'
3
3
  require 'rbconfig'
4
4
  require 'thread'
5
5
  require 'mime/types'
6
- require 'cgi'
7
6
  require 'tempfile'
8
7
 
9
8
  require 'ethon/curl'
@@ -19,7 +19,8 @@ module Ethon
19
19
  # @param [ Hash ] params The parameter to initialize the form with.
20
20
  #
21
21
  # @return [ Form ] A new Form.
22
- def initialize(params)
22
+ def initialize(easy, params)
23
+ @easy = easy
23
24
  @params = params || {}
24
25
  ObjectSpace.define_finalizer(self, self.class.finalizer(self))
25
26
  end
@@ -49,7 +49,7 @@ module Ethon
49
49
  #
50
50
  # @return [ Params ] The params.
51
51
  def params
52
- @params ||= Params.new(options.delete(:params))
52
+ @params ||= Params.new(@easy, options.delete(:params))
53
53
  end
54
54
 
55
55
  # Return the form.
@@ -59,7 +59,7 @@ module Ethon
59
59
  #
60
60
  # @return [ Form ] The form.
61
61
  def form
62
- @form ||= Form.new(options.delete(:body))
62
+ @form ||= Form.new(@easy, options.delete(:body))
63
63
  end
64
64
 
65
65
  # Setup everything necessary for a proper request.
@@ -69,6 +69,7 @@ module Ethon
69
69
  #
70
70
  # @param [ easy ] easy the easy to setup.
71
71
  def setup(easy)
72
+ @easy = easy
72
73
  set_nothing(easy) if params.empty? && form.empty?
73
74
  set_params(easy) unless params.empty?
74
75
  set_form(easy) unless form.empty?
@@ -11,7 +11,7 @@ module Ethon
11
11
  base.const_set(:AVAILABLE_OPTIONS, [
12
12
  :dns_cache_timeout, :httppost, :put, :httpget, :nobody, :upload,
13
13
  :customrequest, :cainfo, :capath, :connecttimeout,
14
- :followlocation, :httpauth, :infilesize, :interface,
14
+ :forbid_reuse, :followlocation, :httpauth, :infilesize, :interface,
15
15
  :maxredirs, :nosignal, :postfieldsize, :copypostfields, :proxy,
16
16
  :proxyauth, :proxyport, :proxytype, :timeout, :readdata, :sslcert,
17
17
  :ssl_verifypeer, :ssl_verifyhost, :sslcerttype, :sslkey, :sslkeytype,
@@ -40,7 +40,7 @@ module Ethon
40
40
  # @return [ Array ] The bool options.
41
41
  def bool_options
42
42
  [
43
- :followlocation, :nosignal, :ssl_verifypeer,
43
+ :followlocation, :forbid_reuse, :nosignal, :ssl_verifypeer,
44
44
  :verbose, :httpget, :nobody, :upload
45
45
  ]
46
46
  end
@@ -17,7 +17,8 @@ module Ethon
17
17
  # @param [ Hash ] params The params to use.
18
18
  #
19
19
  # @return [ Params ] A new Params.
20
- def initialize(params)
20
+ def initialize(easy, params)
21
+ @easy = easy
21
22
  @params = params || {}
22
23
  end
23
24
  end
@@ -31,7 +31,7 @@ module Ethon
31
31
  return pair if pair.is_a?(String)
32
32
 
33
33
  pair.map{ |e|
34
- escape ? CGI::escape(e.to_s) : e
34
+ escape && @easy ? @easy.escape(e.to_s) : e
35
35
  }.join("=")
36
36
  }.join('&')
37
37
  end
@@ -80,6 +80,8 @@ module Ethon
80
80
  # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTDNSCACHETIMEOUT.
81
81
  # @option options :followlocation [Boolean] See
82
82
  # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTFOLLOWLOCATION.
83
+ # @option options :forbid_reuse [Boolean] See
84
+ # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTFORBIDREUSE.
83
85
  # @option options :httpauth [String] See
84
86
  # http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPAUTH.
85
87
  # @option options :httpget [Boolean] See
@@ -177,6 +179,10 @@ module Ethon
177
179
  Curl.easy_reset(handle)
178
180
  end
179
181
 
182
+ def escape(value)
183
+ Curl.easy_escape(handle, value, 0)
184
+ end
185
+
180
186
  # Returns a pointer to the curl easy handle.
181
187
  #
182
188
  # @example Return the handle.
@@ -1,5 +1,5 @@
1
1
  module Ethon
2
2
 
3
3
  # Ethon version.
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -264,7 +264,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
264
264
  version: '0'
265
265
  segments:
266
266
  - 0
267
- hash: 1338934003639649204
267
+ hash: -4306933410699182262
268
268
  required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  none: false
270
270
  requirements: