net-hippie 0.3.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 587a0c3abc7e55ea7db10494f69c828aff0a35879d4d277d73fe3980419a26c7
4
- data.tar.gz: 7c4404f2ee59ddb13b650d4cfe5193652ec120a1d60073a17d0dd969e3428d5f
3
+ metadata.gz: b39c735df32d765a6146802cfed8d0dc6cf6140363b55b84b08d6b691b9613fa
4
+ data.tar.gz: cc061070fc681973b97833836867d489cabb1db950d29e9561a9bdac8c566a1e
5
5
  SHA512:
6
- metadata.gz: a7119bffdf4ea7469e6ec7d948ce033a078eaeb2ae952eb110c0c590d2667c28450fd41b0b268e20ad5a840577615015178c914c457037b4b01dafa2dc9f28ac
7
- data.tar.gz: e1f83721bb3c1a85493e1e17bb5c8eec6bafcfe8d374aa50cea5342405be0faf098f3f689a5d86b679066c20ff9a71301a9cbbf74ac2a639b233f45ec270f70e
6
+ metadata.gz: dedf2965ae930705d3e3a4cc5aacd29bb5210d17097c4699660ad2bb3562cbd4d9cba70450a6fd3646741ae0c55a6bc49ce0fa26e799193294bda05ba29d6ccf
7
+ data.tar.gz: df77476f60696ab864520b689dde126289fc3b9aa9df94bf5e816aa6cb479dff1cdcc33673d3be78a4391685c72d7fa465b261aa712e4b1f84220f1f25b715e9
@@ -1,4 +1,4 @@
1
- Version 0.3.1
1
+ Version 0.3.2
2
2
 
3
3
  # Changelog
4
4
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
  ## [Unreleased]
10
10
  - nil
11
11
 
12
+ ## [0.3.2] - 2020-01-28
13
+ ### Fixed
14
+ - Follow relative path redirects
15
+
12
16
  ## [0.3.1] - 2020-01-14
13
17
  ### Fixed
14
18
  - Parse location header in response then follow redirect.
@@ -50,7 +54,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
50
54
  - with\_retry.https://www.mokhan.ca/%F0%9F%92%8E/2018/11/10/net-hippie-0-2-0.html
51
55
  - authorization header helpers
52
56
 
53
- [Unreleased]: https://github.com/mokhan/net-hippie/compare/v0.3.1...HEAD
57
+ [Unreleased]: https://github.com/mokhan/net-hippie/compare/v0.3.2...HEAD
58
+ [0.3.2]: https://github.com/mokhan/net-hippie/compare/v0.3.1...v0.3.2
54
59
  [0.3.1]: https://github.com/mokhan/net-hippie/compare/v0.3.0...v0.3.1
55
60
  [0.3.0]: https://github.com/mokhan/net-hippie/compare/v0.2.7...v0.3.0
56
61
  [0.2.7]: https://github.com/mokhan/net-hippie/compare/v0.2.6...v0.2.7
@@ -27,11 +27,12 @@ module Net
27
27
  end
28
28
 
29
29
  def execute(uri, request, limit: follow_redirects, &block)
30
- response = http_for(uri).request(request)
30
+ http = http_for(uri)
31
+ response = http.request(request)
31
32
  if limit.positive? && response.is_a?(Net::HTTPRedirection)
32
- location = response['location']
33
- request = request_for(Net::HTTP::Get, location)
34
- execute(location, request, limit: limit - 1, &block)
33
+ url = build_url_for(http, response['location'])
34
+ request = request_for(Net::HTTP::Get, url)
35
+ execute(url, request, limit: limit - 1, &block)
35
36
  else
36
37
  block_given? ? yield(request, response) : response
37
38
  end
@@ -86,7 +87,7 @@ module Net
86
87
  raise error if attempt == max
87
88
 
88
89
  delay = ((2**attempt) * 0.1) + Random.rand(0.05) # delay + jitter
89
- warn("`#{error.message}` Retry: #{attempt + 1}/#{max} Delay: #{delay}s")
90
+ logger.warn("`#{error.message}` #{attempt + 1}/#{max} Delay: #{delay}s")
90
91
  sleep delay
91
92
  end
92
93
 
@@ -121,14 +122,16 @@ module Net
121
122
  http.key = private_key
122
123
  end
123
124
 
124
- def warn(message)
125
- logger.warn(message)
126
- end
127
-
128
125
  def run(uri, http_method, headers, body, &block)
129
126
  request = request_for(http_method, uri, headers: headers, body: body)
130
127
  execute(uri, request, &block)
131
128
  end
129
+
130
+ def build_url_for(http, path)
131
+ return path if path.start_with?('http')
132
+
133
+ "#{http.use_ssl? ? 'https' : 'http'}://#{http.address}#{path}"
134
+ end
132
135
  end
133
136
  end
134
137
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Net
4
4
  module Hippie
5
- VERSION = '0.3.1'
5
+ VERSION = '0.3.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-hippie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-14 00:00:00.000000000 Z
11
+ date: 2020-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest