Skip to content

Commit 9907614

Browse files
committed
Write the gzip'd payload to disk when file:// used
If gzip compression is enabled on the action, and we'd thus send a gzipped payload to the server when we are using a standard baseURL, then similarly write the gzipped payload to disk when we are using a file:// baseURL instead.
1 parent 7fb391d commit 9907614

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/models/app_size_metrics_payload.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ def to_h
5050
#
5151
def send_metrics(base_url:, api_token:, use_gzip: true)
5252
uri = URI(base_url)
53+
json_payload = use_gzip ? Zlib.gzip(to_h.to_json) : to_h.to_json
54+
5355
# Allow using a `file:` URI for debugging
5456
if uri.is_a?(URI::File)
5557
UI.message("Writing metrics payload to file #{uri.path} (instead of sending it to a server)")
56-
File.write(uri.path, to_h.to_json)
58+
File.write(uri.path, json_payload)
5759
return 200 # To make it easy at call site to check for pseudo-status code 200 even in non-HTTP cases
5860
end
5961

@@ -66,7 +68,7 @@ def send_metrics(base_url:, api_token:, use_gzip: true)
6668
headers[:'Content-Encoding'] = 'gzip' if use_gzip
6769

6870
request = Net::HTTP::Post.new(uri, headers)
69-
request.body = use_gzip ? Zlib.gzip(to_h.to_json) : to_h.to_json
71+
request.body = json_payload
7072

7173
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
7274
http.request(request)

0 commit comments

Comments
 (0)