class Roda::RodaPlugins::Chunked::Body

  1. lib/roda/plugins/chunked.rb
Superclass: Object

Rack response body instance for chunked responses using Transfer-Encoding: chunked.

Methods

Public Class

  1. new

Public Instance

  1. each

Public Class methods

new(scope)

Save the scope of the current request handling.

[show source]
    # File lib/roda/plugins/chunked.rb
175 def initialize(scope)
176   @scope = scope
177 end

Public Instance methods

each()

For each response chunk yielded by the scope, yield it it to the caller in chunked format, starting with the size of the request in ASCII hex format, then the chunk. After all chunks have been yielded, yield a 0 sized chunk to finish the response.

[show source]
    # File lib/roda/plugins/chunked.rb
184 def each
185   @scope.each_chunk do |chunk|
186     next if !chunk || chunk.empty?
187     yield("%x\r\n" % chunk.bytesize)
188     yield(chunk)
189     yield("\r\n")
190   end
191 ensure
192   yield("0\r\n\r\n")
193 end