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 +4 -4
- data/lib/braintreehttp/encoder.rb +12 -2
- data/lib/braintreehttp/version.rb +1 -1
- data/spec/braintreehttp/encoder_spec.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 573b80fe852147baed1c042d799fce690204e54c
|
4
|
+
data.tar.gz: bfe5f2c242d571a4d3b980e06d01187982218bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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
|