Repository: puma/puma
File: lib/puma/const.rb (Ruby)

Code before:

    PUMA_VERSION = VERSION = "5.0.2".freeze
    CODE_NAME = "Spoony Bard".freeze

    PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze

    FAST_TRACK_KA_TIMEOUT = 0.2

    # The default number of seconds for another request within a persistent
    # session.
    PERSISTENT_TIMEOUT = 20

    # The default number of seconds to wait until we get the first data
    # for the request
    FIRST_DATA_TIMEOUT = 30

    # How long to wait when getting some write blocking on the socket when
    # sending data back
    WRITE_TIMEOUT = 10

    # How many requests to attempt inline before sending a client back to
    # the reactor to be subject to normal ordering. The idea here is that
    # we amortize the cost of going back to the reactor for a well behaved
    # but very "greedy" client across 10 requests. This prevents a not
    # well behaved client from monopolizing the thread forever.
    MAX_FAST_INLINE = ENV.fetch('MAX_FAST_INLINE', 10).to_i

    # The original URI requested by the client.
    REQUEST_URI= 'REQUEST_URI'.freeze
    REQUEST_PATH = 'REQUEST_PATH'.freeze
    QUERY_STRING = 'QUERY_STRING'.freeze
    CONTENT_LENGTH = "CONTENT_LENGTH".freeze

    PATH_INFO = 'PATH_INFO'.freeze

    PUMA_TMP_BASE = "puma".freeze

    ERROR_RESPONSE = {
      # Indicate that we couldn't parse the request
      400 => "HTTP/1.1 400 Bad Request\r\n\r\n".freeze,
      # The standard empty 404 response for bad requests.  Use Error4040Handler for custom stuff.
      404 => "HTTP/1.1 404 Not Found\r\nConnection: close\r\nServer: Puma #{PUMA_VERSION}\r\n\r\nNOT FOUND".freeze,
      # The standard empty 408 response for requests that timed out.
      408 => "HTTP/1.1 408 Request Timeout\r\nConnection: close\r\nServer: Puma #{PUMA_VERSION}\r\n\r\n".freeze,
      # Indicate that there was an internal error, obviously.
      500 => "HTTP/1.1 500 Internal Server Error\r\n\r\n".freeze,
      # A common header for indicating the server is too busy.  Not used yet.
      503 => "HTTP/1.1 503 Service Unavailable\r\n\r\nBUSY".freeze
    }

    # The basic max request size we'll try to read.

Review comment (suggestion):
I think it would be cleaner to make this an attribute of the Server object, which is read from configuration. 

We don't have any env variables setting constants right now, probably shouldn't start.

Code after:

    PUMA_VERSION = VERSION = "5.0.2".freeze
    CODE_NAME = "Spoony Bard".freeze

    PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze

    FAST_TRACK_KA_TIMEOUT = 0.2

    # The default number of seconds for another request within a persistent
    # session.
    PERSISTENT_TIMEOUT = 20

    # The default number of seconds to wait until we get the first data
    # for the request
    FIRST_DATA_TIMEOUT = 30

    # How long to wait when getting some write blocking on the socket when
    # sending data back
    WRITE_TIMEOUT = 10

    # How many requests to attempt inline before sending a client back to
    # the reactor to be subject to normal ordering. The idea here is that
    # we amortize the cost of going back to the reactor for a well behaved
    # but very "greedy" client across 10 requests. This prevents a not
    # well behaved client from monopolizing the thread forever.
    MAX_FAST_INLINE = 10

    # The original URI requested by the client.
    REQUEST_URI= 'REQUEST_URI'.freeze
    REQUEST_PATH = 'REQUEST_PATH'.freeze
    QUERY_STRING = 'QUERY_STRING'.freeze
    CONTENT_LENGTH = "CONTENT_LENGTH".freeze

    PATH_INFO = 'PATH_INFO'.freeze

    PUMA_TMP_BASE = "puma".freeze

    ERROR_RESPONSE = {
      # Indicate that we couldn't parse the request
      400 => "HTTP/1.1 400 Bad Request\r\n\r\n".freeze,
      # The standard empty 404 response for bad requests.  Use Error4040Handler for custom stuff.
      404 => "HTTP/1.1 404 Not Found\r\nConnection: close\r\nServer: Puma #{PUMA_VERSION}\r\n\r\nNOT FOUND".freeze,
      # The standard empty 408 response for requests that timed out.
      408 => "HTTP/1.1 408 Request Timeout\r\nConnection: close\r\nServer: Puma #{PUMA_VERSION}\r\n\r\n".freeze,
      # Indicate that there was an internal error, obviously.
      500 => "HTTP/1.1 500 Internal Server Error\r\n\r\n".freeze,
      # A common header for indicating the server is too busy.  Not used yet.
      503 => "HTTP/1.1 503 Service Unavailable\r\n\r\nBUSY".freeze
    }

    # The basic max request size we'll try to read.