excon 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of excon might be problematic. Click here for more details.

@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- excon (0.4.0)
4
+ excon (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -137,23 +137,25 @@ end
137
137
  # +--------------------------+----------+
138
138
  # | tach | total |
139
139
  # +--------------------------+----------+
140
- # | Excon (persistent) | 1.521565 |
140
+ # | Excon (persistent) | 1.529095 |
141
141
  # +--------------------------+----------+
142
- # | Excon | 1.624180 |
142
+ # | curb (persistent) | 1.740387 |
143
143
  # +--------------------------+----------+
144
- # | Typhoeus | 1.918563 |
144
+ # | Typhoeus | 1.876236 |
145
145
  # +--------------------------+----------+
146
- # | StreamlyFFI (persistent) | 1.933218 |
146
+ # | Excon | 2.001858 |
147
147
  # +--------------------------+----------+
148
- # | Net::HTTP (persistent) | 2.418454 |
148
+ # | StreamlyFFI (persistent) | 2.200701 |
149
149
  # +--------------------------+----------+
150
- # | Net::HTTP | 2.439801 |
150
+ # | Net::HTTP | 2.395704 |
151
151
  # +--------------------------+----------+
152
- # | HTTParty | 2.609180 |
152
+ # | Net::HTTP (persistent) | 2.418099 |
153
153
  # +--------------------------+----------+
154
- # | RestClient | 2.905853 |
154
+ # | HTTParty | 2.659317 |
155
155
  # +--------------------------+----------+
156
- # | open-uri | 2.936382 |
156
+ # | RestClient | 2.958159 |
157
157
  # +--------------------------+----------+
158
- # | em-http-request | 3.933757 |
158
+ # | open-uri | 2.987051 |
159
159
  # +--------------------------+----------+
160
+ # | em-http-request | 4.123798 |
161
+ # +--------------------------+----------+
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'excon'
16
- s.version = '0.5.0'
16
+ s.version = '0.5.1'
17
17
  s.date = '2011-02-11'
18
18
  s.rubyforge_project = 'excon'
19
19
 
@@ -13,23 +13,13 @@ require 'excon/response'
13
13
 
14
14
  module Excon
15
15
  unless const_defined?(:VERSION)
16
- VERSION = '0.5.0'
16
+ VERSION = '0.5.1'
17
17
  end
18
18
 
19
19
  unless const_defined?(:CHUNK_SIZE)
20
20
  CHUNK_SIZE = 1048576 # 1 megabyte
21
21
  end
22
22
 
23
- # @see Connection#initialize
24
- # Initializes a new keep-alive session for a given remote host
25
- # @param [String] url The destination URL
26
- # @param [Hash<Symbol, >] params One or more option params to set on the Connection instance
27
- # @return [Connection] A new Excon::Connection instance
28
- def self.new(url, params = {})
29
- Excon::Connection.new(url, params)
30
- end
31
-
32
- # Class-level instance variables and generic HTTP methods
33
23
  class << self
34
24
  # @return [String] The filesystem path to the SSL Certificate Authority
35
25
  attr_accessor :ssl_ca_path
@@ -40,6 +30,22 @@ module Excon
40
30
  # setup ssl defaults based on platform
41
31
  @ssl_verify_peer = Config::CONFIG['host_os'] !~ /mswin|win32|dos|cygwin|mingw/i
42
32
 
33
+ # @see Connection#initialize
34
+ # Initializes a new keep-alive session for a given remote host
35
+ # @param [String] url The destination URL
36
+ # @param [Hash<Symbol, >] params One or more option params to set on the Connection instance
37
+ # @return [Connection] A new Excon::Connection instance
38
+ def new(url, params = {})
39
+ Excon::Connection.new(url, params)
40
+ end
41
+
42
+ # Change the status of ssl peer verification
43
+ # @see Excon#ssl_verify_peer (attr_reader)
44
+ def ssl_verify_peer=(new_ssl_verify_peer)
45
+ @ssl_verify_peer = new_ssl_verify_peer && true || false
46
+ end
47
+
48
+ # Generic non-persistent HTTP methods
43
49
  %w{connect delete get head options post put trace}.each do |method|
44
50
  eval <<-DEF
45
51
  def #{method}(url, params = {}, &block)
@@ -48,10 +54,4 @@ module Excon
48
54
  DEF
49
55
  end
50
56
  end
51
-
52
- # Change the status of ssl peer verification
53
- # @see Excon#ssl_verify_peer (attr_reader)
54
- def self.ssl_verify_peer=(new_ssl_verify_peer)
55
- @ssl_verify_peer = new_ssl_verify_peer && true || false
56
- end
57
57
  end
@@ -10,6 +10,7 @@ module Excon
10
10
 
11
11
  def self.parse(socket, params={})
12
12
  response = new(:status => socket.readline[9, 11].to_i)
13
+ block_given = block_given?
13
14
 
14
15
  while true
15
16
  (data = socket.readline).chop!
@@ -24,48 +25,47 @@ module Excon
24
25
 
25
26
  unless params[:method].to_s.casecmp('HEAD') == 0
26
27
 
27
- if response.headers.has_key?('Transfer-Encoding') && response.headers['Transfer-Encoding'].casecmp('chunked') == 0
28
- while true
29
- chunk_size = socket.readline.chop!.to_i(16)
30
-
31
- break if chunk_size < 1
32
- # 2 == "/r/n".length
33
- (chunk = socket.read(chunk_size+2)).chop!
28
+ # don't pass stuff into a block if there was an error
29
+ if params[:expects] && ![*params[:expects]].include?(response.status)
30
+ block_given = false
31
+ end
34
32
 
35
- if block_given?
36
- yield chunk
37
- else
38
- response.body << chunk
33
+ if block_given
34
+ if response.headers.has_key?('Transfer-Encoding') && response.headers['Transfer-Encoding'].casecmp('chunked') == 0
35
+ while true
36
+ chunk_size = socket.readline.chop!.to_i(16)
37
+ break if chunk_size < 1
38
+ yield socket.read(chunk_size+2).chop! # 2 == "/r/n".length
39
+ end
40
+ elsif response.headers.has_key?('Connection') && response.headers['Connection'].casecmp('close') == 0
41
+ yield socket.read
42
+ elsif response.headers.has_key?('Content-Length')
43
+ remaining = response.headers['Content-Length'].to_i
44
+ while remaining > 0
45
+ yield socket.read([CHUNK_SIZE, remaining].min)
46
+ remaining -= CHUNK_SIZE
39
47
  end
40
48
  end
41
-
42
- elsif response.headers.has_key?('Connection') && response.headers['Connection'].casecmp('close') == 0
43
- chunk = socket.read
44
-
45
- if block_given?
46
- yield chunk
47
- else
48
- response.body << chunk
49
- end
50
-
51
- elsif response.headers.has_key?('Content-Length')
52
- remaining = response.headers['Content-Length'].to_i
53
-
54
- while remaining > 0
55
- chunk = socket.read([CHUNK_SIZE, remaining].min)
56
-
57
- if block_given?
58
- yield chunk
59
- else
60
- response.body << chunk
49
+ else
50
+ if response.headers.has_key?('Transfer-Encoding') && response.headers['Transfer-Encoding'].casecmp('chunked') == 0
51
+ while true
52
+ chunk_size = socket.readline.chop!.to_i(16)
53
+ break if chunk_size < 1
54
+ response.body << socket.read(chunk_size + 2).chop! # 2 == "/r/n".length
55
+ end
56
+ elsif response.headers.has_key?('Connection') && response.headers['Connection'].casecmp('close') == 0
57
+ response.body << socket.read
58
+ elsif response.headers.has_key?('Content-Length')
59
+ remaining = response.headers['Content-Length'].to_i
60
+ while remaining > 0
61
+ response.body << socket.read([CHUNK_SIZE, remaining].min)
62
+ remaining -= CHUNK_SIZE
61
63
  end
62
-
63
- remaining -= CHUNK_SIZE
64
64
  end
65
65
  end
66
66
  end
67
67
 
68
- return response
68
+ response
69
69
  end
70
70
 
71
71
  end # class Response
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - geemus (Wesley Beary)