Module: CGI::QueryExtension

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

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(obj) ⇒ Object

Need to do lazy aliasing on the instance that we are extending because of the way QueryExtension gets included for each instance of the CGI object rather than on a module level. This method is a bit obtrusive because we are overriding CGI::QueryExtension::extended which could be used in the future. Need to research a better method



105
106
107
108
109
110
111
# File 'lib/action_controller/cgi_ext/multipart_progress.rb', line 105

def self.extended(obj)
  obj.instance_eval do
    # unless defined? will prevent clobbering the progress IO on multiple extensions
    alias :stdinput_without_progress :stdinput unless defined? stdinput_without_progress
    alias :stdinput :stdinput_with_progress 
  end
end

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

#stdinput_with_progressObject



113
114
115
# File 'lib/action_controller/cgi_ext/multipart_progress.rb', line 113

def stdinput_with_progress
  @stdin_with_progress or stdinput_without_progress
end