Class: Sunrise::FileUpload::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/sunrise/file_upload/request.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



16
17
18
19
20
21
22
23
# File 'lib/sunrise/file_upload/request.rb', line 16

def body
  if raw_post = @env['RAW_POST_DATA']
    raw_post.force_encoding(Encoding::BINARY) if raw_post.respond_to?(:force_encoding)
    StringIO.new(raw_post)
  else
    @env['rack.input']
  end
end

#raw_postObject



8
9
10
11
12
13
14
# File 'lib/sunrise/file_upload/request.rb', line 8

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