degzipper 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/degzipper/middleware.rb +5 -2
- data/lib/degzipper/version.rb +1 -1
- data/spec/degzipper_spec.rb +14 -0
- 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: ee39cde684c0493cba8587318e2f16a37925b1cc
|
4
|
+
data.tar.gz: 712f518e9a307afd97170c1d8132bc31253a83e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 300a3b34f87eefd8eed351654d4c98e4fe3d308d59362ce8a3c0e04b6fadf65574dcdd5043ac6774ec5af4f93f4f3edc06ae89ceafc46dd4344dc05d7cf76154
|
7
|
+
data.tar.gz: f7bf0adfd814f1ef374cc5a82ab575a3b7b0d3957f2168d25fd372de77b8da572365207b873658f87d6945728906bdb9c68c55187f0dfc07660ca381fc952183
|
data/CHANGELOG.md
CHANGED
data/lib/degzipper/middleware.rb
CHANGED
@@ -27,12 +27,15 @@ module Degzipper
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def decode(input, content_encoding)
|
30
|
+
# type of input depends on CONTENT_LENGTH
|
31
|
+
# if CONTENT_LENGTH < 20k it's StringIO; if more it's Tempfile
|
32
|
+
# that's why use only common methods of these types
|
30
33
|
case content_encoding
|
31
34
|
when 'gzip' then Zlib::GzipReader.new(input).read
|
32
|
-
when 'zlib' then Zlib::Inflate.inflate(input.
|
35
|
+
when 'zlib' then Zlib::Inflate.inflate(input.read)
|
33
36
|
when 'deflate'
|
34
37
|
stream = Zlib::Inflate.new(-Zlib::MAX_WBITS)
|
35
|
-
content = stream.inflate(input.
|
38
|
+
content = stream.inflate(input.read)
|
36
39
|
stream.finish
|
37
40
|
stream.close
|
38
41
|
content
|
data/lib/degzipper/version.rb
CHANGED
data/spec/degzipper_spec.rb
CHANGED
@@ -59,6 +59,20 @@ RSpec.describe Degzipper::Middleware do
|
|
59
59
|
'length' => 6
|
60
60
|
)
|
61
61
|
end
|
62
|
+
|
63
|
+
it 'handles a tmp files as well' do
|
64
|
+
Tempfile.open('degzipper') do |stream|
|
65
|
+
stream << compress('hello')
|
66
|
+
stream.rewind
|
67
|
+
resp = make_request(stream, type)
|
68
|
+
|
69
|
+
expect(resp).to eq(
|
70
|
+
'body' => 'hello',
|
71
|
+
'content_encoding' => nil,
|
72
|
+
'length' => 5
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
62
76
|
end
|
63
77
|
|
64
78
|
context 'gzip' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: degzipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hammond
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-06-
|
12
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|