braintreehttp 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecd98d588354892b57adab08fd12f0436f40b460
4
- data.tar.gz: ddb47e416589e2e70e2f5abd36a8dde40697b4ba
3
+ metadata.gz: 573b80fe852147baed1c042d799fce690204e54c
4
+ data.tar.gz: bfe5f2c242d571a4d3b980e06d01187982218bff
5
5
  SHA512:
6
- metadata.gz: 4dc5c2feda9a452c62114fb5edfa61cce9630e131f835aeaef179eb70a0f855c3577eb513bd97c098dd506a2949124c9c0f7a90484a42712f2f6057da06f3dea
7
- data.tar.gz: 5d564e3a9cc44a65d6ee0c03352cc31eff36c9a1db7cee99b0ce2216b633318eaf3c48af336deba864c323bc012ea80149fd8b8ba8a2f6896fb6263647139642
6
+ metadata.gz: b9fa99e9a24984d30667ee1e4e7455b119bfdab4a1e2e56b12d3c3e375caf709cdd728f4c8c7c5e554a42313913f2c2a2ef75a7d721cba58d7d4bdfea84a6dc3
7
+ data.tar.gz: 192deb14605d03670a59f5cf2457fbc4b3b50478061068803f4dfa4bf461893f74ffe3af26bc1a27a3fd0f077a4034b0f80dcb145ff3e8803445cae49f5239a2
@@ -1,3 +1,4 @@
1
+ require 'stringio'
1
2
  require 'zlib'
2
3
 
3
4
  require_relative './serializers/json'
@@ -23,7 +24,13 @@ module BraintreeHttp
23
24
  content_encoding = _extract_header(req.headers, 'Content-Encoding')
24
25
 
25
26
  if content_encoding == 'gzip'
26
- encoded = Zlib::Deflate.deflate(encoded)
27
+ out = StringIO.new('w')
28
+ writer = Zlib::GzipWriter.new(out)
29
+
30
+ writer.write encoded
31
+ writer.close
32
+
33
+ encoded = out.string
27
34
  end
28
35
 
29
36
  encoded
@@ -40,7 +47,10 @@ module BraintreeHttp
40
47
  content_encoding = _extract_header(headers, 'Content-Encoding')
41
48
 
42
49
  if content_encoding == 'gzip'
43
- resp = Zlib::Inflate.inflate(resp)
50
+ buf = StringIO.new(resp, 'rb')
51
+ reader = Zlib::GzipReader.new(buf)
52
+
53
+ resp = reader.read
44
54
  end
45
55
 
46
56
  enc.decode(resp)
@@ -1 +1 @@
1
- VERSION = "0.4.3"
1
+ VERSION = "0.4.4"
@@ -1,5 +1,6 @@
1
1
  require 'ostruct'
2
2
  require 'json'
3
+ require 'stringio'
3
4
  require 'zlib'
4
5
 
5
6
  describe Encoder do
@@ -126,7 +127,14 @@ describe Encoder do
126
127
 
127
128
  encoder = Encoder.new
128
129
 
129
- expect(encoder.serialize_request(req)).to eq(Zlib::Deflate.deflate(JSON.generate(req.body)))
130
+ out = StringIO.new('w')
131
+ writer = Zlib::GzipWriter.new(out)
132
+ writer.write JSON.generate(req.body)
133
+ writer.close
134
+
135
+ expected_body = out.string
136
+
137
+ expect(encoder.serialize_request(req)).to eq(expected_body)
130
138
  end
131
139
  end
132
140
 
@@ -202,7 +210,11 @@ describe Encoder do
202
210
  :one => 'two'
203
211
  })
204
212
 
205
- encoded_body = Zlib::Deflate.deflate(body)
213
+ out = StringIO.new('w')
214
+ encoder = Zlib::GzipWriter.new(out)
215
+ encoder.write(body)
216
+ encoder.close
217
+ encoded_body = out.string
206
218
 
207
219
  expect(Encoder.new.deserialize_response(encoded_body, headers)).to eq({'one' => 'two'})
208
220
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintreehttp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-01 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Used for generated API clients
14
14
  email: code@getbraintree.com