A Rack interface for the Request. Applies itself and whatever
 middlewares to the env and passes the new env into the adapter.

 environment - A Hash for the Rack env.

 Returns an Array of three items; a Rack tuple.
556850
def call(environment)
      app = adapter.new
      middlewares = @middlewares || []
      stack = Rack::Builder.new do
        middlewares.each do |middleware|
          klass, *args = middleware
          use klass, *args[0...-1].flatten, &args.last
        end
        run app
      end
      stack.call rack_env_defaults.merge(environment.update(env))
    end
258870
def restore_env(rack_env)
      env = rack_env.fetch('faraday')
      headers = env[:request_headers]
      headers.clear

      rack_env.each do |name, value|
        next unless String === name && String === value
        if NonPrefixedHeaders.include? name or name.index('HTTP_') == 0
          name = name.sub(/^HTTP_/, '').downcase.tr('_', '-')
          headers[name] = value
        end
      end

      env[:method] = rack_env['REQUEST_METHOD'].downcase.to_sym
      env[:rack_errors] = rack_env['rack.errors']
      env
    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
1299233
def prepare!(env)
      @env      = env
      @request  = Rack::Request.new(env)
      @response = Rack::Response.new
      @headers  = @response.header
      @params   = @request.GET.merge(@request.POST)
      @params.default_proc = proc do |hash, key|
        hash[key.to_s] if Symbol === key
      end
    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
497738
def environment_keys?(hash)
      hash.is_a?(Hash) && hash.any? { |k, _| environments.include?(k.to_s) }
    end
918309
def load_executor_envs
      prefix = 'SPARK_RUBY_EXECUTOR_ENV_'

      envs = ENV.select{|key, _| key.start_with?(prefix)}
      envs.each do |key, value|
        key = key.dup # ENV keys are frozen
        key.slice!(0, prefix.size)

        set("spark.ruby.executor.env.#{key}", value)
      end
    end
764770
def call(env)
      now              = Time.now.to_i
      session          = env['rack.session']
      window_size      = window_size(env)
      previous_timeout = session['aker.last_request_at']

      return @app.call(env) unless window_size > 0

      env['aker.timeout_at'] = now + window_size
      session['aker.last_request_at'] = now

      return @app.call(env) unless previous_timeout

      if now >= previous_timeout + window_size
        env['aker.session_expired'] = true
        env['warden'].logout
      end
      @app.call(env)
    end
1008792
def apply_to_request(context, rack_env:, for_type:)
      req = rails_req?(rack_env) ? rack_env : Rack::Request.new(rack_env)

      context.request = Context::Request.new unless context.request
      request = context.request

      request.socket = Context::Request::Socket.new(req)
      request.http_version = build_http_version rack_env
      request.method = req.request_method
      request.url = Context::Request::Url.new(req)

      request.body = should_capture_body?(for_type) ? get_body(req) : SKIPPED

      headers, env = get_headers_and_env(rack_env)
      request.headers = headers if config.capture_headers?
      request.env = env if config.capture_env?

      context
    end
1169743
def env
      vars = {}
      @stack.variables.each { |k, v| vars["TF_VAR_#{k}"] = v }
      SECRETS.each do |_provider, secrets|
        if secrets.is_a?(Hash)
          secrets.each do |k, v|
            vars[k.to_s] = v
          end
        end
      end
      vars
    end
356375
def call(env)
      # Store environment, request and response for later
      req = ::Rack::Request.new(env)
      res = ::Rack::Response.new

      logger.debug "== Request: #{env['PATH_INFO']}"

      # Catch :halt exceptions and use that response if given
      catch(:halt) do
        process_request(env, req, res)
        res.status = 404
        res.finish
      end
    end
102928
def call(env)
      begin
        if running? && !path_ignored?(env)
          transaction = start_transaction(env)
        end

        resp = @app.call env
      rescue InternalError
        raise # Don't report ElasticAPM errors
      rescue ::Exception => e
        context = ElasticAPM.build_context(rack_env: env, for_type: :error)
        ElasticAPM.report(e, context: context, handled: false)
        raise
      ensure
        if resp && transaction
          status, headers, _body = resp
          transaction.add_response(status, headers: headers.dup)
        end

        ElasticAPM.end_transaction http_result(status)
      end

      resp
    end
50175
def update_environment(self, environment, environment_ids):
        

        uri = 'api/v3/environment/%s/' % environment_ids

        data = dict()
        data['environments'] = list()
        data['environments'].append(environment)

        return super(ApiEnvironment, self).put(uri, data)
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
1248739
def stub_env_config(inst, hash = nil)
      (hash = inst; inst = nil) if inst.is_a?(Hash)
      inst = @env || env unless inst

      hash = Jekyll::Utils.deep_merge_hashes(inst.asset_config, hash)
      allow(inst).to receive(:asset_config).and_return(hash)
    end
943232
def _get_envs(self):
        '''
        
        '''
        envs = ['base']
        if 'file_roots' in self.opts:
            envs.extend([x for x in list(self.opts['file_roots'])
                         if x not in envs])
        env_order = self.opts.get('env_order', [])
        # Remove duplicates while preserving the order
        members = set()
        env_order = [env for env in env_order if not (env in members or members.add(env))]
        client_envs = self.client.envs()
        if env_order and client_envs:
            return [env for env in env_order if env in client_envs]

        elif env_order:
            return env_order
        else:
            envs.extend([env for env in client_envs if env not in envs])
            return envs
315948
def get_key_from_envs(envs, key):
    
    # if it barks like a dict, make it a list have to use `get` since dicts and
    # lists both have __getitem__
    if hasattr(envs, 'get'):
        envs = [envs]

    for env in envs:
        if key in env:
            return env[key]

    return NO_VALUE