confeature 0.1.0 → 0.1.1
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 +4 -4
- data/lib/confeature/internal/config_fetcher.rb +26 -2
- data/lib/confeature/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: 526cadeccff8c73783cedea06b2913852c5d3dc1def25e1849226acc810ff7c8
|
|
4
|
+
data.tar.gz: e4d743d9078e1d9bdf06b4a758938dee26e62a147c5121abf08dde83833db062
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6524aa693004bb6459f5a87a2524a295b7a4c100e05a8d420570e01fa6b2853c586ca3bc2534f7216fb046a5cfa3778fc83e6ef6fe09625bc5ad3921d77eca35
|
|
7
|
+
data.tar.gz: 2474b277f34cdeffe9554153ac44e72bf94c92b9816ce18bddb0d31e8644d6cd6c00a8dc8ea22e722de3f11e526164fd5e2a40baf5c4f3e2644a8ff5f564f863
|
|
@@ -32,7 +32,7 @@ module Confeature
|
|
|
32
32
|
# So no exception text is ever passed on (it may quote the URL): only
|
|
33
33
|
# the exception's class picks a fixed reason code.
|
|
34
34
|
class ConfigFetcher
|
|
35
|
-
DEFAULT_BASE_URL = "https://cdn
|
|
35
|
+
DEFAULT_BASE_URL = "https://cdn.confeature.io"
|
|
36
36
|
|
|
37
37
|
# Reason code when the key cannot be placed in a path segment
|
|
38
38
|
# ("", "." or "..") — the fetcher refuses to fetch (#803 FR-001).
|
|
@@ -42,6 +42,10 @@ module Confeature
|
|
|
42
42
|
# URL — no request is made (#803 FR-002; sdk-go's code).
|
|
43
43
|
INVALID_REQUEST = "invalid_request"
|
|
44
44
|
|
|
45
|
+
# Reason code of a dropped connection: a transport exception, or a
|
|
46
|
+
# 2xx body cut short of its Content-Length (#920).
|
|
47
|
+
CONNECTION_RESET = "connection_reset"
|
|
48
|
+
|
|
45
49
|
# Transport failures -> fixed, key-free reason codes (#803 FR-002;
|
|
46
50
|
# mirrors sdk-go's `classifyError`). Order matters: a timeout is
|
|
47
51
|
# checked first (`Net::OpenTimeout` etc. descend from
|
|
@@ -109,7 +113,7 @@ module Confeature
|
|
|
109
113
|
# reason code (#803 FR-002). The message is never read.
|
|
110
114
|
def self.classify_error(exc)
|
|
111
115
|
return "timeout" if TIMEOUT_ERRORS.any? { |klass| exc.is_a?(klass) }
|
|
112
|
-
return
|
|
116
|
+
return CONNECTION_RESET if CONNECTION_RESET_ERRORS.any? { |klass| exc.is_a?(klass) }
|
|
113
117
|
|
|
114
118
|
"network_error"
|
|
115
119
|
end
|
|
@@ -166,6 +170,11 @@ module Confeature
|
|
|
166
170
|
http.open_timeout = @timeout
|
|
167
171
|
http.read_timeout = @timeout
|
|
168
172
|
http.write_timeout = @timeout if http.respond_to?(:write_timeout=)
|
|
173
|
+
# Net::HTTP silently retries an idempotent GET once on a read
|
|
174
|
+
# timeout or a reset (`max_retries` defaults to 1): two requests,
|
|
175
|
+
# and twice the deadline, for one fetch. One fetch is one request —
|
|
176
|
+
# the poll service owns retrying (#920, found by the live suite).
|
|
177
|
+
http.max_retries = 0
|
|
169
178
|
http
|
|
170
179
|
end
|
|
171
180
|
|
|
@@ -183,6 +192,8 @@ module Confeature
|
|
|
183
192
|
when Net::HTTPNotModified
|
|
184
193
|
FetchResult.new(status: :not_modified, etag: response["etag"])
|
|
185
194
|
when Net::HTTPSuccess
|
|
195
|
+
return fail_with(CONNECTION_RESET) if truncated?(response)
|
|
196
|
+
|
|
186
197
|
parse_success(response)
|
|
187
198
|
else
|
|
188
199
|
reason = "HTTP #{response.code}"
|
|
@@ -193,6 +204,19 @@ module Confeature
|
|
|
193
204
|
end
|
|
194
205
|
end
|
|
195
206
|
|
|
207
|
+
# Net::HTTP reads a Content-Length body ignoring EOF, so a connection
|
|
208
|
+
# dropped mid-body yields a SHORT body, never an EOFError. Without
|
|
209
|
+
# this check it would be misread as malformed JSON — a transport
|
|
210
|
+
# failure reported as CDN drift (wire-cases `network-reset`, #920).
|
|
211
|
+
# Net::HTTP rewrites Content-Length to the inflated size when it
|
|
212
|
+
# decodes gzip, so the comparison holds for a compressed response.
|
|
213
|
+
def truncated?(response)
|
|
214
|
+
declared = response["content-length"]
|
|
215
|
+
return false unless declared&.match?(/\A\d+\z/)
|
|
216
|
+
|
|
217
|
+
response.body.to_s.bytesize < Integer(declared, 10)
|
|
218
|
+
end
|
|
219
|
+
|
|
196
220
|
def parse_success(response)
|
|
197
221
|
body = JSON.parse(response.body)
|
|
198
222
|
unless body.is_a?(Hash)
|
data/lib/confeature/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: confeature
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MakerLabs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|