Module: Puma::Const
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
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
-
BANNED_HEADER_KEY =
Banned keys of response header
/\A(rack\.|status\z)/.freeze
-
CGI_VER =
# File 'lib/puma/const.rb', line 222"CGI/1.2"
-
CHUNKED =
# File 'lib/puma/const.rb', line 264"chunked"
-
CHUNK_SIZE =
The basic max request size we’ll try to read.
64 * 1024
-
CLOSE =
# File 'lib/puma/const.rb', line 250"close"
-
CLOSE_CHUNKED =
# File 'lib/puma/const.rb', line 262"0\r\n\r\n"
-
CODE_NAME =
# File 'lib/puma/const.rb', line 104"Romantic Warrior"
-
COLON =
# File 'lib/puma/const.rb', line 266": "
-
CONNECTION_CLOSE =
# File 'lib/puma/const.rb', line 258"Connection: close\r\n"
-
CONNECTION_KEEP_ALIVE =
# File 'lib/puma/const.rb', line 259"Connection: Keep-Alive\r\n"
-
CONTENT_LENGTH =
# File 'lib/puma/const.rb', line 116"CONTENT_LENGTH"
-
CONTENT_LENGTH2 =
# File 'lib/puma/const.rb', line 253"content-length"
-
CONTENT_LENGTH_S =
# File 'lib/puma/const.rb', line 254"Content-Length: "
-
CONTINUE =
# File 'lib/puma/const.rb', line 244"100-continue"
-
DQUOTE =
Illegal character in the key or value of response header
"\""
-
EARLY_HINTS =
# File 'lib/puma/const.rb', line 274"rack.early_hints"
-
ERROR_RESPONSE =
# File 'lib/puma/const.rb', line 122{ # 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\n\r\n", # The standard empty 408 response for requests that timed out. 408 => "HTTP/1.1 408 Request Timeout\r\nConnection: close\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\n" }.freeze
-
GATEWAY_INTERFACE =
# File 'lib/puma/const.rb', line 221"GATEWAY_INTERFACE"
-
HALT_COMMAND =
# File 'lib/puma/const.rb', line 225"!"
-
HEAD =
# File 'lib/puma/const.rb', line 148"HEAD"
-
HIJACK =
# File 'lib/puma/const.rb', line 271"rack.hijack"
-
HIJACK_IO =
# File 'lib/puma/const.rb', line 272"rack.hijack_io"
-
HIJACK_P =
# File 'lib/puma/const.rb', line 270"rack.hijack?"
-
HTTP =
# File 'lib/puma/const.rb', line 236"http"
-
HTTPS =
# File 'lib/puma/const.rb', line 237"https"
-
HTTPS_KEY =
# File 'lib/puma/const.rb', line 239"HTTPS"
-
HTTP_10_200 =
# File 'lib/puma/const.rb', line 248"HTTP/1.0 200 OK\r\n"
-
HTTP_11 =
# File 'lib/puma/const.rb', line 218"HTTP/1.1"
-
HTTP_11_100 =
# File 'lib/puma/const.rb', line 246"HTTP/1.1 100 Continue\r\n\r\n"
-
HTTP_11_200 =
# File 'lib/puma/const.rb', line 247"HTTP/1.1 200 OK\r\n"
-
HTTP_CONNECTION =
# File 'lib/puma/const.rb', line 242"HTTP_CONNECTION"
-
HTTP_EXPECT =
# File 'lib/puma/const.rb', line 243"HTTP_EXPECT"
-
HTTP_HEADER_DELIMITER =
# File 'lib/puma/const.rb', line 278Regexp.escape("(),/:;<=>?@[]{}\\").freeze
-
HTTP_HOST =
# File 'lib/puma/const.rb', line 208"HTTP_HOST"
-
HTTP_VERSION =
# File 'lib/puma/const.rb', line 241"HTTP_VERSION"
-
HTTP_X_FORWARDED_FOR =
# File 'lib/puma/const.rb', line 201"HTTP_X_FORWARDED_FOR"
-
HTTP_X_FORWARDED_PROTO =
# File 'lib/puma/const.rb', line 204"HTTP_X_FORWARDED_PROTO"
-
HTTP_X_FORWARDED_SCHEME =
# File 'lib/puma/const.rb', line 203"HTTP_X_FORWARDED_SCHEME"
-
HTTP_X_FORWARDED_SSL =
# File 'lib/puma/const.rb', line 202"HTTP_X_FORWARDED_SSL"
-
IANA_HTTP_METHODS =
list from www.iana.org/assignments/http-methods/http-methods.xhtml as of 04-May-23
%w[ ACL BASELINE-CONTROL BIND CHECKIN CHECKOUT CONNECT COPY DELETE GET HEAD LABEL LINK LOCK MERGE MKACTIVITY MKCALENDAR MKCOL MKREDIRECTREF MKWORKSPACE MOVE OPTIONS ORDERPATCH PATCH POST PRI PROPFIND PROPPATCH PUT REBIND REPORT SEARCH TRACE UNBIND UNCHECKOUT UNLINK UNLOCK UPDATE UPDATEREDIRECTREF VERSION-CONTROL ].freeze
-
ILLEGAL_HEADER_KEY_REGEX =
# File 'lib/puma/const.rb', line 279/[\x00-\x20#{DQUOTE}#{HTTP_HEADER_DELIMITER}]/.freeze
-
ILLEGAL_HEADER_VALUE_REGEX =
header values can contain HTAB?
/[\x00-\x08\x0A-\x1F]/.freeze
-
KEEP_ALIVE =
# File 'lib/puma/const.rb', line 251"keep-alive"
-
LINE_END =
ETag is based on the apache standard of hex mtime-size-inode (inode is 0 on win32)
"\r\n"
-
LOCALHOST =
# File 'lib/puma/const.rb', line 211"localhost"
-
LOCALHOST_IPV4 =
# File 'lib/puma/const.rb', line 212"127.0.0.1"
-
LOCALHOST_IPV6 =
# File 'lib/puma/const.rb', line 213"::1"
-
MAX_BODY =
Maximum request body size before it is moved out of memory and into a tempfile for reading.
MAX_HEADER
-
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)
-
NEWLINE =
# File 'lib/puma/const.rb', line 268"\n"
-
PATH_INFO =
# File 'lib/puma/const.rb', line 118"PATH_INFO"
-
PORT_443 =
# File 'lib/puma/const.rb', line 210"443"
-
PORT_80 =
# File 'lib/puma/const.rb', line 209"80"
-
PROXY_PROTOCOL_V1_REGEX =
# File 'lib/puma/const.rb', line 294/^PROXY (?:TCP4|TCP6|UNKNOWN) ([^\r]+)\r\n/.freeze
-
PUMA_CONFIG =
# File 'lib/puma/const.rb', line 233"puma.config"
-
PUMA_PEERCERT =
# File 'lib/puma/const.rb', line 234"puma.peercert"
-
PUMA_SERVER_STRING =
# File 'lib/puma/const.rb', line 106["puma", PUMA_VERSION, CODE_NAME].join(" ").freeze
-
PUMA_SOCKET =
# File 'lib/puma/const.rb', line 232"puma.socket"
-
PUMA_TMP_BASE =
# File 'lib/puma/const.rb', line 120"puma"
-
PUMA_VERSION =
# File 'lib/puma/const.rb', line 103VERSION = "7.0.0.pre1"
-
QUERY_STRING =
# File 'lib/puma/const.rb', line 115"QUERY_STRING"
-
RACK_AFTER_REPLY =
# File 'lib/puma/const.rb', line 230"rack.after_reply"
-
RACK_INPUT =
# File 'lib/puma/const.rb', line 228"rack.input"
-
RACK_RESPONSE_FINISHED =
# File 'lib/puma/const.rb', line 231"rack.response_finished"
-
RACK_URL_SCHEME =
# File 'lib/puma/const.rb', line 229"rack.url_scheme"
-
REMOTE_ADDR =
# File 'lib/puma/const.rb', line 200"REMOTE_ADDR"
-
REQUEST_METHOD =
# File 'lib/puma/const.rb', line 147"REQUEST_METHOD"
-
REQUEST_PATH =
# File 'lib/puma/const.rb', line 114"REQUEST_PATH"
-
REQUEST_URI =
The original URI requested by the client.
"REQUEST_URI"
-
RESTART_COMMAND =
# File 'lib/puma/const.rb', line 226"R"
-
SERVER_NAME =
# File 'lib/puma/const.rb', line 206"SERVER_NAME"
-
SERVER_PORT =
# File 'lib/puma/const.rb', line 207"SERVER_PORT"
-
SERVER_PROTOCOL =
# File 'lib/puma/const.rb', line 217"SERVER_PROTOCOL"
-
SERVER_SOFTWARE =
# File 'lib/puma/const.rb', line 220"SERVER_SOFTWARE"
-
STOP_COMMAND =
# File 'lib/puma/const.rb', line 224"?"
-
SUPPORTED_HTTP_METHODS =
based on www.rfc-editor.org/rfc/rfc9110.html#name-overview, with CONNECT removed, and PATCH added
%w[HEAD GET POST PUT DELETE OPTIONS TRACE PATCH].freeze
-
TRANSFER_ENCODING =
# File 'lib/puma/const.rb', line 255"transfer-encoding"
-
TRANSFER_ENCODING2 =
# File 'lib/puma/const.rb', line 256"HTTP_TRANSFER_ENCODING"
-
TRANSFER_ENCODING_CHUNKED =
# File 'lib/puma/const.rb', line 261"Transfer-Encoding: chunked\r\n"
-
UNMASKABLE_HEADERS =
The keys of headers that should not be convert to underscore normalized versions. These headers are ignored at the request reading layer, but if we normalize them after reading, it’s just confusing for the application.
{ "HTTP_TRANSFER,ENCODING" => true, "HTTP_CONTENT,LENGTH" => true, }
-
UNSPECIFIED_IPV4 =
# File 'lib/puma/const.rb', line 214"0.0.0.0"
-
UNSPECIFIED_IPV6 =
# File 'lib/puma/const.rb', line 215"::"
-
WRITE_TIMEOUT =
How long to wait when getting some write blocking on the socket when sending data back
10