diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-28 17:42:51 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-28 17:42:51 +0000 |
commit | 62ed6950c9119c12e6b17a68c79c45c77a7b1ca4 (patch) | |
tree | c00beda4e2f4ea5e88f39882dc421cb8b7e68a0d /actionpack/lib/action_controller/cgi_ext | |
parent | 96e590ca3c25e63d03c9ae5d74a40538cbe88f58 (diff) | |
download | rails-62ed6950c9119c12e6b17a68c79c45c77a7b1ca4.tar.gz rails-62ed6950c9119c12e6b17a68c79c45c77a7b1ca4.tar.bz2 rails-62ed6950c9119c12e6b17a68c79c45c77a7b1ca4.zip |
Added support for upload progress indicators in Apache and lighttpd 1.4.x (won't work in WEBrick or lighttpd 1.3.x) #1475 [Sean Treadway]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1552 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/cgi_ext')
-rw-r--r-- | actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb b/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb index 5cb13c2456..b2194eb07b 100644 --- a/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +++ b/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb @@ -6,6 +6,8 @@ class CGI #:nodoc: # Handles multipart forms (in particular, forms that involve file uploads). # Reads query parameters in the @params field, and cookies into @cookies. def initialize_query() + @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] || env_table['COOKIE'])) + if boundary = multipart_form_boundary @multipart = true @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH'])) @@ -13,8 +15,6 @@ class CGI #:nodoc: @multipart = false @params = CGI::parse(read_query_params || "") end - - @cookies = CGI::Cookie::parse((env_table['HTTP_COOKIE'] || env_table['COOKIE'])) end private @@ -28,16 +28,32 @@ class CGI #:nodoc: end end + def read_params_from_query + if defined? MOD_RUBY + Apache::request.args || '' + else + # fixes CGI querystring parsing for POSTs + if env_table['QUERY_STRING'].blank? && !env_table['REQUEST_URI'].blank? + env_table['QUERY_STRING'] = env_table['REQUEST_URI'].split('?', 2)[1] || '' + end + env_table['QUERY_STRING'] + end + end + + def read_params_from_post + stdinput.binmode if stdinput.respond_to?(:binmode) + content = stdinput.read(Integer(env_table['CONTENT_LENGTH'])) || '' + env_table['RAW_POST_DATA'] = content.split("&_").first.to_s.freeze # &_ is a fix for Safari Ajax postings that always append \000 + end + def read_query_params case env_table['REQUEST_METHOD'].to_s.upcase when 'CMD' read_from_cmdline when 'POST', 'PUT' - stdinput.binmode if stdinput.respond_to?(:binmode) - content = stdinput.read(Integer(env_table['CONTENT_LENGTH'])) || '' - env_table['RAW_POST_DATA'] = content.split("&_").first.to_s.freeze # &_ is a fix for Safari Ajax postings that always append \000 + read_params_from_post else # when 'GET', 'HEAD', 'DELETE', 'OPTIONS' - (defined?(MOD_RUBY) ? Apache::request.args : env_table['QUERY_STRING']) || '' + read_params_from_query end end end # module QueryExtension |