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

Changeset 5622

Show
Ignore:
Timestamp:
11/23/06 23:52:25 (2 years ago)
Author:
david
Message:

Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-pre-release/actionpack/CHANGELOG

    r5621 r5622  
    11*1.13.0 RC1* (November 22nd, 2006) 
     2 
     3* Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [DHH] 
    24 
    35* Added GET-masquarading for HEAD, so request.method will return :get even for HEADs. This will help anyone relying on case request.method to automatically work with HEAD and map.resources will also allow HEADs to all GET actions. Rails automatically throws away the response content in a reply to HEAD, so you don't even need to worry about that. If you, for whatever reason, still need to distinguish between GET and HEAD in some edge case, you can use Request#head? and even Request.headers["REQUEST_METHOD"] for get the "real" answer. Closes #6694 [DHH] 
  • branches/1-2-pre-release/actionpack/lib/action_controller/cgi_process.rb

    r5443 r5622  
    172172 
    173173    def out(output = $stdout) 
    174       convert_content_type!(@headers) 
     174      convert_content_type! 
     175      set_content_length! 
     176 
    175177      output.binmode      if output.respond_to?(:binmode) 
    176178      output.sync = false if output.respond_to?(:sync=) 
     
    197199 
    198200    private 
    199       def convert_content_type!(headers) 
    200         if header = headers.delete("Content-Type") 
    201           headers["type"] = header 
    202         end 
    203         if header = headers.delete("Content-type") 
    204           headers["type"] = header 
    205         end 
    206         if header = headers.delete("content-type") 
    207           headers["type"] = header 
    208         end 
     201      def convert_content_type! 
     202        if content_type = @headers.delete("Content-Type") 
     203          @headers["type"] = content_type 
     204        end 
     205        if content_type = @headers.delete("Content-type") 
     206          @headers["type"] = content_type 
     207        end 
     208        if content_type = @headers.delete("content-type") 
     209          @headers["type"] = content_type 
     210        end 
     211      end 
     212       
     213      # Don't set the Content-Length for block-based bodies as that would mean reading it all into memory. Not nice 
     214      # for, say, a 2GB streaming file. 
     215      def set_content_length! 
     216        @headers["Content-Length"] = @body.size unless @body.respond_to?(:call) 
    209217      end 
    210218  end 
  • trunk/actionpack/CHANGELOG

    r5621 r5622  
    11*SVN* 
     2 
     3* Fixed that HEAD should return the proper Content-Length header (that is, actually use @body.size, not just 0) [DHH] 
    24 
    35* Added GET-masquarading for HEAD, so request.method will return :get even for HEADs. This will help anyone relying on case request.method to automatically work with HEAD and map.resources will also allow HEADs to all GET actions. Rails automatically throws away the response content in a reply to HEAD, so you don't even need to worry about that. If you, for whatever reason, still need to distinguish between GET and HEAD in some edge case, you can use Request#head? and even Request.headers["REQUEST_METHOD"] for get the "real" answer. Closes #6694 [DHH] 
  • trunk/actionpack/lib/action_controller/cgi_process.rb

    r5442 r5622  
    172172 
    173173    def out(output = $stdout) 
    174       convert_content_type!(@headers) 
     174      convert_content_type! 
     175      set_content_length! 
     176 
    175177      output.binmode      if output.respond_to?(:binmode) 
    176178      output.sync = false if output.respond_to?(:sync=) 
     
    197199 
    198200    private 
    199       def convert_content_type!(headers) 
    200         if header = headers.delete("Content-Type") 
    201           headers["type"] = header 
    202         end 
    203         if header = headers.delete("Content-type") 
    204           headers["type"] = header 
    205         end 
    206         if header = headers.delete("content-type") 
    207           headers["type"] = header 
    208         end 
     201      def convert_content_type! 
     202        if content_type = @headers.delete("Content-Type") 
     203          @headers["type"] = content_type 
     204        end 
     205        if content_type = @headers.delete("Content-type") 
     206          @headers["type"] = content_type 
     207        end 
     208        if content_type = @headers.delete("content-type") 
     209          @headers["type"] = content_type 
     210        end 
     211      end 
     212       
     213      # Don't set the Content-Length for block-based bodies as that would mean reading it all into memory. Not nice 
     214      # for, say, a 2GB streaming file. 
     215      def set_content_length! 
     216        @headers["Content-Length"] = @body.size unless @body.respond_to?(:call) 
    209217      end 
    210218  end