Module: Puma::Const
- Included in:
- Binder, Client, ErrorLogger, Request, Server
- Defined in:
- lib/puma/const.rb
Overview
Frequently used constants when constructing requests or responses. Many times the constant just refers to a string with the same contents. Using these constants gave about a 3% to 10% performance improvement over using the strings directly.
The constants are frozen because Hash#[]= when called with a String key dups the String UNLESS the String is frozen. This saves us therefore 2 object allocations when creating the env hash later.
While Puma does try to emulate the CGI/1.2 protocol, it does not use the REMOTE_IDENT, REMOTE_USER, or REMOTE_HOST parameters since those are either a security problem or too taxing on performance.
Constant Summary collapse
- PUMA_VERSION =
VERSION = "6.0.2"
- CODE_NAME =
"Sunflower"
- PUMA_SERVER_STRING =
["puma", PUMA_VERSION, CODE_NAME].join(" ").freeze
- FAST_TRACK_KA_TIMEOUT =
0.2
- WRITE_TIMEOUT =
How long to wait when getting some write blocking on the socket when sending data back
10
- REQUEST_URI =
The original URI requested by the client.
"REQUEST_URI"
- REQUEST_PATH =
"REQUEST_PATH"
- QUERY_STRING =
"QUERY_STRING"
- CONTENT_LENGTH =
"CONTENT_LENGTH"
- PATH_INFO =
"PATH_INFO"
- PUMA_TMP_BASE =
"puma"
- ERROR_RESPONSE =
{ # Indicate that we couldn't parse the request 400 => "HTTP/1.1 400 Bad Request\r\n\r\n", # 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", # 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", # Indicate that there was an internal error, obviously. 500 => "HTTP/1.1 500 Internal Server Error\r\n\r\n", # Incorrect or invalid header value 501 => "HTTP/1.1 501 Not Implemented\r\n\r\n", # 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
- CHUNK_SIZE =
The basic max request size we'll try to read.
16 * 1024
- MAX_HEADER =
This is the maximum header that is allowed before a client is booted. The parser detects this, but we'd also like to do this as well.
1024 * (80 + 32)
- MAX_BODY =
Maximum request body size before it is moved out of memory and into a tempfile for reading.
MAX_HEADER
- REQUEST_METHOD =
"REQUEST_METHOD"
- HEAD =
"HEAD"
- SUPPORTED_HTTP_METHODS =
%w[HEAD GET POST PUT DELETE OPTIONS TRACE PATCH].freeze
- LINE_END =
ETag is based on the apache standard of hex mtime-size-inode (inode is 0 on win32)
"\r\n"
- REMOTE_ADDR =
"REMOTE_ADDR"
- HTTP_X_FORWARDED_FOR =
"HTTP_X_FORWARDED_FOR"
- HTTP_X_FORWARDED_SSL =
"HTTP_X_FORWARDED_SSL"
- HTTP_X_FORWARDED_SCHEME =
"HTTP_X_FORWARDED_SCHEME"
- HTTP_X_FORWARDED_PROTO =
"HTTP_X_FORWARDED_PROTO"
- SERVER_NAME =
"SERVER_NAME"
- SERVER_PORT =
"SERVER_PORT"
- HTTP_HOST =
"HTTP_HOST"
- PORT_80 =
"80"
- PORT_443 =
"443"
- LOCALHOST =
"localhost"
- LOCALHOST_IPV4 =
"127.0.0.1"
- LOCALHOST_IPV6 =
"::1"
- UNSPECIFIED_IPV4 =
"0.0.0.0"
- UNSPECIFIED_IPV6 =
"::"
- SERVER_PROTOCOL =
"SERVER_PROTOCOL"
- HTTP_11 =
"HTTP/1.1"
- SERVER_SOFTWARE =
"SERVER_SOFTWARE"
- GATEWAY_INTERFACE =
"GATEWAY_INTERFACE"
- CGI_VER =
"CGI/1.2"
- STOP_COMMAND =
"?"
- HALT_COMMAND =
"!"
- RESTART_COMMAND =
"R"
- RACK_INPUT =
"rack.input"
- RACK_URL_SCHEME =
"rack.url_scheme"
- RACK_AFTER_REPLY =
"rack.after_reply"
- PUMA_SOCKET =
"puma.socket"
- PUMA_CONFIG =
"puma.config"
- PUMA_PEERCERT =
"puma.peercert"
- HTTP =
"http"
- HTTPS =
"https"
- HTTPS_KEY =
"HTTPS"
- HTTP_VERSION =
"HTTP_VERSION"
- HTTP_CONNECTION =
"HTTP_CONNECTION"
- HTTP_EXPECT =
"HTTP_EXPECT"
- CONTINUE =
"100-continue"
- HTTP_11_100 =
"HTTP/1.1 100 Continue\r\n\r\n"
- HTTP_11_200 =
"HTTP/1.1 200 OK\r\n"
- HTTP_10_200 =
"HTTP/1.0 200 OK\r\n"
- CLOSE =
"close"
- KEEP_ALIVE =
"keep-alive"
- CONTENT_LENGTH2 =
"content-length"
- CONTENT_LENGTH_S =
"Content-Length: "
- TRANSFER_ENCODING =
"transfer-encoding"
- TRANSFER_ENCODING2 =
"HTTP_TRANSFER_ENCODING"
- CONNECTION_CLOSE =
"Connection: close\r\n"
- CONNECTION_KEEP_ALIVE =
"Connection: Keep-Alive\r\n"
- TRANSFER_ENCODING_CHUNKED =
"Transfer-Encoding: chunked\r\n"
- CLOSE_CHUNKED =
"0\r\n\r\n"
- CHUNKED =
"chunked"
- COLON =
": "
- NEWLINE =
"\n"
- HIJACK_P =
"rack.hijack?"
- HIJACK =
"rack.hijack"
- HIJACK_IO =
"rack.hijack_io"
- EARLY_HINTS =
"rack.early_hints"
- DQUOTE =
Illegal character in the key or value of response header
"\""
- HTTP_HEADER_DELIMITER =
Regexp.escape("(),/:;<=>[email protected][]{}\\").freeze
- ILLEGAL_HEADER_KEY_REGEX =
/[\x00-\x20#{DQUOTE}#{HTTP_HEADER_DELIMITER}]/.freeze
- ILLEGAL_HEADER_VALUE_REGEX =
header values can contain HTAB?
/[\x00-\x08\x0A-\x1F]/.freeze
- BANNED_HEADER_KEY =
Banned keys of response header
/\A(rack\.|status\z)/.freeze
- PROXY_PROTOCOL_V1_REGEX =
/^PROXY (?:TCP4|TCP6|UNKNOWN) ([^\r]+)\r\n/.freeze