Skip to content

Commit

Permalink
Fixed new WEBrick handling to actually pass parameters
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1483 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Jun 22, 2005
1 parent 4e0ffab commit 413d10c
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions railties/lib/webrick_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ def stdinput
@stdin || $stdin
end

def stdinput=(input)
@stdin = input
end

def env_table
@env_table || ENV
end

def initialize(type = "query", table = nil, stdin = nil)
@env_table, @stdin = table, stdin

if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE")
Apache.request.setup_cgi_env
end

def env_table=(table)
@env_table = table
extend QueryExtension
@multipart = false
if defined?(CGI_PARAMS)
warn "do not use CGI_PARAMS and CGI_COOKIES"
@params = CGI_PARAMS.dup
@cookies = CGI_COOKIES.dup
else
initialize_query() # set @params, @cookies
end
@output_cookies = nil
@output_hidden = nil
end
end

Expand Down Expand Up @@ -88,7 +100,11 @@ def handle_file(req, res)

def handle_dispatch(req, res, origin = nil)
data = StringIO.new
Dispatcher.dispatch(create_cgi(req, origin), ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, data)
Dispatcher.dispatch(
CGI.new("query", create_env_table(req, origin), StringIO.new(req.body || "")),
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
data
)

header, body = extract_header_and_body(data)
assign_status(res, header)
Expand All @@ -103,13 +119,6 @@ def handle_dispatch(req, res, origin = nil)
end

private
def create_cgi(req, origin)
cgi = CGI.new
cgi.env_table = create_env_table(req, origin)
cgi.stdinput = req.body || ""
return cgi
end

def create_env_table(req, origin)
env = req.meta_vars.clone
env.delete "SCRIPT_NAME"
Expand Down

0 comments on commit 413d10c

Please sign in to comment.