Permalink
Browse files

A few missing files

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@468 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 93f7cb2 commit dfed3d309e26c11ba4132aaf4c3cd25ad3b2c905 @dhh dhh committed Jan 20, 2005
@@ -0,0 +1,44 @@
+class CGI #:nodoc:
+ # Add @request.env['RAW_POST_DATA'] for the vegans.
+ module QueryExtension
+ # 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.
+ def initialize_query()
+ if boundary = multipart_form_boundary
+ @multipart = true
+ @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
+ else
+ @multipart = false
+ @params = CGI::parse(read_query_params)
+ end
+ end
+
+ private
+ def multipart_form_boundary
+ multipart_form_boundary_re = %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n # " ruby-mode
+
+ if env_table['REQUEST_METHOD'] == 'POST'
+ multipart_form_boundary_re.match(env_table['CONTENT_TYPE']).to_a.pop
+ end
+ end
+
+ def read_query_params
+ case env_table['REQUEST_METHOD']
+ when 'GET', 'HEAD'
+ if defined? MOD_RUBY
+ Apache::request.args or ''
+ else
+ env_table['QUERY_STRING'] or ''
+ end
+ when 'POST'
+ stdinput.binmode if stdinput.respond_to?(:binmode)
+ content = stdinput.read(Integer(env_table['CONTENT_LENGTH'])) or ''
+ env_table['RAW_POST_DATA'] = content.freeze
+ else
+ read_from_cmdline
+ end
+ end
+ end # module QueryExtension
+end
@@ -0,0 +1,31 @@
+require 'test/unit'
+require 'cgi'
+require 'stringio'
+require File.dirname(__FILE__) + '/../../lib/action_controller/cgi_ext/raw_post_data_fix'
+
+class RawPostDataTest < Test::Unit::TestCase
+ def setup
+ ENV['REQUEST_METHOD'] = 'POST'
+ ENV['CONTENT_TYPE'] = ''
+ ENV['CONTENT_LENGTH'] = '0'
+ end
+
+ def test_raw_post_data
+ process_raw "action=create_customer&full_name=David%20Heinemeier%20Hansson&customerId=1"
+ end
+
+ private
+ def process_raw(query_string)
+ old_stdin = $stdin
+ begin
+ $stdin = StringIO.new(query_string.dup)
+ ENV['CONTENT_LENGTH'] = $stdin.size.to_s
+ CGI.new
+ assert_not_nil ENV['RAW_POST_DATA']
+ assert ENV['RAW_POST_DATA'].frozen?
+ assert_equal query_string, ENV['RAW_POST_DATA']
+ ensure
+ $stdin = old_stdin
+ end
+ end
+end
@@ -0,0 +1,12 @@
+require 'abstract_unit'
+require 'fixtures/topic'
+
+class TestColumnAlias < Test::Unit::TestCase
+
+ def test_column_alias
+ topic = Topic.find(1)
+ records = topic.connection.select_all("SELECT id AS pk FROM topics LIMIT 1")
+ assert_equal(records[0].keys[0], "pk")
+ end
+
+end
View
@@ -2,7 +2,7 @@
build_number = `svn log -q -rhead http://dev.rubyonrails.org/svn/rails`.scan(/r([0-9]*)/).first.first.to_i
-%w( actionmailer actionpack activerecord railties ).each do |pkg|
+(%w( actionmailer actionpack activerecord railties ) - ARGV).each do |pkg|
puts "Pushing: #{pkg} (#{build_number})"
`cd #{pkg} && PKG_BUILD=#{build_number} rake pgem && cd ..`
end

0 comments on commit dfed3d3

Please sign in to comment.