Skip to content

Commit d771dea

Browse files
Request GZIP compression (#239)
* Request GZIP compression * Handle GZIP responses
1 parent d848ef9 commit d771dea

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.github/workflows/kong.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
KONG:
19-
timeout-minutes: 5
19+
timeout-minutes: 10
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Get KONG

lib/network.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class Network
2323
extend T::Sig
2424

2525
sig { params(server_secret: String, options: StatsigOptions, backoff_mult: Integer).void }
26-
2726
def initialize(server_secret, options, backoff_mult = 10)
2827
super()
2928
URIHelper.initialize(options)
@@ -36,14 +35,14 @@ def initialize(server_secret, options, backoff_mult = 10)
3635
@session_id = SecureRandom.uuid
3736
@connection_pool = ConnectionPool.new(size: 3) do
3837
meta = Statsig.get_statsig_metadata
39-
client = HTTP.headers(
38+
client = HTTP.use(:auto_inflate).headers(
4039
{
4140
'STATSIG-API-KEY' => @server_secret,
42-
'STATSIG-CLIENT-TIME' => (Time.now.to_f * 1000).to_i.to_s,
4341
'STATSIG-SERVER-SESSION-ID' => @session_id,
4442
'Content-Type' => 'application/json; charset=UTF-8',
4543
'STATSIG-SDK-TYPE' => meta['sdkType'],
46-
'STATSIG-SDK-VERSION' => meta['sdkVersion']
44+
'STATSIG-SDK-VERSION' => meta['sdkVersion'],
45+
'Accept-Encoding' => 'gzip'
4746
}
4847
).accept(:json)
4948
if @timeout
@@ -58,7 +57,6 @@ def initialize(server_secret, options, backoff_mult = 10)
5857
params(endpoint: String, body: String, retries: Integer, backoff: Integer)
5958
.returns([T.any(HTTP::Response, NilClass), T.any(StandardError, NilClass)])
6059
end
61-
6260
def post_helper(endpoint, body, retries = 0, backoff = 1)
6361
if @local_mode
6462
return nil, nil

lib/spec_store.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def spawn_sync_id_lists_thread
222222
})
223223
end
224224
end
225+
225226
def download_config_specs
226227
tracker = @diagnostics.track('download_config_specs', 'network_request')
227228

@@ -237,6 +238,7 @@ def download_config_specs
237238
if e.nil?
238239
unless response.nil?
239240
tracker = @diagnostics.track('download_config_specs', 'process')
241+
240242
if process_specs(response.body.to_s)
241243
@init_reason = EvaluationReason::NETWORK
242244
end
@@ -481,5 +483,6 @@ def process_single_id_list(list, content, content_length = nil, from_adapter: fa
481483
return false
482484
end
483485
end
486+
484487
end
485488
end

0 commit comments

Comments
 (0)