module M2R::Upload

Logic for Mongrel2 request delivered using async-upload feature Contains methods for recognizing such requests and reading them. @private

Public Instance Methods

body_io() click to toggle source

@return [File] Request body encapsulated in IO compatible object @api public

Calls superclass method
# File lib/m2r/request/upload.rb, line 33
def body_io
  return super unless upload_done?
  @body_io ||= begin
    f = File.open(upload_path, "r+b")
    f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding)
    f
  end
end
free!() click to toggle source

@return [nil] Free external resources such as files or sockets @api public

Calls superclass method
# File lib/m2r/request/upload.rb, line 44
def free!
  super
  File.delete(body_io.path) if upload_done?
end
upload?() click to toggle source

@return [true,false] True if this is async-upload related request @api public

# File lib/m2r/request/upload.rb, line 8
def upload?
  !!@mongrel_headers['x-mongrel2-upload-start']
end
upload_done?() click to toggle source

@return [true,false] True if this is final async-upload request @api public

# File lib/m2r/request/upload.rb, line 20
def upload_done?
  upload? and upload_path
end
upload_path() click to toggle source

@return [String] Relative path to file containing body of HTTP

request.

@api public

# File lib/m2r/request/upload.rb, line 27
def upload_path
  @mongrel_headers['x-mongrel2-upload-done']
end
upload_start?() click to toggle source

@return [true,false] True if this is async-upload start notification @api public

# File lib/m2r/request/upload.rb, line 14
def upload_start?
  upload? and not upload_path
end