Module: CGI::QueryExtension

Defined in:
lib/action_controller/cgi_ext/raw_post_data_fix.rb

Overview

Add @request.env for the vegans.

Instance Method Summary collapse

Instance Method Details

#initialize_queryObject

Initialize the data from the query.

Handles multipart forms (in particular, forms that involve file uploads). Reads query parameters in the @params field, and cookies into @cookies.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/action_controller/cgi_ext/raw_post_data_fix.rb', line 8

def initialize_query()
  @cookies = CGI::Cookie::parse(env_table['HTTP_COOKIE'] || env_table['COOKIE'])

  #fix some strange request environments
  if method = env_table['REQUEST_METHOD']
    method = method.to_s.downcase.intern
  else
    method = :get
  end

  if method == :post && (boundary = multipart_form_boundary)
    @multipart = true
    @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
  else
    @multipart = false
    @params = CGI::parse(read_query_params(method) || "")
  end
end