Sha256: 6cfa27e5cc5f83c672c2fddb1442eaa19bf5f84b484a37f0b76649854b024b1a

Contents?: true

Size: 1.14 KB

Versions: 85

Compression:

Stored size: 1.14 KB

Contents

module Rack
  # A multipart form data parser, adapted from IOWA.
  #
  # Usually, Rack::Request#POST takes care of calling this.
  module Multipart
    autoload :UploadedFile, 'rack/multipart/uploaded_file'
    autoload :Parser, 'rack/multipart/parser'
    autoload :Generator, 'rack/multipart/generator'

    EOL = "\r\n"
    MULTIPART_BOUNDARY = "AaB03x"
    MULTIPART = %r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n
    TOKEN = /[^\s()<>,;:\\"\/\[\]?=]+/
    CONDISP = /Content-Disposition:\s*#{TOKEN}\s*/i
    DISPPARM = /;\s*(#{TOKEN})=("(?:\\"|[^"])*"|#{TOKEN})/
    RFC2183 = /^#{CONDISP}(#{DISPPARM})+$/i
    BROKEN_QUOTED = /^#{CONDISP}.*;\sfilename="(.*?)"(?:\s*$|\s*;\s*#{TOKEN}=)/i
    BROKEN_UNQUOTED = /^#{CONDISP}.*;\sfilename=(#{TOKEN})/i
    MULTIPART_CONTENT_TYPE = /Content-Type: (.*)#{EOL}/ni
    MULTIPART_CONTENT_DISPOSITION = /Content-Disposition:.*\s+name="?([^\";]*)"?/ni
    MULTIPART_CONTENT_ID = /Content-ID:\s*([^#{EOL}]*)/ni

    class << self
      def parse_multipart(env)
        Parser.new(env).parse
      end

      def build_multipart(params, first = true)
        Generator.new(params, first).dump
      end
    end

  end
end

Version data entries

85 entries across 74 versions & 21 rubygems

Version Path
graphael-on-rails-0.5.1 vendor/bundle/gems/rack-1.4.5/lib/rack/multipart.rb
graphael-on-rails-0.0.1 vendor/bundle/gems/rack-1.4.5/lib/rack/multipart.rb
challah-0.9.1.beta.3 vendor/bundle/gems/rack-1.4.3/lib/rack/multipart.rb
rack-1.5.2 lib/rack/multipart.rb
rack-1.4.5 lib/rack/multipart.rb
rack-1.3.10 lib/rack/multipart.rb
devise_sociable-0.1.0 vendor/bundle/gems/rack-1.4.4/lib/rack/multipart.rb
devise_sociable-0.1.0 vendor/bundle/gems/rack-1.5.1/lib/rack/multipart.rb
rack-1.5.1 lib/rack/multipart.rb
rack-1.5.0 lib/rack/multipart.rb
backbone-queryparams-rails-0.0.1 vendor/bundle/gems/rack-1.4.4/lib/rack/multipart.rb
railscast-assets-0.0.2 vendor/bundle/gems/rack-1.4.4/lib/rack/multipart.rb
railscast-assets-0.0.2 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/rack-1.4.4/lib/rack/multipart.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/rack-1.4.4/lib/rack/multipart.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/rack-1.4.4/lib/rack/multipart.rb
rack-1.5.0.beta.2 lib/rack/multipart.rb
rack-1.4.4 lib/rack/multipart.rb
rack-1.3.9 lib/rack/multipart.rb
backbone-deep-rails-0.0.1 vendor/bundle/gems/rack-1.4.3/lib/rack/multipart.rb
rack-1.5.0.beta.1 lib/rack/multipart.rb