Skip to content

Commit a9bc5a7

Browse files
committed
Compress request's body before sending
1 parent 36f9139 commit a9bc5a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/rorvswild/client.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "set"
44
require "uri"
5+
require "zlib"
56
require "json/ext"
67
require "net/http"
78

@@ -24,6 +25,7 @@ def initialize(config)
2425
@mutex = Mutex.new
2526
@config = config
2627
@headers = {
28+
"Content-Encoding" => "deflate",
2729
"Content-Type" => "application/json",
2830
"X-RorVsWild-Version" => RorVsWild::VERSION,
2931
"X-Ruby-Version" => RUBY_VERSION,
@@ -36,7 +38,7 @@ def post(path, data)
3638
uri = URI(api_url + path)
3739
post = Net::HTTP::Post.new(uri.path, @headers)
3840
post.basic_auth(nil, api_key)
39-
post.body = JSON.generate(data)
41+
post.body = Zlib.deflate(JSON.generate(data), Zlib::BEST_SPEED)
4042
transmit(post)
4143
end
4244

0 commit comments

Comments
 (0)