net-hippie 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/lib/net/hippie/client.rb +12 -9
- data/lib/net/hippie/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39c735df32d765a6146802cfed8d0dc6cf6140363b55b84b08d6b691b9613fa
|
4
|
+
data.tar.gz: cc061070fc681973b97833836867d489cabb1db950d29e9561a9bdac8c566a1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dedf2965ae930705d3e3a4cc5aacd29bb5210d17097c4699660ad2bb3562cbd4d9cba70450a6fd3646741ae0c55a6bc49ce0fa26e799193294bda05ba29d6ccf
|
7
|
+
data.tar.gz: df77476f60696ab864520b689dde126289fc3b9aa9df94bf5e816aa6cb479dff1cdcc33673d3be78a4391685c72d7fa465b261aa712e4b1f84220f1f25b715e9
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Version 0.3.
|
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.
|
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
|
data/lib/net/hippie/client.rb
CHANGED
@@ -27,11 +27,12 @@ module Net
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def execute(uri, request, limit: follow_redirects, &block)
|
30
|
-
|
30
|
+
http = http_for(uri)
|
31
|
+
response = http.request(request)
|
31
32
|
if limit.positive? && response.is_a?(Net::HTTPRedirection)
|
32
|
-
|
33
|
-
request = request_for(Net::HTTP::Get,
|
34
|
-
execute(
|
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}`
|
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
|
data/lib/net/hippie/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|