]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/http/StatusCode.cc
Mimic GET reforwarding decisions when our CONNECT fails (#1168)
[thirdparty/squid.git] / src / http / StatusCode.cc
index 4afbcc7e070a6967b8b8080026fb6a2c160c23ec..24fb2942340262a6bb287ae8a87f104eb28b0c42 100644 (file)
@@ -1,6 +1,15 @@
+/*
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
 #include "squid.h"
-#include "Debug.h"
+#include "debug/Stream.h"
 #include "http/StatusCode.h"
+#include "SquidConfig.h"
 
 const char *
 Http::StatusCodeString(const Http::StatusCode status)
@@ -9,7 +18,7 @@ Http::StatusCodeString(const Http::StatusCode status)
 
     // 000
     case Http::scNone:
-        return "Init";         /* we init .status with code 0 */
+        return "Init";      /* we init .status with code 0 */
         break;
 
     // 100-199
@@ -25,6 +34,10 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Processing";
         break;
 
+    case Http::scEarlyHints: // 103
+        return "Early Hints";
+        break;
+
     // 200-299
     case Http::scOkay:
         return "OK";
@@ -152,8 +165,8 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Precondition Failed";
         break;
 
-    case Http::scPayloadTooLarge:
-        return "Payload Too Large";
+    case Http::scContentTooLarge:
+        return "Content Too Large";
         break;
 
     case Http::scUriTooLong:
@@ -172,6 +185,10 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Expectation Failed";
         break;
 
+    case Http::scMisdirectedRequest:
+        return "Misdirected Request";
+        break;
+
     case Http::scUnprocessableEntity:
         return "Unprocessable Entity";
         break;
@@ -200,6 +217,10 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Request Header Fields Too Large";
         break;
 
+    case scUnavailableForLegalReasons:
+        return "Unavailable For Legal Reasons";
+        break;
+
     // 500-599
     case Http::scInternalServerError:
         return "Internal Server Error";
@@ -248,10 +269,33 @@ Http::StatusCodeString(const Http::StatusCode status)
     // 600+
     case Http::scInvalidHeader:
     case Http::scHeaderTooLarge:
-        // fall through to default.
+    // fall through to default.
 
     default:
         debugs(57, 3, "Unassigned HTTP status code: " << status);
     }
     return "Unassigned";
 }
+
+bool
+Http::IsReforwardableStatus(const StatusCode s)
+{
+    switch (s) {
+
+    case scBadGateway:
+    case scGatewayTimeout:
+        return true;
+
+    case scForbidden:
+    case scInternalServerError:
+    case scNotImplemented:
+    case scServiceUnavailable:
+        return Config.retry.onerror;
+
+    default:
+        return false;
+    }
+
+    /* NOTREACHED */
+}
+