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 =
# File 'lib/puma/const.rb', line 294
Banned keys of response header
/\A(rack\.|status\z)/.freeze
-
CGI_VER =
# File 'lib/puma/const.rb', line 223"CGI/1.2" -
CHUNKED =
# File 'lib/puma/const.rb', line 266"chunked" -
CHUNK_SIZE =
# File 'lib/puma/const.rb', line 138
The basic max request size we'll try to read.
64 * 1024
-
CLOSE =
# File 'lib/puma/const.rb', line 252"close" -
CLOSE_CHUNKED =
# File 'lib/puma/const.rb', line 264"0\r\n\r\n" -
CODE_NAME =
# File 'lib/puma/const.rb', line 104"Into the Arena" -
COLON =
# File 'lib/puma/const.rb', line 268": " -
CONNECTION_CLOSE =
# File 'lib/puma/const.rb', line 260"connection: close\r\n" -
CONNECTION_KEEP_ALIVE =
# File 'lib/puma/const.rb', line 261"connection: keep-alive\r\n" -
CONTENT_LENGTH =
# File 'lib/puma/const.rb', line 116"CONTENT_LENGTH" -
CONTENT_LENGTH2 =
# File 'lib/puma/const.rb', line 255"content-length" -
CONTENT_LENGTH_S =
# File 'lib/puma/const.rb', line 256"content-length: " -
CONTINUE =
# File 'lib/puma/const.rb', line 246"100-continue" -
DQUOTE =
# File 'lib/puma/const.rb', line 279
Illegal character in the key or value of response header
"\"" -
EARLY_HINTS =
# File 'lib/puma/const.rb', line 276"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 222"GATEWAY_INTERFACE" -
HALT_COMMAND =
# File 'lib/puma/const.rb', line 226"!" -
HEAD =
# File 'lib/puma/const.rb', line 148"HEAD" -
HIJACK =
# File 'lib/puma/const.rb', line 273"rack.hijack" -
HIJACK_IO =
# File 'lib/puma/const.rb', line 274"rack.hijack_io" -
HIJACK_P =
# File 'lib/puma/const.rb', line 272"rack.hijack?" -
HTTP =
# File 'lib/puma/const.rb', line 238"http" -
HTTPS =
# File 'lib/puma/const.rb', line 239"https" -
HTTPS_KEY =
# File 'lib/puma/const.rb', line 241"HTTPS" -
HTTP_10_200 =
# File 'lib/puma/const.rb', line 250"HTTP/1.0 200 OK\r\n" -
HTTP_11 =
# File 'lib/puma/const.rb', line 219"HTTP/1.1" -
HTTP_11_100 =
# File 'lib/puma/const.rb', line 248"HTTP/1.1 100 Continue\r\n\r\n" -
HTTP_11_200 =
# File 'lib/puma/const.rb', line 249"HTTP/1.1 200 OK\r\n" -
HTTP_CONNECTION =
# File 'lib/puma/const.rb', line 244"HTTP_CONNECTION" -
HTTP_EXPECT =
# File 'lib/puma/const.rb', line 245"HTTP_EXPECT" -
HTTP_HEADER_DELIMITER =
# File 'lib/puma/const.rb', line 280Regexp.escape("(),/:;<=>?@[]{}\\").freeze
-
HTTP_HOST =
# File 'lib/puma/const.rb', line 209"HTTP_HOST" -
HTTP_VERSION =
# File 'lib/puma/const.rb', line 243"HTTP_VERSION" -
HTTP_X_FORWARDED_FOR =
# File 'lib/puma/const.rb', line 202"HTTP_X_FORWARDED_FOR" -
HTTP_X_FORWARDED_PROTO =
# File 'lib/puma/const.rb', line 205"HTTP_X_FORWARDED_PROTO" -
HTTP_X_FORWARDED_SCHEME =
# File 'lib/puma/const.rb', line 204"HTTP_X_FORWARDED_SCHEME" -
HTTP_X_FORWARDED_SSL =
# File 'lib/puma/const.rb', line 203"HTTP_X_FORWARDED_SSL" -
IANA_HTTP_METHODS =
# File 'lib/puma/const.rb', line 156
list from https://www.iana.org/assignments/http-methods/http-methods.xhtml as of 17-Jun-26, with QUERY added based on https://www.rfc-editor.org/rfc/rfc10008.html
%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 QUERY REBIND REPORT SEARCH TRACE UNBIND UNCHECKOUT UNLINK UNLOCK UPDATE UPDATEREDIRECTREF VERSION-CONTROL ].freeze
-
ILLEGAL_HEADER_KEY_REGEX =
# File 'lib/puma/const.rb', line 281/[\x00-\x20#{DQUOTE}#{HTTP_HEADER_DELIMITER}]/.freeze
-
ILLEGAL_HEADER_VALUE_REGEX =
# File 'lib/puma/const.rb', line 283
header values can contain HTAB?
/[\x00-\x08\x0A-\x1F]/.freeze
-
KEEP_ALIVE =
# File 'lib/puma/const.rb', line 253"keep-alive" -
LINE_END =
# File 'lib/puma/const.rb', line 200
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 212"localhost" -
LOCALHOST_IPV4 =
# File 'lib/puma/const.rb', line 213"127.0.0.1" -
LOCALHOST_IPV6 =
# File 'lib/puma/const.rb', line 214"::1" -
MAX_BODY =
# File 'lib/puma/const.rb', line 145
Maximum request body size before it is moved out of memory and into a tempfile for reading.
MAX_HEADER -
MAX_HEADER =
# File 'lib/puma/const.rb', line 142
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 270"\n" -
PATH_INFO =
# File 'lib/puma/const.rb', line 118"PATH_INFO" -
PORT_443 =
# File 'lib/puma/const.rb', line 211"443" -
PORT_80 =
# File 'lib/puma/const.rb', line 210"80" -
PROXY_PROTOCOL_V1_MAX_LENGTH =
# File 'lib/puma/const.rb', line 297107 -
PROXY_PROTOCOL_V1_REGEX =
# File 'lib/puma/const.rb', line 296/\APROXY (?:TCP4|TCP6|UNKNOWN) ([^\r]+)\r\n/.freeze
-
PUMA_CONFIG =
# File 'lib/puma/const.rb', line 234"puma.config" -
PUMA_PEERCERT =
# File 'lib/puma/const.rb', line 235"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 233"puma.socket" -
PUMA_TMP_BASE =
# File 'lib/puma/const.rb', line 120"puma" -
PUMA_UNDERSCORE_HEADERS =
# File 'lib/puma/const.rb', line 236"puma.underscore_headers" -
PUMA_VERSION =
# File 'lib/puma/const.rb', line 103VERSION = "8.0.2"
-
QUERY_STRING =
# File 'lib/puma/const.rb', line 115"QUERY_STRING" -
RACK_AFTER_REPLY =
# File 'lib/puma/const.rb', line 231"rack.after_reply" -
RACK_INPUT =
# File 'lib/puma/const.rb', line 229"rack.input" -
RACK_RESPONSE_FINISHED =
# File 'lib/puma/const.rb', line 232"rack.response_finished" -
RACK_URL_SCHEME =
# File 'lib/puma/const.rb', line 230"rack.url_scheme" -
REMOTE_ADDR =
# File 'lib/puma/const.rb', line 201"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 =
# File 'lib/puma/const.rb', line 113
The original URI requested by the client.
"REQUEST_URI" -
RESTART_COMMAND =
# File 'lib/puma/const.rb', line 227"R" -
SERVER_NAME =
# File 'lib/puma/const.rb', line 207"SERVER_NAME" -
SERVER_PORT =
# File 'lib/puma/const.rb', line 208"SERVER_PORT" -
SERVER_PROTOCOL =
# File 'lib/puma/const.rb', line 218"SERVER_PROTOCOL" -
SERVER_SOFTWARE =
# File 'lib/puma/const.rb', line 221"SERVER_SOFTWARE" -
STOP_COMMAND =
# File 'lib/puma/const.rb', line 225"?" -
SUPPORTED_HTTP_METHODS =
# File 'lib/puma/const.rb', line 152
based on https://www.rfc-editor.org/rfc/rfc9110.html#name-overview and https://www.rfc-editor.org/rfc/rfc10008.html, with CONNECT removed, and PATCH & QUERY added
%w[HEAD GET POST PUT DELETE OPTIONS TRACE PATCH QUERY].freeze
-
TRANSFER_ENCODING =
# File 'lib/puma/const.rb', line 257"transfer-encoding" -
TRANSFER_ENCODING2 =
# File 'lib/puma/const.rb', line 258"HTTP_TRANSFER_ENCODING" -
TRANSFER_ENCODING_CHUNKED =
# File 'lib/puma/const.rb', line 263"transfer-encoding: chunked\r\n" -
UNMASKABLE_HEADERS =
# File 'lib/puma/const.rb', line 288
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 215"0.0.0.0" -
UNSPECIFIED_IPV6 =
# File 'lib/puma/const.rb', line 216"::" -
WRITE_TIMEOUT =
# File 'lib/puma/const.rb', line 110
How long to wait when getting some write blocking on the socket when sending data back
10