lib/puma/server.rb
def normalize_env(env, client)
      if host = env[HTTP_HOST]
        if colon = host.index(":")
          env[SERVER_NAME] = host[0, colon]
          env[SERVER_PORT] = host[colon+1, host.bytesize]
        else
          env[SERVER_NAME] = host
          env[SERVER_PORT] = PORT_80
        end
      end

      unless env[REQUEST_PATH]
        # it might be a dumbass full host request header
        uri = URI.parse(env[REQUEST_URI])
        env[REQUEST_PATH] = uri.path

        raise "No REQUEST PATH" unless env[REQUEST_PATH]
      end

      env[PATH_INFO] = env[REQUEST_PATH]

      # 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."
      #
      env[REMOTE_ADDR] = client.peeraddr.last
    end
# Given a Hash +env+ for the request read from +client+, add
# and fixup keys to comply with Rack's env guidelines.
#
Given a Hash +env+ for the request read from +client+, add
and fixup keys to comply with Rack's env guidelines.
Given a Hash + env + for the request read from + client + add and fixup keys to comply with Rack ' s env guidelines .
def normalize_env(env, client)
      if host = env[HTTP_HOST]
        if colon = host.index(":")
          env[SERVER_NAME] = host[0, colon]
          env[SERVER_PORT] = host[colon+1, host.bytesize]
        else
          env[SERVER_NAME] = host
          env[SERVER_PORT] = PORT_80
        end
      end
      unless env[REQUEST_PATH]
        uri = URI.parse(env[REQUEST_URI])
        env[REQUEST_PATH] = uri.path
        raise "No REQUEST PATH" unless env[REQUEST_PATH]
      end
      env[PATH_INFO] = env[REQUEST_PATH]
      env[REMOTE_ADDR] = client.peeraddr.last
    end
def normalize_env ( env , client ) if host = env [ HTTP_HOST ] if colon = host . index ( ":" ) env [ SERVER_NAME ] = host [ 0 , colon ] env [ SERVER_PORT ] = host [ colon + 1 , host . bytesize ] else env [ SERVER_NAME ] = host env [ SERVER_PORT ] = PORT_80 end end unless env [ REQUEST_PATH ] uri = URI . parse ( env [ REQUEST_URI ] ) env [ REQUEST_PATH ] = uri . path raise "No REQUEST PATH" unless env [ REQUEST_PATH ] end env [ PATH_INFO ] = env [ REQUEST_PATH ] env [ REMOTE_ADDR ] = client . peeraddr . last end
Given a Hash +env+ for the request read from +client+, add
and fixup keys to comply with Rack's env guidelines.
Given a Hash + env + for the request read from + client + add and fixup keys to comply with Rack ' s env guidelines .
# it might be a dumbass full host request header # 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." #
env
client