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
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/rack-1.5.5/lib/rack/multipart.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/rack-1.5.5/lib/rack/multipart.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/rack-1.5.5/lib/rack/multipart.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/multipart.rb
rack-1.4.7 lib/rack/multipart.rb
rack-1.5.5 lib/rack/multipart.rb
rack-1.4.6 lib/rack/multipart.rb
rack-1.5.4 lib/rack/multipart.rb
rack-1.5.3 lib/rack/multipart.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/lib/rack/multipart.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/multipart.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/multipart.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/multipart.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/multipart.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/multipart.rb
scout_realtime-1.0.5 lib/vendor/rack-1.5.2/lib/rack/multipart.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/multipart.rb
scout_realtime-1.0.4 lib/vendor/rack-1.5.2/lib/rack/multipart.rb
scout_realtime-1.0.3 lib/vendor/rack-1.5.2/lib/rack/multipart.rb
scout_realtime-1.0.3.pre lib/vendor/rack-1.5.2/lib/rack/multipart.rb