Rack Interface

 @param env Rack environment
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
829718
function getServeEnv (baseDir) {
  let serverEnv

  const envPath = path.join(baseDir, 'config/env')
  if (fs.existsSync(envPath)) {
    serverEnv = fs.readFileSync(envPath, 'utf8')
  }

  if (!serverEnv) {
    serverEnv = process.env.KNOTWORK_ENV || process.env.KOA_ENV
  }

  if (!serverEnv) {
    if (process.env.NODE_ENV === 'test') {
      serverEnv = 'unittest'
    } else if (process.env.NODE_ENV === 'production') {
      serverEnv = 'prod'
    } else {
      serverEnv = 'local'
    }
  } else {
    serverEnv = serverEnv.trim()
  }

  return serverEnv
}
954514
def fix_headers!(env)
      env.keys.select { |k| k =~ /^HTTP_X_/ }.each do |k|
        env[k.gsub("HTTP_", "")] = env[k]
        env.delete(k)
      end
      env
    end
101229
def call!(env)
      log "===== Received request ====="
      Rack::Request.new(env).tap do |request|
        log "  Method:  #{request.request_method.inspect}"
        log "  Path:    #{request.path.inspect}"
      end
      env['deas.logging'] = Proc.new{ |msg| log(msg) }
      status, headers, body = super(env)
      log "  Redir:   #{headers['Location']}" if headers.key?('Location')
      log "===== Completed in #{env['deas.time_taken']}ms (#{response_display(status)}) ====="
      [status, headers, body]
    end
328920
def on_complete(env)
      env[:body] = Nori.new(
        strip_namespaces: true,
        convert_tags_to: ->(tag) { tag.snakecase.to_sym }
      ).parse(env[:body])

      raise SOAPError, "Invalid SOAP response" if env[:body].empty?

      env[:body] = env[:body][:envelope][:body]
      env[:body] = find_key_in_hash(env[:body], @key)
    end
350427
function Env(data, parent, path) {
	Context.call(this, data, parent, path);
	delete this.env;
}
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
868571
def call(env)
      @request = Rack::Request.new(env)

      return @app.call(env) if ignore?

      @scheme = if enforce_ssl?
        'https'
      elsif enforce_non_ssl?
        'http'
      end

      if redirect_required?
        call_before_redirect
        modify_location_and_redirect
      elsif ssl_request?
        status, headers, body = @app.call(env)
        flag_cookies_as_secure!(headers) if @options[:force_secure_cookies]
        set_hsts_headers!(headers) if @options[:hsts] && !@options[:strict]
        [status, headers, body]
      else
        @app.call(env)
      end
    end
331017
def route_request(rack_env, env)
      rack_request = Rack::Request.new(rack_env)

      if rack_request.request_method != "POST"
        return bad_route_error("HTTP request method must be POST", rack_request)
      end

      content_type = rack_request.get_header("CONTENT_TYPE")
      if !Encoding.valid_content_type?(content_type)
        return bad_route_error("Unexpected Content-Type: #{content_type.inspect}. Content-Type header must be one of #{Encoding.valid_content_types.inspect}", rack_request)
      end
      env[:content_type] = content_type

      path_parts = rack_request.fullpath.split("/")
      if path_parts.size < 3 || path_parts[-2] != self.full_name
        return bad_route_error("Invalid route. Expected format: POST {BaseURL}/#{self.full_name}/{Method}", rack_request)
      end
      method_name = path_parts[-1]

      base_env = self.class.rpcs[method_name]
      if !base_env
        return bad_route_error("Invalid rpc method #{method_name.inspect}", rack_request)
      end
      env.merge!(base_env) # :rpc_method, :input_class, :output_class

      input = nil
      begin
        input = Encoding.decode(rack_request.body.read, env[:input_class], content_type)
      rescue => e
        error_msg = "Invalid request body for rpc method #{method_name.inspect} with Content-Type=#{content_type}"
        if e.is_a?(Google::Protobuf::ParseError)
          error_msg += ": #{e.message.strip}"
        end
        return bad_route_error(error_msg, rack_request)
      end

      env[:input] = input
      env[:http_response_headers] = {}
      return
    end
1325141
def POST
      if @env["rack.request.form_input"].eql? @env["rack.input"]
        @env["rack.request.form_hash"]
      elsif form_data? || parseable_data?
        @env["rack.request.form_input"] = @env["rack.input"]
        unless @env["rack.request.form_hash"] =
            Utils::Multipart.parse_multipart(env)
          form_vars = @env["rack.input"].read

          # Fix for Safari Ajax postings that always append \0
          form_vars.sub!(/\0\z/, '')

          @env["rack.request.form_vars"] = form_vars
          @env["rack.request.form_hash"] = Utils.parse_nested_query(form_vars)

          @env["rack.input"].rewind
        end
        @env["rack.request.form_hash"]
      else
        {}
      end
    end
222656
def env(mounts):
    
    f_mounts = [m.strip("/") for m in mounts]

    root = local.path("/")

    ld_libs = [root / m / "lib" for m in f_mounts]
    ld_libs.extend([root / m / "lib64" for m in f_mounts])

    paths = [root / m / "bin" for m in f_mounts]
    paths.extend([root / m / "sbin" for m in f_mounts])
    paths.extend([root / m for m in f_mounts])
    return paths, ld_libs
290492
protected function setEnvironment(Application $app, ?string $env = null): void
    {
        $app->detectEnvironment(function () use ($env) {
            return $env ?: env('APP_ENV', 'production');
        });
    }
526328
def env=(env)
      @env  = env
      uri   = URI.parse(env)
      @http = Net::HTTP.new(uri.host, uri.port)
      # HTTPS
      if uri.scheme == "https"
        @http.use_ssl     = true
        @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
    end
971020
def headers_for_env(env)
      return "" if env.blank?

      parameters = filter_parameters(env)

      headers = []
      headers << "Method:      #{env['REQUEST_METHOD']}"
      headers << "URL:         #{env['REQUEST_URI']}"
      if env['REQUEST_METHOD'].downcase != "get"
        headers << "Parameters:\n#{pretty_hash(parameters.except(:controller, :action), 13)}"
      end
      headers << "Controller:  #{parameters['controller']}##{parameters['action']}"
      headers << "RequestId:   #{env['action_dispatch.request_id']}"
      headers << "User-Agent:  #{env['HTTP_USER_AGENT']}"
      headers << "Remote IP:   #{env['REMOTE_ADDR']}"
      headers << "Language:    #{env['HTTP_ACCEPT_LANGUAGE']}"
      headers << "Server:      #{Socket.gethostname}"
      headers << "Process:     #{$PROCESS_ID}"

      headers.join("\n")
    end
691981
def env_for(rjr_method)
     # look for exact match first
     env = @environments.find { |k,v| k == rjr_method }

     # if not found try to match regex's
     env ||= @environments.find { |k,v| k.is_a?(Regexp) && (k =~ rjr_method) }

     env.nil? ? nil : env.last
  end
360156
def _call( env )
      env.merge! "rack.lodash" => {"organisation" => @organisation}

      request = Rack::Request.new(env.dup)
      if request.path_info == @http_path_to_lodash
        response = Rack::Response.new
        # for caching
        response.headers.merge! caching_headers( LODASH_FILE_NAME, LODASH_VERSION_DATE)

        # There's no need to test if the IF_MODIFIED_SINCE against the release date because the header will only be passed if the file was previously accessed by the requester, and the file is never updated. If it is updated then it is accessed by a different path.
        if request.env['HTTP_IF_MODIFIED_SINCE']
          response.status = 304
        else
          response.status = 200
          response.write ::File.read( ::File.expand_path "../../../vendor/assets/javascript/libs/lodash/#{LODASH_VERSION}/lodash.min.js", __FILE__)
        end
        response.finish
      else
        @app.call(env)
      end
    end
1299527
def initialize_metal
      Rails::Rack::Metal.requested_metals = configuration.metals
      Rails::Rack::Metal.metal_paths = ["#{TRUSTY_CMS_ROOT}/app/metal"] # reset Rails default to TRUSTY_CMS_ROOT
      Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
      Rails::Rack::Metal.metal_paths += extension_loader.paths(:metal)
      Rails::Rack::Metal.metal_paths.uniq!

      configuration.middleware.insert_before(
        :"ActionController::ParamsParser",
        Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?)
    end