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 224"CGI/1.2"
-
CHUNKED =
# File 'lib/puma/const.rb', line 265"chunked"
-
CHUNK_SIZE =
The basic max request size we’ll try to read.
64 * 1024
-
CLOSE =
# File 'lib/puma/const.rb', line 251"close"
-
CLOSE_CHUNKED =
# File 'lib/puma/const.rb', line 263"0\r\n\r\n"
-
CODE_NAME =
# File 'lib/puma/const.rb', line 104"Sky's Version"
-
COLON =
# File 'lib/puma/const.rb', line 267": "
-
CONNECTION_CLOSE =
# File 'lib/puma/const.rb', line 259"Connection: close\r\n"
-
CONNECTION_KEEP_ALIVE =
# File 'lib/puma/const.rb', line 260"Connection: Keep-Alive\r\n"
-
CONTENT_LENGTH =
# File 'lib/puma/const.rb', line 118"CONTENT_LENGTH"
-
CONTENT_LENGTH2 =
# File 'lib/puma/const.rb', line 254"content-length"
-
CONTENT_LENGTH_S =
# File 'lib/puma/const.rb', line 255"Content-Length: "
-
CONTINUE =
# File 'lib/puma/const.rb', line 245"100-continue"
-
DQUOTE =
Illegal character in the key or value of response header
"\""
-
EARLY_HINTS =
# File 'lib/puma/const.rb', line 275"rack.early_hints"
-
ERROR_RESPONSE =
# File 'lib/puma/const.rb', line 124{ # 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
-
FAST_TRACK_KA_TIMEOUT =
# File 'lib/puma/const.rb', line 1080.2
-
GATEWAY_INTERFACE =
# File 'lib/puma/const.rb', line 223"GATEWAY_INTERFACE"
-
HALT_COMMAND =
# File 'lib/puma/const.rb', line 227"!"
-
HEAD =
# File 'lib/puma/const.rb', line 150"HEAD"
-
HIJACK =
# File 'lib/puma/const.rb', line 272"rack.hijack"
-
HIJACK_IO =
# File 'lib/puma/const.rb', line 273"rack.hijack_io"
-
HIJACK_P =
# File 'lib/puma/const.rb', line 271"rack.hijack?"
-
HTTP =
# File 'lib/puma/const.rb', line 237"http"
-
HTTPS =
# File 'lib/puma/const.rb', line 238"https"
-
HTTPS_KEY =
# File 'lib/puma/const.rb', line 240"HTTPS"
-
HTTP_10_200 =
# File 'lib/puma/const.rb', line 249"HTTP/1.0 200 OK\r\n"
-
HTTP_11 =
# File 'lib/puma/const.rb', line 220"HTTP/1.1"
-
HTTP_11_100 =
# File 'lib/puma/const.rb', line 247"HTTP/1.1 100 Continue\r\n\r\n"
-
HTTP_11_200 =
# File 'lib/puma/const.rb', line 248"HTTP/1.1 200 OK\r\n"
-
HTTP_CONNECTION =
# File 'lib/puma/const.rb', line 243"HTTP_CONNECTION"
-
HTTP_EXPECT =
# File 'lib/puma/const.rb', line 244"HTTP_EXPECT"
-
HTTP_HEADER_DELIMITER =
# File 'lib/puma/const.rb', line 279Regexp.escape("(),/:;<=>?@[]{}\\").freeze
-
HTTP_HOST =
# File 'lib/puma/const.rb', line 210"HTTP_HOST"
-
HTTP_VERSION =
# File 'lib/puma/const.rb', line 242"HTTP_VERSION"
-
HTTP_X_FORWARDED_FOR =
# File 'lib/puma/const.rb', line 203"HTTP_X_FORWARDED_FOR"
-
HTTP_X_FORWARDED_PROTO =
# File 'lib/puma/const.rb', line 206"HTTP_X_FORWARDED_PROTO"
-
HTTP_X_FORWARDED_SCHEME =
# File 'lib/puma/const.rb', line 205"HTTP_X_FORWARDED_SCHEME"
-
HTTP_X_FORWARDED_SSL =
# File 'lib/puma/const.rb', line 204"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 280/[\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 252"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 213"localhost"
-
LOCALHOST_IPV4 =
# File 'lib/puma/const.rb', line 214"127.0.0.1"
-
LOCALHOST_IPV6 =
# File 'lib/puma/const.rb', line 215"::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 269"\n"
-
PATH_INFO =
# File 'lib/puma/const.rb', line 120"PATH_INFO"
-
PORT_443 =
# File 'lib/puma/const.rb', line 212"443"
-
PORT_80 =
# File 'lib/puma/const.rb', line 211"80"
-
PROXY_PROTOCOL_V1_REGEX =
# File 'lib/puma/const.rb', line 295/^PROXY (?: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 122"puma"
-
PUMA_VERSION =
# File 'lib/puma/const.rb', line 103VERSION = "6.5.0"
-
QUERY_STRING =
# File 'lib/puma/const.rb', line 117"QUERY_STRING"
-
RACK_AFTER_REPLY =
# File 'lib/puma/const.rb', line 232"rack.after_reply"
-
RACK_INPUT =
# File 'lib/puma/const.rb', line 230"rack.input"
-
RACK_URL_SCHEME =
# File 'lib/puma/const.rb', line 231"rack.url_scheme"
-
REMOTE_ADDR =
# File 'lib/puma/const.rb', line 202"REMOTE_ADDR"
-
REQUEST_METHOD =
# File 'lib/puma/const.rb', line 149"REQUEST_METHOD"
-
REQUEST_PATH =
# File 'lib/puma/const.rb', line 116"REQUEST_PATH"
-
REQUEST_URI =
The original URI requested by the client.
"REQUEST_URI"
-
RESTART_COMMAND =
# File 'lib/puma/const.rb', line 228"R"
-
SERVER_NAME =
# File 'lib/puma/const.rb', line 208"SERVER_NAME"
-
SERVER_PORT =
# File 'lib/puma/const.rb', line 209"SERVER_PORT"
-
SERVER_PROTOCOL =
# File 'lib/puma/const.rb', line 219"SERVER_PROTOCOL"
-
SERVER_SOFTWARE =
# File 'lib/puma/const.rb', line 222"SERVER_SOFTWARE"
-
STOP_COMMAND =
# File 'lib/puma/const.rb', line 226"?"
-
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 256"transfer-encoding"
-
TRANSFER_ENCODING2 =
# File 'lib/puma/const.rb', line 257"HTTP_TRANSFER_ENCODING"
-
TRANSFER_ENCODING_CHUNKED =
# File 'lib/puma/const.rb', line 262"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 216"0.0.0.0"
-
UNSPECIFIED_IPV6 =
# File 'lib/puma/const.rb', line 217"::"
-
WRITE_TIMEOUT =
How long to wait when getting some write blocking on the socket when sending data back
10