Log Request headers from Rack env
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
1005434
def get_headers(environ):
    
    for key, value in compat.iteritems(environ):
        key = str(key)
        if key.startswith("HTTP_") and key not in ("HTTP_CONTENT_TYPE", "HTTP_CONTENT_LENGTH"):
            yield key[5:].replace("_", "-").lower(), value
        elif key in ("CONTENT_TYPE", "CONTENT_LENGTH"):
            yield key.replace("_", "-").lower(), value
876528
void maybeLogRequest (String uri, String method, Properties parms, Properties header) {
    boolean filterOutRepetitiveStuff = true;

    String log = String.format("%-4s %s", method, uri);
    for( Object arg : parms.keySet() ) {
      String value = parms.getProperty((String) arg);
      if( value != null && value.length() != 0 )
        log += " " + arg + "=" + value;
    }

    Log.info_no_stdout(Sys.HTLOG, log);

    if (filterOutRepetitiveStuff) {
      if (uri.endsWith(".css")) return;
      if (uri.endsWith(".js")) return;
      if (uri.endsWith(".png")) return;
      if (uri.endsWith(".ico")) return;
      if (uri.startsWith("/Typeahead")) return;
      if (uri.startsWith("/2/Typeahead")) return;
      if (uri.endsWith("LogAndEcho.json")) return;
      if (uri.startsWith("/Cloud.json")) return;
      if (uri.contains("Progress")) return;
      if (uri.startsWith("/Jobs.json")) return;
      if (uri.startsWith("/Up.json")) return;
      if (uri.startsWith("/2/WaterMeter")) return;
    }

    Log.info(Sys.HTTPD, log);

    if(header.getProperty("user-agent") != null)
      H2O.GA.postAsync(new AppViewHit(uri).customDimension(H2O.CLIENT_TYPE_GA_CUST_DIM, header.getProperty("user-agent")));
    else
      H2O.GA.postAsync(new AppViewHit(uri));
  }
944905
def setup_controller_params(controller, env, vars)
      if Fastr::HTTP.method?(env, :get)
        controller.get_params = Fastr::HTTP.parse_query_string(env['QUERY_STRING'])
        controller.params = controller.get_params.merge(vars)
      elsif Fastr::HTTP.method?(env, :post)
        controller.post_params = {}
        controller.post_params = Fastr::HTTP.parse_query_string(env['rack.input'].read) if env['rack.input']
        controller.params = controller.post_params.merge(vars)
      else
        controller.params = vars
      end
    end
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
229981
def system_headers(input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/system/headers', input_params, always_retry=always_retry, **kwargs)
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
1248949
def process_request(env, req, res)
      start_time = Time.now

      request_path = URI.decode(env['PATH_INFO'].dup)
      request_path.force_encoding('UTF-8') if request_path.respond_to? :force_encoding
      request_path = ::Middleman::Util.full_path(request_path, @middleman)
      full_request_path = File.join(env['SCRIPT_NAME'], request_path) # Path including rack mount

      # Get the resource object for this path
      resource = @middleman.sitemap.by_destination_path(request_path.gsub(' ', '%20'))

      # Return 404 if not in sitemap
      return not_found(res, full_request_path) unless resource && !resource.ignored?

      # If this path is a binary file, send it immediately
      return send_file(resource, env) if resource.binary? || resource.static_file?

      res['Content-Type'] = resource.content_type || 'text/plain'

      begin
        # Write out the contents of the page
        res.write resource.render({}, rack: { request: req })

        # Valid content is a 200 status
        res.status = 200
      rescue Middleman::TemplateRenderer::TemplateNotFound => e
        res.write "Error: #{e.message}"
        res.status = 500
      end

      # End the request
      logger.debug "== Finishing Request: #{resource.destination_path} (#{(Time.now - start_time).round(2)}s)"
      halt res.finish
    end
899411
def GET
      fetch_header("action_dispatch.request.query_parameters") do |k|
        rack_query_params = super || {}
        # Check for non UTF-8 parameter values, which would cause errors later
        Request::Utils.check_param_encoding(rack_query_params)
        set_header k, Request::Utils.normalize_encode_params(rack_query_params)
      end
    rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
      raise ActionController::BadRequest.new("Invalid query parameters: #{e.message}")
    end
286857
def dir_list(load):
    '''
    
    '''
    if 'env' in load:
        # "env" is not supported; Use "saltenv".
        load.pop('env')

    ret = []

    if 'saltenv' not in load:
        return ret

    saltenv = load['saltenv']
    metadata = _init()

    if not metadata or saltenv not in metadata:
        return ret

    # grab all the dirs from the buckets cache file
    for bucket in _find_dirs(metadata[saltenv]):
        for dirs in six.itervalues(bucket):
            # trim env and trailing slash
            dirs = _trim_env_off_path(dirs, saltenv, trim_slash=True)
            # remove empty string left by the base env dir in single bucket mode
            ret += [_f for _f in dirs if _f]

    return ret
972191
def _log_request(self, request):
        
        msg = []
        for d in self.LOG_DATA:
            val = getattr(request, d)
            if val:
                msg.append(d + ': ' + repr(val))
        for d in self.LOG_HEADERS:
            if d in request.headers and request.headers[d]:
                msg.append(d + ': ' + repr(request.headers[d]))
        logger.info("Request information: %s", ', '.join(msg))
864040
def normalize_request(rack_req)
      host = rack_req.host

      s_req = Request.new
      s_req.path = path_for_rack_request(rack_req)
      s_req.is_path_style = true
      s_req.rack_request = rack_req

      if !@root_hostnames.include?(host)
        s_req.bucket = host.split(".")[0]
        s_req.is_path_style = false
      end

      s_req.http_verb = rack_req.request_method

      case rack_req.request_method
      when 'PUT'
        normalize_put(rack_req,s_req)
      when 'GET','HEAD'
        normalize_get(rack_req,s_req)
      when 'DELETE'
        normalize_delete(rack_req,s_req)
      when 'POST'
        normalize_post(rack_req,s_req)
      when 'OPTIONS'
        nomalize_options(rack_req,s_req)
      else
        return false
      end

      if s_req.type.nil?
        return false
      end

      return s_req
    end
1162134
def get_environ(self):
        """"""
        req = self.req
        env = {
            # set a non-standard environ entry so the WSGI app can know what
            # the *real* server protocol is (and what features to support).
            # See http://www.faqs.org/rfcs/rfc2145.html.
            'ACTUAL_SERVER_PROTOCOL': req.server.protocol,
            'PATH_INFO': req.path,
            'QUERY_STRING': req.qs,
            'REMOTE_ADDR': req.conn.remote_addr or '',
            'REMOTE_PORT': str(req.conn.remote_port or ''),
            'REQUEST_METHOD': req.method,
            'REQUEST_URI': req.uri,
            'SCRIPT_NAME': '',
            'SERVER_NAME': req.server.server_name,
            # Bah. "SERVER_PROTOCOL" is actually the REQUEST protocol.
            'SERVER_PROTOCOL': req.request_protocol,
            'SERVER_SOFTWARE': req.server.software,
            'wsgi.errors': sys.stderr,
            'wsgi.input': req.rfile,
            'wsgi.multiprocess': False,
            'wsgi.multithread': True,
            'wsgi.run_once': False,
            'wsgi.url_scheme': req.scheme,
            'wsgi.version': (1, 0),
            }
        
        if isinstance(req.server.bind_addr, basestring):
            # AF_UNIX. This isn't really allowed by WSGI, which doesn't
            # address unix domain sockets. But it's better than nothing.
            env["SERVER_PORT"] = ""
        else:
            env["SERVER_PORT"] = str(req.server.bind_addr[1])
        
        # Request headers
        for k, v in req.inheaders.iteritems():
            env["HTTP_" + k.upper().replace("-", "_")] = v
        
        # CONTENT_TYPE/CONTENT_LENGTH
        ct = env.pop("HTTP_CONTENT_TYPE", None)
        if ct is not None:
            env["CONTENT_TYPE"] = ct
        cl = env.pop("HTTP_CONTENT_LENGTH", None)
        if cl is not None:
            env["CONTENT_LENGTH"] = cl
        
        if req.conn.ssl_env:
            env.update(req.conn.ssl_env)
        
        return env
1036451
def bulk_log_header(registers = register_list)
      registers.map do |reg|
        range_address_header(reg.start, reg.count)
      end.flatten
    end
78863
def to_h
      h = RRRSpec.redis.hgetall(key)
      h['key'] = key
      h['log'] = log
      h['worker'] = { 'key' => h['worker'] }
      h['taskset'] = { 'key' => h['taskset'] }
      RRRSpec.convert_if_present(h, 'started_at') { |v| Time.zone.parse(v) }
      RRRSpec.convert_if_present(h, 'rsync_finished_at') { |v| Time.zone.parse(v) }
      RRRSpec.convert_if_present(h, 'setup_finished_at') { |v| Time.zone.parse(v) }
      RRRSpec.convert_if_present(h, 'finished_at') { |v| Time.zone.parse(v) }
      h
    end
1166975
def http_log_req(method, uri, args, kwargs):
    
    if not pyrax.get_http_debug():
        return
    string_parts = ["curl -i -X %s" % method]
    for element in args:
        string_parts.append("%s" % element)
    for element in kwargs["headers"]:
        header = "-H '%s: %s'" % (element, kwargs["headers"][element])
        string_parts.append(header)
    string_parts.append(uri)
    log = logging.getLogger("pyrax")
    log.debug("\nREQ: %s\n" % " ".join(string_parts))
    if "body" in kwargs:
        pyrax._logger.debug("REQ BODY: %s\n" % (kwargs["body"]))
    if "data" in kwargs:
        pyrax._logger.debug("REQ DATA: %s\n" % (kwargs["data"]))
356396
def index(environment, start_response, headers):
  
  response = {'service': 'kronosd',
              'version': kronos.__version__,
              'id': settings.node['id'],
              'storage': {},
              SUCCESS_FIELD: True}

  # Check if each backend is alive
  for name, backend in router.get_backends():
    response['storage'][name] = {'alive': backend.is_alive(),
                                 'backend': settings.storage[name]['backend']}

  start_response('200 OK', headers)
  return response