excon 0.65.0 → 0.66.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cc63ddad0f9af8192beff1525e1ebce8ec89a633aa6a8bc2aec53177a7f8a41
4
- data.tar.gz: 0e8f295ee1570d333e0ce292d272a175c92cf37fcb415b32a60b2997b4f5d3cf
3
+ metadata.gz: 353be74596fc596f8436dac3da4ebaba40f006e4ad4973429cf25c6c54c41923
4
+ data.tar.gz: 156b667f3a4474033b115aa09818b3fba2288160aa7774c82459bb4708158264
5
5
  SHA512:
6
- metadata.gz: 12669e9bef2f22834bbc6ac0292e16bcf1f9d87ca0e37b06d02e39183d25b2f7bd69389663d688e48b8edd1104f91c50146eb152d8e508840aafd0802169f379
7
- data.tar.gz: b0d6abdbe9fdeb53a89ce96dca6315e5e61d2b66a64d5a326dfff711df5ce742fa3455c997c8b94d315a31ceb9bd5caa1186b414a7389687b312cbbc87607150
6
+ metadata.gz: 26a8d197845c79aa756b6b29adfa65e7b4f340eeb27b7beccc69605134d67f254b44198cb88f583f193ff0362a9601420689109f535a875f2cb32f30b2299fd2
7
+ data.tar.gz: 4d9672acc8e2e3fe657ebaebd00478583a39438d02d20535a315e6d02fc3b902923d8c26b7e8f113205b123071d01c414d71be5e35402573f4b994b5d3f4dab6
@@ -440,7 +440,7 @@ module Excon
440
440
  datum[:stack].response_call(datum)
441
441
  rescue => error
442
442
  case error
443
- when Excon::Errors::HTTPStatusError, Excon::Errors::Timeout
443
+ when Excon::Errors::HTTPStatusError, Excon::Errors::Timeout, Excon::Errors::TooManyRedirects
444
444
  raise(error)
445
445
  else
446
446
  raise_socket_error(error)
@@ -12,6 +12,8 @@ module Excon
12
12
  CHUNK_SIZE = DEFAULT_CHUNK_SIZE
13
13
  end
14
14
 
15
+ DEFAULT_REDIRECT_LIMIT = 10
16
+
15
17
  DEFAULT_RETRY_LIMIT = 4
16
18
 
17
19
  DEFAULT_RETRY_ERRORS = [
@@ -51,6 +51,7 @@ or:
51
51
  class Timeout < Error; end
52
52
  class ResponseParse < Error; end
53
53
  class ProxyParse < Error; end
54
+ class TooManyRedirects < Error; end
54
55
 
55
56
  # Base class for HTTP Error classes
56
57
  class HTTPStatus < Error
@@ -26,11 +26,12 @@ module Excon
26
26
  end
27
27
 
28
28
  if stub = Excon.stub_for(datum)
29
+ datum[:remote_ip] ||= '127.0.0.1'
29
30
  datum[:response] = {
30
31
  :body => '',
31
32
  :headers => {},
32
33
  :status => 200,
33
- :remote_ip => '127.0.0.1'
34
+ :remote_ip => datum[:remote_ip]
34
35
  }
35
36
 
36
37
  stub_datum = case stub.last
@@ -2,6 +2,18 @@
2
2
  module Excon
3
3
  module Middleware
4
4
  class RedirectFollower < Excon::Middleware::Base
5
+ def self.valid_parameter_keys
6
+ [
7
+ :redirects_remaining,
8
+ :redirect_limit
9
+ ]
10
+ end
11
+
12
+ def request_call(datum)
13
+ datum[:redirects_remaining] ||= datum[:redirect_limit] ||
14
+ Excon::DEFAULT_REDIRECT_LIMIT
15
+ @stack.request_call(datum)
16
+ end
5
17
 
6
18
  def get_header(datum, header)
7
19
  _, header_value = datum[:response][:headers].detect do |key, value|
@@ -14,14 +26,21 @@ module Excon
14
26
  if datum.has_key?(:response)
15
27
  case datum[:response][:status]
16
28
  when 301, 302, 303, 307, 308
29
+ if datum[:redirects_remaining] <= 0
30
+ raise Excon::Errors::TooManyRedirects
31
+ end
32
+
33
+ datum[:redirects_remaining] -= 1
34
+
17
35
  uri_parser = datum[:uri_parser] || Excon.defaults[:uri_parser]
18
36
 
19
37
  location = get_header(datum, 'Location')
20
38
  base_uri = Excon::Utils.request_uri(datum)
21
39
  uri = uri_parser.join(base_uri, location)
22
40
 
23
- # delete old/redirect response
41
+ # delete old/redirect response and remote_ip
24
42
  response = datum.delete(:response)
43
+ datum.delete(:remote_ip)
25
44
 
26
45
  params = datum.dup
27
46
  params.delete(:connection)
@@ -52,7 +71,10 @@ module Excon
52
71
  params.merge!(:password => Utils.unescape_uri(uri.password)) if uri.password
53
72
 
54
73
  response = Excon::Connection.new(params).request
55
- datum.merge!({:response => response.data})
74
+ datum.merge!({
75
+ :remote_ip => response.remote_ip,
76
+ :response => response.data
77
+ })
56
78
  else
57
79
  @stack.response_call(datum)
58
80
  end
@@ -125,6 +125,7 @@ module Excon
125
125
  end
126
126
 
127
127
  @remote_ip = ip
128
+ @data[:remote_ip] = ip
128
129
 
129
130
  # nonblocking connect
130
131
  begin
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Excon
3
- VERSION = '0.65.0'
3
+ VERSION = '0.66.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.65.0
4
+ version: 0.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dpiddy (Dan Peterson)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-07-22 00:00:00.000000000 Z
13
+ date: 2019-08-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec