Sha256: 70ea22d645263f1b408ab5069d29282a12c610db266cb3c36d2cd8c7fb60502b

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

require 'rack/request'
require 'stringio'

module Sunrise
  module FileUpload
    class Request < ::Rack::Request
    
      def raw_post
        unless @env.include? 'RAW_POST_DATA'
          @env['RAW_POST_DATA'] = body.read(@env['CONTENT_LENGTH'].to_i)
          body.rewind if body.respond_to?(:rewind)
        end
        @env['RAW_POST_DATA']
      end
      
      def body
        if raw_post = @env['RAW_POST_DATA']
          raw_post = raw_post.force_encoding(Encoding::BINARY) if raw_post.respond_to?(:force_encoding)
          StringIO.new(raw_post)
        else
          @env['rack.input']
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sunrise-file-upload-0.1.4 lib/sunrise/file_upload/request.rb