rest-client 1.4.0.a → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rest-client might be problematic. Click here for more details.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0.a
1
+ 1.4.0
@@ -207,7 +207,9 @@ module RestClient
207
207
  end
208
208
 
209
209
  def self.decode content_encoding, body
210
- if content_encoding == 'gzip' and not body.empty?
210
+ if (!body) || body.empty?
211
+ body
212
+ elsif content_encoding == 'gzip'
211
213
  Zlib::GzipReader.new(StringIO.new(body)).read
212
214
  elsif content_encoding == 'deflate'
213
215
  Zlib::Inflate.new.inflate body
@@ -6,6 +6,8 @@ module RestClient
6
6
 
7
7
  attr_reader :body
8
8
 
9
+ WARNING_MESSAGE = '[warning] The Response is no more a String and the Response content is now accessed through Response.body, please update your code'
10
+
9
11
  def initialize body, net_http_res, args
10
12
  super net_http_res, args
11
13
  @body = body || ""
@@ -13,7 +15,7 @@ module RestClient
13
15
 
14
16
  def method_missing symbol, *args
15
17
  if body.respond_to? symbol
16
- warn "[warning] The Response is no more a String, please update your code"
18
+ warn WARNING_MESSAGE
17
19
  body.send symbol, *args
18
20
  else
19
21
  super
@@ -26,7 +28,7 @@ module RestClient
26
28
  else
27
29
  equal_body = (body == o)
28
30
  if equal_body
29
- warn "[warning] The Response is no more a String, please update your code"
31
+ warn WARNING_MESSAGE
30
32
  end
31
33
  equal_body
32
34
  end
@@ -26,10 +26,16 @@ describe RestClient::Request do
26
26
  end
27
27
 
28
28
  describe "compression" do
29
+
29
30
  it "decodes an uncompressed result body by passing it straight through" do
30
31
  RestClient::Request.decode(nil, 'xyz').should == 'xyz'
31
32
  end
32
33
 
34
+ it "doesn't fail for nil bodies" do
35
+ RestClient::Request.decode('gzip', nil).should be_nil
36
+ end
37
+
38
+
33
39
  it "decodes a gzip body" do
34
40
  RestClient::Request.decode('gzip', "\037\213\b\b\006'\252H\000\003t\000\313T\317UH\257\312,HM\341\002\000G\242(\r\v\000\000\000").should == "i'm gziped\n"
35
41
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-client
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 1
7
7
  - 4
8
8
  - 0
9
- - a
10
- version: 1.4.0.a
9
+ version: 1.4.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Adam Wiggins