def call_on_child(env_base, env_other)
      env = env_base

      # TODO: this requires quite a few trips, there's probably a faster way
      # to handle this.
      env_other.each_pair do |key, value|
        env[key] = value
      end

      status, headers, body = @rack_app.call(env)

      # Extract the body to pass as a string.  We need to do this
      # because after the call, the objects will be GC'ed, so we want
      # them to be able to be marshaled to be send over DRb.
      if body.respond_to?(:to_str)
        body_str = body
      else
        extracted_body = []

        # Read the
        body.each do |str|
          extracted_body << str
        end

        body.close if body.respond_to?(:close)
        body_str = extracted_body.join
      end

      [status, headers, body_str]
    end
def call_on_child(env_base, env_other)
      env = env_base

      # TODO: this requires quite a few trips, there's probably a faster way
      # to handle this.
      env_other.each_pair do |key, value|
        env[key] = value
      end

      status, headers, body = @rack_app.call(env)

      # Extract the body to pass as a string.  We need to do this
      # because after the call, the objects will be GC'ed, so we want
      # them to be able to be marshaled to be send over DRb.
      if body.respond_to?(:to_str)
        body_str = body
      else
        extracted_body = []

        # Read the
        body.each do |str|
          extracted_body << str
        end

        body.close if body.respond_to?(:close)
        body_str = extracted_body.join
      end

      [status, headers, body_str]
    end
When passing an object, Drb will not marshal it if any of its subobjects
 are not marshalable.  So we split the marshable and not marshalbe objects
 then re-merge them so we get real copies of most values (which are
 needed in some cases)  Then we merge them back into a new hash.