From 01a76eb1ddc67dda21cc2646dc73c15830cb3de7 Mon Sep 17 00:00:00 2001 From: Ian Ownbey Date: Sat, 22 Nov 2008 18:00:10 -0800 Subject: removed dispatchers --- lib/mongrel.rb | 60 ++++++++++++++------------------------------- lib/mongrel/http_request.rb | 8 +----- 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/lib/mongrel.rb b/lib/mongrel.rb index e3c56be..423abeb 100644 --- a/lib/mongrel.rb +++ b/lib/mongrel.rb @@ -138,47 +138,25 @@ module Mongrel script_name, path_info, handlers = @classifier.resolve(params[Const::REQUEST_PATH]) - if handlers - params[Const::PATH_INFO] = path_info - params[Const::SCRIPT_NAME] = script_name - - # From http://www.ietf.org/rfc/rfc3875 : - # "Script authors should be aware that the REMOTE_ADDR and REMOTE_HOST - # meta-variables (see sections 4.1.8 and 4.1.9) may not identify the - # ultimate source of the request. They identify the client for the - # immediate request to the server; that client may be a proxy, gateway, - # or other intermediary acting on behalf of the actual source client." - params[Const::REMOTE_ADDR] = client.peeraddr.last - - # select handlers that want more detailed request notification - notifiers = handlers.select { |h| h.request_notify } - request = HttpRequest.new(params, client, notifiers) - - # in the case of large file uploads the user could close the socket, so skip those requests - break if request.body == nil # nil signals from HttpRequest::initialize that the request was aborted - raise "CALLING APPPPPPP" - app_responce = @app.call(request.env) - response = HttpResponse.new(client, app_response).start - - # request is good so far, continue processing the response - # response = HttpResponse.new(client) - - # # Process each handler in registered order until we run out or one finalizes the response. - # handlers.each do |handler| - # handler.process(request, response) - # break if response.done or client.closed? - # end - - # # And finally, if nobody closed the response off, we finalize it. - # unless response.done or client.closed? - # response.finished - # end - else - # Didn't find it, return a stock 404 response. - client.write(Const::ERROR_404_RESPONSE) - end - - break #done + params[Const::PATH_INFO] = path_info + params[Const::SCRIPT_NAME] = script_name + + # From http://www.ietf.org/rfc/rfc3875 : + # "Script authors should be aware that the REMOTE_ADDR and REMOTE_HOST + # meta-variables (see sections 4.1.8 and 4.1.9) may not identify the + # ultimate source of the request. They identify the client for the + # immediate request to the server; that client may be a proxy, gateway, + # or other intermediary acting on behalf of the actual source client." + params[Const::REMOTE_ADDR] = client.peeraddr.last + + # select handlers that want more detailed request notification + request = HttpRequest.new(params, client) + + # in the case of large file uploads the user could close the socket, so skip those requests + break if request.body == nil # nil signals from HttpRequest::initialize that the request was aborted + app_response = @app.call(request.env) + response = HttpResponse.new(client, app_response).start + break #done else # Parser is not done, queue up more data to read and continue parsing chunk = client.readpartial(Const::CHUNK_SIZE) diff --git a/lib/mongrel/http_request.rb b/lib/mongrel/http_request.rb index 8df3a5a..0e3790f 100644 --- a/lib/mongrel/http_request.rb +++ b/lib/mongrel/http_request.rb @@ -22,17 +22,11 @@ module Mongrel # You don't really call this. It's made for you. # Main thing it does is hook up the params, and store any remaining # body data into the HttpRequest.body attribute. - def initialize(params, socket, dispatchers) + def initialize(params, socket) @params = params @socket = socket - @dispatchers = dispatchers content_length = @params[Const::CONTENT_LENGTH].to_i remain = content_length - @params.http_body.length - - # tell all dispatchers the request has begun - @dispatchers.each do |dispatcher| - dispatcher.request_begins(@params) - end unless @dispatchers.nil? || @dispatchers.empty? # Some clients (like FF1.0) report 0 for body and then send a body. This will probably truncate them but at least the request goes through usually. if remain <= 0 -- cgit v1.2.3-24-ge0c7