Class: Rack::Chunked::Body
- Inherits:
 - 
      Object
      
        
- Object
 - Rack::Chunked::Body
 
 
- Defined in:
 - lib/rack/chunked.rb
 
Overview
A body wrapper that emits chunked responses.
Direct Known Subclasses
Constant Summary collapse
- TERM =
 "\r\n"- TAIL =
 "0#{TERM}"
Instance Method Summary collapse
- 
  
    
      #close  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Close the response body if the response body supports it.
 - 
  
    
      #each {|TAIL| ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
For each element yielded by the response body, yield the element in chunked encoding.
 - 
  
    
      #initialize(body)  ⇒ Body 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Store the response body to be chunked.
 
Constructor Details
#initialize(body) ⇒ Body
Store the response body to be chunked.
      30 31 32  | 
    
      # File 'lib/rack/chunked.rb', line 30 def initialize(body) @body = body end  | 
  
Instance Method Details
#close ⇒ Object
Close the response body if the response body supports it.
      50 51 52  | 
    
      # File 'lib/rack/chunked.rb', line 50 def close @body.close if @body.respond_to?(:close) end  | 
  
#each {|TAIL| ... } ⇒ Object
For each element yielded by the response body, yield the element in chunked encoding.
      36 37 38 39 40 41 42 43 44 45 46 47  | 
    
      # File 'lib/rack/chunked.rb', line 36 def each(&block) term = TERM @body.each do |chunk| size = chunk.bytesize next if size == 0 yield [size.to_s(16), term, chunk.b, term].join end yield TAIL yield_trailers(&block) yield term end  |