[master] d686166ad http: Add missing HTTP response code

Nils Goroll nils.goroll at uplex.de
Mon Oct 5 13:06:06 UTC 2020


commit d686166ad469cad4043ed24328f4377e0d5f71a7
Author: BARON David <david.baron+git at varnish-software.com>
Date:   Thu Oct 1 12:50:18 2020 +0900

    http: Add missing HTTP response code
    
    - Complete the missing HTTP response codes / messages from :
    https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

diff --git a/bin/varnishtest/tests/p00010.vtc b/bin/varnishtest/tests/p00010.vtc
new file mode 100644
index 000000000..1a5a8a25d
--- /dev/null
+++ b/bin/varnishtest/tests/p00010.vtc
@@ -0,0 +1,101 @@
+varnishtest "status codes"
+
+server s1 {} -start
+
+varnish v1 -vcl+backend {
+	import std;
+	sub vcl_recv {
+		return (synth(std.integer(req.http.x-vtc-response-code, 999)));
+	}
+} -start
+
+client c1 {
+	txreq -hdr "x-vtc-response-code: 102"
+	rxresp
+	expect resp.reason == "Processing"
+
+	txreq -hdr "x-vtc-response-code: 103"
+	rxresp
+	expect resp.reason == "Early Hints"
+
+	txreq -hdr "x-vtc-response-code: 207"
+	rxresp
+	expect resp.reason == "Multi-Status"
+
+	txreq -hdr "x-vtc-response-code: 208"
+	rxresp
+	expect resp.reason == "Already Reported"
+
+	txreq -hdr "x-vtc-response-code: 226"
+	rxresp
+	expect resp.reason == "IM Used"
+
+	txreq -hdr "x-vtc-response-code: 308"
+	rxresp
+	expect resp.reason == "Permanent Redirect"
+
+	txreq -hdr "x-vtc-response-code: 421"
+	rxresp
+	expect resp.reason == "Misdirected Request"
+
+	txreq -hdr "x-vtc-response-code: 422"
+	rxresp
+	expect resp.reason == "Unprocessable Entity"
+
+	txreq -hdr "x-vtc-response-code: 423"
+	rxresp
+	expect resp.reason == "Locked"
+
+	txreq -hdr "x-vtc-response-code: 424"
+	rxresp
+	expect resp.reason == "Failed Dependency"
+
+	txreq -hdr "x-vtc-response-code: 425"
+	rxresp
+	expect resp.reason == "Too Early"
+
+	txreq -hdr "x-vtc-response-code: 426"
+	rxresp
+	expect resp.reason == "Upgrade Required"
+
+	txreq -hdr "x-vtc-response-code: 428"
+	rxresp
+	expect resp.reason == "Precondition Required"
+
+	txreq -hdr "x-vtc-response-code: 429"
+	rxresp
+	expect resp.reason == "Too Many Requests"
+
+	txreq -hdr "x-vtc-response-code: 431"
+	rxresp
+	expect resp.reason == "Request Header Fields Too Large"
+	txreq -hdr "x-vtc-response-code: 451"
+	rxresp
+	expect resp.reason == "Unavailable For Legal Reasons"
+	
+	txreq -hdr "x-vtc-response-code: 506"
+	rxresp
+	expect resp.reason == "Variant Also Negotiates"
+
+	txreq -hdr "x-vtc-response-code: 507"
+	rxresp
+	expect resp.reason == "Insufficient Storage"
+
+	txreq -hdr "x-vtc-response-code: 508"
+	rxresp
+	expect resp.reason == "Loop Detected"
+
+	txreq -hdr "x-vtc-response-code: 510"
+	rxresp
+	expect resp.reason == "Not Extended"
+
+	txreq -hdr "x-vtc-response-code: 511"
+	rxresp
+	expect resp.reason == "Network Authentication Required"
+
+	txreq -hdr "x-vtc-response-code: vtc"
+	rxresp
+	expect resp.status == 999
+	expect resp.reason == "Unknown HTTP Status"
+} -run
+
diff --git a/include/tbl/http_response.h b/include/tbl/http_response.h
index 8f2314639..567353968 100644
--- a/include/tbl/http_response.h
+++ b/include/tbl/http_response.h
@@ -34,6 +34,8 @@
 
 HTTP_RESP(100, "Continue")
 HTTP_RESP(101, "Switching Protocols")
+HTTP_RESP(102, "Processing")
+HTTP_RESP(103, "Early Hints")
 HTTP_RESP(200, "OK")
 HTTP_RESP(201, "Created")
 HTTP_RESP(202, "Accepted")
@@ -41,6 +43,9 @@ HTTP_RESP(203, "Non-Authoritative Information")
 HTTP_RESP(204, "No Content")
 HTTP_RESP(205, "Reset Content")
 HTTP_RESP(206, "Partial Content")
+HTTP_RESP(207, "Multi-Status")
+HTTP_RESP(208, "Already Reported")
+HTTP_RESP(226, "IM Used")
 HTTP_RESP(300, "Multiple Choices")
 HTTP_RESP(301, "Moved Permanently")
 HTTP_RESP(302, "Found")
@@ -49,6 +54,7 @@ HTTP_RESP(304, "Not Modified")
 HTTP_RESP(305, "Use Proxy")
 HTTP_RESP(306, "(Unused)")
 HTTP_RESP(307, "Temporary Redirect")
+HTTP_RESP(308, "Permanent Redirect")
 HTTP_RESP(400, "Bad Request")
 HTTP_RESP(401, "Unauthorized")
 HTTP_RESP(402, "Payment Required")
@@ -67,12 +73,27 @@ HTTP_RESP(414, "Request-URI Too Long")
 HTTP_RESP(415, "Unsupported Media Type")
 HTTP_RESP(416, "Requested Range Not Satisfiable")
 HTTP_RESP(417, "Expectation Failed")
+HTTP_RESP(421, "Misdirected Request")
+HTTP_RESP(422, "Unprocessable Entity")
+HTTP_RESP(423, "Locked")
+HTTP_RESP(424, "Failed Dependency")
+HTTP_RESP(425, "Too Early")
+HTTP_RESP(426, "Upgrade Required")
+HTTP_RESP(428, "Precondition Required")
+HTTP_RESP(429, "Too Many Requests")
+HTTP_RESP(431, "Request Header Fields Too Large")
+HTTP_RESP(451, "Unavailable For Legal Reasons")
 HTTP_RESP(500, "Internal Server Error")
 HTTP_RESP(501, "Not Implemented")
 HTTP_RESP(502, "Bad Gateway")
 HTTP_RESP(503, "Service Unavailable")
 HTTP_RESP(504, "Gateway Timeout")
 HTTP_RESP(505, "HTTP Version Not Supported")
+HTTP_RESP(506, "Variant Also Negotiates")
+HTTP_RESP(507, "Insufficient Storage")
+HTTP_RESP(508, "Loop Detected")
+HTTP_RESP(510, "Not Extended")
+HTTP_RESP(511, "Network Authentication Required")
 #undef HTTP_RESP
 
 /*lint -restore */


More information about the varnish-commit mailing list