The real Rack call interface.
 This is the common behavior for both the verbose and summary logging
 middlewares. It sets rack's logger, times the response and returns it as is.
492326
def call!(env)
      env['rack.logger'] = @logger

      status, headers, body = nil, nil, nil
      benchmark = Benchmark.measure do
        status, headers, body = @app.call(env)
      end
      log_error(env['deas.error'])
      env['deas.time_taken'] = RoundedTime.new(benchmark.real)

      [status, headers, body]
    end
964372
def execute
      # Here is the order of operations:
      # -> setting @data_sent
      # -> executing before_request_execution callback
      # -> executing the HTTP request
      # -> setting @response
      # -> setting @data_received
      # -> executing after_request_execution callback

      # Setting @data_sent
      params = Rack::Utils.parse_nested_query(URI.parse(@http_request.path).query)
      # Since that's how it will be interpreted anyway on the server, we merge the POST params to the GET params,
      # but it's not supposed to happen: either every params is prepared for GET/query params, or as POST body
      params.merge!(Rack::Utils.parse_nested_query(@http_request.body.to_s))

      # About: Hash[{}.map{|k,v| [k, v.join] }]
      # it transforms the following hash:
      # {"accept"=>["*/*"], "user-agent"=>["TheBigDB RubyWrapper/X.Y.Z"], "host"=>["computer.host"]}
      # into the following hash:
      # {"accept"=>"*/*", "user-agent"=>"TheBigDB RubyWrapper/X.Y.Z", "host"=>"computer.host"}
      # which is way more useful and cleaner.
      @data_sent = {
        "headers" => Hash[@http_request.to_hash.map{|k,v| [k, v.join] }],
        "host" => @http.address,
        "port" => @http.port,
        "path" => URI.parse(@http_request.path).path,
        "method" => @http_request.method,
        "params" => params
      }

      # Executing callback
      TheBigDB.before_request_execution.call(self)

      # Here is where the request is actually executed
      @http_response = TheBigDB.http_request_executor.call(@http, @http_request)

      # Setting @response
      begin
        # We parse the JSON answer and return it.
        @response = JSON(@http_response.body)
      rescue JSON::ParserError => e
        @response = {"status" => "error", "error" => {"code" => "0000", "description" => "The server gave an invalid JSON body:\n#{@http_response.body}"}}
      end

      # Setting @data_received
      @data_received = {
        "headers" => Hash[@http_response.to_hash.map{|k,v| [k, v.join] }],
        "content" => @response
      }

      # Executing callback
      TheBigDB.after_request_execution.call(self)

      # Raising exception if asked
      if TheBigDB.raise_on_api_status_error and @response["status"] == "error"
        raise ApiStatusError.new(@response["error"]["code"])
      end

      self
    end
200099
def call!(env)
      env['deas.logging'] = Proc.new{ |msg| } # no-op
      status, headers, body = super(env)
      request = Rack::Request.new(env)
      line_attrs = {
        'method'  => request.request_method,
        'path'    => request.path,
        'params'  => env['deas.params'],
        'splat'   => env['deas.splat'],
        'time'    => env['deas.time_taken'],
        'status'  => status
      }
      if env['deas.handler_class']
        line_attrs['handler'] = env['deas.handler_class'].name
      end
      if headers.key?('Location')
        line_attrs['redir'] = headers['Location']
      end
      log SummaryLine.new(line_attrs)
      [status, headers, body]
    end
143057
def call(env)
      request = env['rack-accept_headers.request'] ||= Request.new(env)
      check!(request) unless @checks.empty?
      @app.call(env)
    rescue AcceptError
      response = Response.new
      response.not_acceptable!
      response.finish
    end
392940
def default_logger(verbose=false)
      if verbose
        logger = Logger.new(STDOUT)
        logger.level = Logger::DEBUG
        logger.formatter = PlainLoggerFormatter.new
      else
        logger = RightScale::Log
      end
      return logger
    end
840196
def call(env)
      # remove the callback and _ parameters BEFORE calling the backend, so
      # that caching middleware does not store a copy for each value of the
      # callback parameter
      request = Rack::Request.new(env)
      callback = request.params.delete(@callback_param)
      timestamp = request.params.delete(@timestamp_param)
      env['QUERY_STRING'] = env['QUERY_STRING'].split("&").delete_if{|param|
        param =~ /^(#{@timestamp_param}|#{@callback_param})=/
      }.join("&")
      env['rack.jsonp.callback'] = callback
      env['rack.jsonp.timestamp'] = timestamp

      status, headers, response = @app.call(env)

      if callback && headers['Content-Type'] =~ /json/i
        response = pad(callback, response)
        headers['Content-Length'] = response.first.bytesize.to_s
        headers['Content-Type'] = 'application/javascript'
      elsif @carriage_return && headers['Content-Type'] =~ /json/i
        # add a \n after the response if this is a json (not JSONP) response
        response = carriage_return(response)
        headers['Content-Length'] = response.first.bytesize.to_s
      end

      [status, headers, response]
    end
743372
def log_detailed(label, params = {})
      return unless RMQ.app.development? || RMQ.app.test?

      objects = params[:objects]
      skip_first_caller = params[:skip_first_caller]

      if block_given? && !objects
        objects = yield
      end

      callers = caller
      callers = callers.drop(1) if skip_first_caller

      out = %(

        ------------------------------------------------
        Deep log - #{label}
        At: #{Time.now.to_s}

        Callers:
        #{callers.join("\n - ")}

        Objects:
        #{objects.map{|k, v| "#{k.to_s}: #{v.inspect}" }.join("\n\n")}
        ------------------------------------------------

      ).gsub(/^ +/, '')

      NSLog out
      label
    end
962040
def _server_begin_response_callback(self, response: Response):
        ''''''
        self._item_session.response = response

        if self._cookie_jar:
            self._cookie_jar.extract_cookies(response, self._item_session.request)

        action = self._result_rule.handle_pre_response(self._item_session)
        self._file_writer_session.process_response(response)

        return action == Actions.NORMAL
549894
function(request, callback, response_middlewares) {
        var that = this;
        request.finalize(function(err, res) {
            if (err) callback(err, null);
            else that._callResponseMiddlewares(response_middlewares, res, callback);
        });
    }
887258
@Override public RackResponse call(RackEnvironment environment) {
    RubyHash environmentHash = convertToRubyHash(environment.entrySet());

    RubyArray response = callRackApplication(environmentHash);

    return convertToJavaRackResponse(response);
  }
872156
def call(env)
      # Set the request data for bugsnag middleware to use
      Bugsnag.configuration.set_request_data(:rack_env, env)
      if Bugsnag.configuration.auto_capture_sessions
        Bugsnag.start_session
      end

      begin
        response = @app.call(env)
      rescue Exception => raised
        # Notify bugsnag of rack exceptions
        Bugsnag.notify(raised, true) do |report|
          report.severity = "error"
          report.severity_reason = {
            :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
            :attributes => Bugsnag::Rack::FRAMEWORK_ATTRIBUTES
          }
        end

        # Re-raise the exception
        raise
      end

      # Notify bugsnag of rack exceptions
      if env["rack.exception"]
        Bugsnag.notify(env["rack.exception"], true) do |report|
          report.severity = "error"
          report.severity_reason = {
            :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
            :attributes => FRAMEWORK_ATTRIBUTES
          }
        end
      end

      response
    ensure
      # Clear per-request data after processing the each request
      Bugsnag.configuration.clear_request_data
    end
236188
protected final <R extends RaftResponse> R logResponse(R response) {
    log.trace("Sending {}", response);
    return response;
  }
192147
def call(env)
      return render(500) do |xml|
        xml.h2("#{@key} env is not initialized")
      end unless env[@key]

      request = ::Rack::Request.new(env)

      if action = dispatch_action(request)
        send(action, request)
      else
        @app.call(env)
      end
    end
138085
function loggingMiddleware(req, res, next) {
  logRequest(req, res);
  setupResponseInterceptors(req, res);
  next();
}
23145
def call(env)
      began_at = Time.now
      began_ns = Process.clock_gettime(Process::CLOCK_MONOTONIC, :nanosecond)

      # this is closed after the app is called, so read it before 
      env["rack.input"].rewind
      request_body = env["rack.input"].read
      env["rack.input"].rewind

      if @logger && @logger.formatter.respond_to?(:current_tags)
        log_tags = @logger.formatter.current_tags.dup
      end

      request = Rack::Request.new(env)
      request_uri = Addressable::URI.new(
        :scheme => request.scheme,
        :host => request.host,
        :port => request.port,
        :path => request.path,
        :query => (request.query_string unless request.query_string.empty?)
      )

      status, response_headers, response_body = @app.call(env)
      response_headers = ::Rack::Utils::HeaderHash.new(response_headers)
      body_proxy = ::Rack::BodyProxy.new(response_body) do
        log(env, request_uri, request_body, status, response_headers, response_body, began_at, began_ns, log_tags)
      end
      [status, response_headers, body_proxy]
    end
692010
def __get_calls_from_parser(proxy_parser, real_parser):
    
    __parsers[proxy_parser] = real_parser
    for method, safe, args, kwargs, proxy_subparser in proxy_parser.calls:
        args = (__proxy_to_real_parser(v) for v in args)
        kwargs = {k: __proxy_to_real_parser(v) for k, v in kwargs.items()}
        real_subparser = getattr(real_parser, method)(*args, **kwargs)
        if real_subparser is not None:
            __get_calls_from_parser(proxy_subparser, real_subparser)
987561
def call(env)
      if env['REQUEST_METHOD'] == 'GET' && env['PATH_INFO'] == logout_path(env)
        ::Rack::Response.new(login_html(env, :logged_out => true)) do |resp|
          resp['Content-Type'] = 'text/html'
        end.finish
      else
        @app.call(env)
      end
    end