Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8364

Show
Ignore:
Timestamp:
12/10/07 05:53:56 (2 years ago)
Author:
bitsweat
Message:

Correct empty response handling. Closes #10445.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activeresource/CHANGELOG

    r8330 r8364  
     1*SVN* 
     2 
     3* Correct empty response handling.  #10445 [seangeo] 
     4 
     5 
    16*2.0.1* (December 7th, 2007) 
    27 
  • trunk/activeresource/lib/active_resource/base.rb

    r8090 r8364  
    808808       
    809809      def load_attributes_from_response(response) 
    810         if response['Content-size'] != "0" && response.body.strip.size > 0 
     810        if response['Content-Length'] != "0" && response.body.strip.size > 0 
    811811          load(self.class.format.decode(response.body)) 
    812812        end 
  • trunk/activeresource/lib/active_resource/connection.rb

    r8167 r8364  
    100100        result = nil 
    101101        time = Benchmark.realtime { result = http.send(method, path, *arguments) } 
    102         logger.info "--> #{result.code} #{result.message} (#{result.body.length}b %.2fs)" % time if logger 
     102        logger.info "--> #{result.code} #{result.message} (#{result.body ? result.body : 0}b %.2fs)" % time if logger 
    103103        handle_response(result) 
    104104      end 
  • trunk/activeresource/lib/active_resource/http_mock.rb

    r7719 r8364  
    3535 
    3636        if block_given? 
    37           yield Responder.new(responses)  
     37          yield Responder.new(responses) 
    3838        else 
    3939          Responder.new(responses) 
     
    103103      @body, @message, @headers = body, message.to_s, headers 
    104104      @code = @message[0,3].to_i 
     105 
     106      resp_cls = Net::HTTPResponse::CODE_TO_OBJ[@code.to_s] 
     107      if resp_cls && !resp_cls.body_permitted? 
     108        @body = nil 
     109      end 
     110 
     111      if @body.nil? 
     112        self['Content-Length'] = "0" 
     113      else 
     114        self['Content-Length'] = body.size.to_s 
     115      end 
    105116    end 
    106117 
     
    116127      headers[key] = value 
    117128    end 
    118      
     129 
    119130    def ==(other) 
    120131      if (other.is_a?(Response))