summaryrefslogtreecommitdiff
path: root/SPEC.rdoc
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-04-29 16:00:29 -0700
committerGitHub <noreply@github.com>2022-04-30 11:00:29 +1200
commitcaed8085851de822359f56e949c58f3ef78c16fe (patch)
treea6456f85d086b31c637ab688b950bbb9097efdfb /SPEC.rdoc
parent53458855fbbec1a08503aa6efac80643c627da85 (diff)
downloadrack-caed8085851de822359f56e949c58f3ef78c16fe.tar.gz
Add SERVER_PROTOCOL to SPEC (#1883)
SPEC currently does not currently specify a way to get the HTTP version in use. However, both Chunked and CommonLogger need access to the http version for correct functioning, and other users in the rack ecosystem need it as well (Roda needs it, and I've just identified a need for it in rack-test). Unicorn, Webrick, and Puma all currently set SERVER_PROTOCOL. However, Puma currently sets SERVER_PROTOCOL statically to HTTP/1.1, unlike Unicorn and Webrick, which set it to the protocol used by the client. Unicorn and Puma set HTTP_VERSION to the protocol used by the client. This specifies that SERVER_PROTOCOL should match the protocol used by the client, that it should be a valid protocol matching HTTP/\d(\.\d)?, and that if HTTP_VERSION is provided, it must match SERVER_PROTOCOL. This will require minor changes to Puma to be compliant with the new SPEC. Set SERVER_PROTOCOL to HTTP/1.1 by default in Rack::MockRequest, allowing it to be set by the :http_version option. Update CommonLogger specs to include the version. This removes a spec in Chunked for usage without SERVER_PROTOCOL. A comment in the removed lines indicate unicorn will not set SERVER_PROTOCOL for HTTP/0.9 requests, but that is incorrect, as unicorn has set SERVER_PROTOCOL to HTTP/0.9 since 2009 (see unicorn commit bd0599c4ac91d95cae1f34df3ae99c92f3225391). The related comment was correct when added in 2009 (rack commit 895beec0622d3cafdc5fbae20d665c6d5f6c8e7c), but has been incorrect since the code was changed from HTTP_VERSION to SERVER_PROTOCOL in 2015 (rack commit e702d31335c1a820e99c3acdd9d3368ac25da010).
Diffstat (limited to 'SPEC.rdoc')
-rw-r--r--SPEC.rdoc4
1 files changed, 4 insertions, 0 deletions
diff --git a/SPEC.rdoc b/SPEC.rdoc
index 5d89e09f..0739f534 100644
--- a/SPEC.rdoc
+++ b/SPEC.rdoc
@@ -58,6 +58,8 @@ below.
<tt>SERVER_PORT</tt>:: An optional +Integer+ which is the port the
server is running on. Should be specified if
the server is running on a non-standard port.
+<tt>SERVER_PROTOCOL</tt>:: A string representing the HTTP version used
+ for the request.
<tt>HTTP_</tt> Variables:: Variables corresponding to the
client-supplied HTTP request
headers (i.e., variables whose
@@ -117,6 +119,8 @@ accepted specifications and must not be used otherwise.
The <tt>SERVER_PORT</tt> must be an Integer if set.
The <tt>SERVER_NAME</tt> must be a valid authority as defined by RFC7540.
The <tt>HTTP_HOST</tt> must be a valid authority as defined by RFC7540.
+The <tt>SERVER_PROTOCOL</tt> must match the regexp <tt>HTTP/\d(\.\d)?</tt>.
+If the <tt>HTTP_VERSION</tt> is present, it must equal the <tt>SERVER_PROTOCOL</tt>.
The environment must not contain the keys
<tt>HTTP_CONTENT_TYPE</tt> or <tt>HTTP_CONTENT_LENGTH</tt>
(use the versions without <tt>HTTP_</tt>).