<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -18,6 +18,10 @@ module RestClient
 		def http_code
 			@response.code.to_i if @response
 		end
+
+		def http_body
+			RestClient::Request.decode(@response['content-encoding'], @response.body) if @response
+		end
 	end
 
 	# A redirect was encountered; caught by execute to retry with the new url.</diff>
      <filename>lib/restclient/exceptions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -173,7 +173,7 @@ module RestClient
 			if res.code =~ /\A2\d{2}\z/ 
 				# We don't decode raw requests
 				unless @raw_response
-					decode res['content-encoding'], res.body if res.body
+					self.class.decode res['content-encoding'], res.body if res.body
 				end
 			elsif %w(301 302 303).include? res.code
 				url = res.header['Location']
@@ -196,7 +196,7 @@ module RestClient
 			end
 		end
 
-		def decode(content_encoding, body)
+		def self.decode(content_encoding, body)
 			if content_encoding == 'gzip' and not body.empty?
 				Zlib::GzipReader.new(StringIO.new(body)).read
 			elsif content_encoding == 'deflate'</diff>
      <filename>lib/restclient/request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,6 +12,10 @@ describe RestClient::Exception do
 end
 
 describe RestClient::RequestFailed do
+	before do
+		@response = mock('HTTP Response', :code =&gt; '502')
+	end
+
 	it &quot;stores the http response on the exception&quot; do
 		begin
 			raise RestClient::RequestFailed, :response
@@ -21,11 +25,18 @@ describe RestClient::RequestFailed do
 	end
 
 	it &quot;http_code convenience method for fetching the code as an integer&quot; do
-		RestClient::RequestFailed.new(mock('res', :code =&gt; '502')).http_code.should == 502
+		RestClient::RequestFailed.new(@response).http_code.should == 502
+	end
+
+	it &quot;http_body convenience method for fetching the body (decoding when necessary)&quot; do
+		@response.stub!(:[]).with('content-encoding').and_return('gzip')
+		@response.stub!(:body).and_return('compressed body')
+		RestClient::Request.should_receive(:decode).with('gzip', 'compressed body').and_return('plain body')
+		RestClient::RequestFailed.new(@response).http_body.should == 'plain body'
 	end
 
 	it &quot;shows the status code in the message&quot; do
-		RestClient::RequestFailed.new(mock('res', :code =&gt; '502')).to_s.should match(/502/)
+		RestClient::RequestFailed.new(@response).to_s.should match(/502/)
 	end
 end
 </diff>
      <filename>spec/exceptions_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,19 +22,19 @@ describe RestClient::Request do
 	end
 
 	it &quot;decodes an uncompressed result body by passing it straight through&quot; do
-		@request.decode(nil, 'xyz').should == 'xyz'
+		RestClient::Request.decode(nil, 'xyz').should == 'xyz'
 	end
 
 	it &quot;decodes a gzip body&quot; do
-		@request.decode('gzip', &quot;\037\213\b\b\006'\252H\000\003t\000\313T\317UH\257\312,HM\341\002\000G\242(\r\v\000\000\000&quot;).should == &quot;i'm gziped\n&quot;
+		RestClient::Request.decode('gzip', &quot;\037\213\b\b\006'\252H\000\003t\000\313T\317UH\257\312,HM\341\002\000G\242(\r\v\000\000\000&quot;).should == &quot;i'm gziped\n&quot;
 	end
 
 	it &quot;ingores gzip for empty bodies&quot; do
-		@request.decode('gzip', '').should be_empty
+		RestClient::Request.decode('gzip', '').should be_empty
 	end
 
 	it &quot;decodes a deflated body&quot; do
-		@request.decode('deflate', &quot;x\234+\316\317MUHIM\313I,IMQ(I\255(\001\000A\223\006\363&quot;).should == &quot;some deflated text&quot;
+		RestClient::Request.decode('deflate', &quot;x\234+\316\317MUHIM\313I,IMQ(I\255(\001\000A\223\006\363&quot;).should == &quot;some deflated text&quot;
 	end
 
 	it &quot;processes a successful result&quot; do</diff>
      <filename>spec/request_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>742bc77a842dbf7f0de7826046ff38dfaab0633b</id>
    </parent>
  </parents>
  <author>
    <name>Pedro Belo</name>
    <email>pedro@heroku.com</email>
  </author>
  <url>http://github.com/adamwiggins/rest-client/commit/cb0dd1fd3b50439ea16553d5b6ccecd699e7f253</url>
  <id>cb0dd1fd3b50439ea16553d5b6ccecd699e7f253</id>
  <committed-date>2009-06-29T16:22:54-07:00</committed-date>
  <authored-date>2009-06-29T16:22:54-07:00</authored-date>
  <message>decode response body for exceptions too (401, 404, etc)</message>
  <tree>b1c5bc3e41fba95c7ce6e582dc4ea216c78a8d44</tree>
  <committer>
    <name>Pedro Belo</name>
    <email>pedro@heroku.com</email>
  </committer>
</commit>
