]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP/1.1: Update registered status codes from IANA registry
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 9 Apr 2014 16:53:05 +0000 (09:53 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 9 Apr 2014 16:53:05 +0000 (09:53 -0700)
IETF HTTPbis WG has created an IANA registry for HTTP status codes at
http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

Update our registered codes and strings to match the registry entries.

13 files changed:
src/FwdState.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/errorpage.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/http/StatusCode.cc
src/http/StatusCode.h
src/mgr/Forwarder.cc
src/redirect.cc
src/urn.cc

index 2936ad20ff818d92b18414cc7851bc328a3c5f4a..6c65b3b368748945cfbd12325d15fe63e9c4112d 100644 (file)
@@ -1053,7 +1053,7 @@ FwdState::connectTimeout(int fd)
     assert(fd == serverDestinations[0]->fd);
 
     if (entry->isEmpty()) {
-        ErrorState *anErr = new ErrorState(ERR_CONNECT_FAIL, Http::scGateway_Timeout, request);
+        ErrorState *anErr = new ErrorState(ERR_CONNECT_FAIL, Http::scGatewayTimeout, request);
         anErr->xerrno = ETIMEDOUT;
         fail(anErr);
 
@@ -1384,7 +1384,7 @@ ErrorState *
 FwdState::makeConnectingError(const err_type type) const
 {
     return new ErrorState(type, request->flags.needValidation ?
-                          Http::scGateway_Timeout : Http::scServiceUnavailable, request);
+                          Http::scGatewayTimeout : Http::scServiceUnavailable, request);
 }
 
 static void
@@ -1423,7 +1423,7 @@ FwdState::reforwardableStatus(const Http::StatusCode s) const
 
     case Http::scBadGateway:
 
-    case Http::scGateway_Timeout:
+    case Http::scGatewayTimeout:
         return true;
 
     case Http::scForbidden:
index 817ec4623d27e3434c8152495d0cce530542121f..4f928bd255fe9a3cb308d8bd2e3166b9a453e614 100644 (file)
@@ -2889,7 +2889,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
             assert (repContext);
             conn->quitAfterError(request.getRaw());
             repContext->setReplyToError(ERR_TOO_BIG,
-                                        Http::scRequestEntityTooLarge, Http::METHOD_NONE, NULL,
+                                        Http::scPayloadTooLarge, Http::METHOD_NONE, NULL,
                                         conn->clientConnection->remote, http->request, NULL, NULL);
             assert(context->http->out.offset == 0);
             context->pullData();
@@ -3254,7 +3254,7 @@ ConnStateData::abortChunkedRequestBody(const err_type error)
         clientReplyContext *repContext = dynamic_cast<clientReplyContext*>(node->data.getRaw());
         assert(repContext);
         const Http::StatusCode scode = (error == ERR_TOO_BIG) ?
-                                       Http::scRequestEntityTooLarge : HTTP_BAD_REQUEST;
+                                       Http::scPayloadTooLarge : HTTP_BAD_REQUEST;
         repContext->setReplyToError(error, scode,
                                     repContext->http->request->method,
                                     repContext->http->uri,
index 01da7dc5d8934c43b224f325d408808cf54458eb..bcd7d9118977dff7658f63cee5a50c958a8d8a9b 100644 (file)
@@ -700,8 +700,8 @@ clientReplyContext::processOnlyIfCachedMiss()
 {
     debugs(88, 4, "clientProcessOnlyIfCachedMiss: '" <<
            RequestMethodStr(http->request->method) << " " << http->uri << "'");
-    http->al->http.code = Http::scGateway_Timeout;
-    ErrorState *err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, Http::scGateway_Timeout, NULL,
+    http->al->http.code = Http::scGatewayTimeout;
+    ErrorState *err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, Http::scGatewayTimeout, NULL,
                                        http->getConn()->clientConnection->remote, http->request);
     removeClientStoreReference(&sc, http);
     startError(err);
index 8e9368f9b524fef65f64032aa126fa2c6f2f863f..232130b835e4c96dfedef6091901bd21fe3a737b 100644 (file)
@@ -1273,17 +1273,17 @@ ClientRequestContext::clientRedirectDone(const HelperReply &reply)
 
             // TODO: change default redirect status for appropriate requests
             // Squid defaults to 302 status for now for better compatibility with old clients.
-            // HTTP/1.0 client should get 302 (Http::scMovedTemporarily)
+            // HTTP/1.0 client should get 302 (Http::scFound)
             // HTTP/1.1 client contacting reverse-proxy should get 307 (Http::scTemporaryRedirect)
             // HTTP/1.1 client being diverted by forward-proxy should get 303 (Http::scSeeOther)
-            Http::StatusCode status = Http::scMovedTemporarily;
+            Http::StatusCode status = Http::scFound;
             if (statusNote != NULL) {
                 const char * result = statusNote;
                 status = static_cast<Http::StatusCode>(atoi(result));
             }
 
             if (status == Http::scMovedPermanently
-                    || status == Http::scMovedTemporarily
+                    || status == Http::scFound
                     || status == Http::scSeeOther
                     || status == Http::scPermanentRedirect
                     || status == Http::scTemporaryRedirect) {
index edea909c663960831ead6c96e3d3d0f76a4662bf..8d161e1be6c8fe0b65ab9334b168300c172fc3d5 100644 (file)
@@ -1157,7 +1157,7 @@ ErrorState::BuildHttpReply()
 
     if (name[0] == '3' || (name[0] != '2' && name[0] != '4' && name[0] != '5' && strchr(name, ':'))) {
         /* Redirection */
-        Http::StatusCode status = Http::scMovedTemporarily;
+        Http::StatusCode status = Http::scFound;
         // Use configured 3xx reply status if set.
         if (name[0] == '3')
             status = httpStatus;
index 50df61c3c3881dad4cb5a379a3761b07625e1f61..8d037d319e38bde85b25cfa1e11a6e2ba632787d 100644 (file)
@@ -3510,7 +3510,7 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno)
         break;
 
     case ERR_READ_TIMEOUT:
-        ftperr = new ErrorState(error, Http::scGateway_Timeout, fwd->request);
+        ftperr = new ErrorState(error, Http::scGatewayTimeout, fwd->request);
         break;
 
     default:
index 0d99ff4433fc26b732bee1ba15192fbfaf813d7d..f01f746ee60d3f06e755b950d9af44c4f5478659 100644 (file)
@@ -726,7 +726,7 @@ gopherTimeout(const CommTimeoutCbParams &io)
     GopherStateData *gopherState = static_cast<GopherStateData *>(io.data);
     debugs(10, 4, HERE << io.conn << ": '" << gopherState->entry->url() << "'" );
 
-    gopherState->fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGateway_Timeout, gopherState->fwd->request));
+    gopherState->fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGatewayTimeout, gopherState->fwd->request));
 
     if (Comm::IsConnOpen(io.conn))
         io.conn->close();
index 1d071f57f3b905ea4ed3c99ee2cacf801e2b3a84..0e6eb0c8c6717601237134dceb74469493d82b6e 100644 (file)
@@ -182,7 +182,7 @@ HttpStateData::httpTimeout(const CommTimeoutCbParams &params)
     debugs(11, 4, HERE << serverConnection << ": '" << entry->url() << "'" );
 
     if (entry->store_status == STORE_PENDING) {
-        fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGateway_Timeout, fwd->request));
+        fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGatewayTimeout, fwd->request));
     }
 
     serverConnection->close();
@@ -208,7 +208,7 @@ httpMaybeRemovePublic(StoreEntry * e, Http::StatusCode status)
 
     case Http::scMovedPermanently:
 
-    case Http::scMovedTemporarily:
+    case Http::scFound:
 
     case Http::scGone:
 
@@ -487,7 +487,7 @@ HttpStateData::cacheableReply()
 
         /* Responses that only are cacheable if the server says so */
 
-    case Http::scMovedTemporarily:
+    case Http::scFound:
     case Http::scTemporaryRedirect:
         if (rep->date <= 0) {
             debugs(22, 3, HERE << "NO because HTTP status " << rep->sline.status() << " and Date missing/invalid");
@@ -517,7 +517,7 @@ HttpStateData::cacheableReply()
 
     case Http::scMethodNotAllowed:
 
-    case Http::scRequestUriTooLarge:
+    case Http::scUriTooLong:
 
     case Http::scInternalServerError:
 
@@ -527,8 +527,8 @@ HttpStateData::cacheableReply()
 
     case Http::scServiceUnavailable:
 
-    case Http::scGateway_Timeout:
-        debugs(22, 3, HERE << "MAYBE because HTTP status " << rep->sline.status());
+    case Http::scGatewayTimeout:
+        debugs(22, 3, "MAYBE because HTTP status " << rep->sline.status());
         return -1;
 
         /* NOTREACHED */
@@ -556,7 +556,7 @@ HttpStateData::cacheableReply()
     case Http::scConflict:
     case Http::scLengthRequired:
     case Http::scPreconditionFailed:
-    case Http::scRequestEntityTooLarge:
+    case Http::scPayloadTooLarge:
     case Http::scUnsupportedMediaType:
     case Http::scUnprocessableEntity:
     case Http::scLocked:
index f9e2aa82a6d75462b12468844e63b5e83b7bf12e..4afbcc7e070a6967b8b8080026fb6a2c160c23ec 100644 (file)
@@ -7,10 +7,12 @@ Http::StatusCodeString(const Http::StatusCode status)
 {
     switch (status) {
 
+    // 000
     case Http::scNone:
         return "Init";         /* we init .status with code 0 */
         break;
 
+    // 100-199
     case Http::scContinue:
         return "Continue";
         break;
@@ -19,6 +21,11 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Switching Protocols";
         break;
 
+    case Http::scProcessing:
+        return "Processing";
+        break;
+
+    // 200-299
     case Http::scOkay:
         return "OK";
         break;
@@ -51,6 +58,15 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Multi-Status";
         break;
 
+    case Http::scAlreadyReported:
+        return "Already Reported";
+        break;
+
+    case Http::scImUsed:
+        return "IM Used";
+        break;
+
+    // 300-399
     case Http::scMultipleChoices:
         return "Multiple Choices";
         break;
@@ -59,8 +75,8 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Moved Permanently";
         break;
 
-    case Http::scMovedTemporarily:
-        return "Moved Temporarily";
+    case Http::scFound:
+        return "Found";
         break;
 
     case Http::scSeeOther:
@@ -83,6 +99,7 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Permanent Redirect";
         break;
 
+    // 400-499
     case Http::scBadRequest:
         return "Bad Request";
         break;
@@ -116,7 +133,7 @@ Http::StatusCodeString(const Http::StatusCode status)
         break;
 
     case Http::scRequestTimeout:
-        return "Request Time-out";
+        return "Request Timeout";
         break;
 
     case Http::scConflict:
@@ -135,12 +152,12 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Precondition Failed";
         break;
 
-    case Http::scRequestEntityTooLarge:
-        return "Request Entity Too Large";
+    case Http::scPayloadTooLarge:
+        return "Payload Too Large";
         break;
 
-    case Http::scRequestUriTooLarge:
-        return "Request-URI Too Large";
+    case Http::scUriTooLong:
+        return "URI Too Long";
         break;
 
     case Http::scUnsupportedMediaType:
@@ -155,6 +172,35 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Expectation Failed";
         break;
 
+    case Http::scUnprocessableEntity:
+        return "Unprocessable Entity";
+        break;
+
+    case Http::scLocked:
+        return "Locked";
+        break;
+
+    case Http::scFailedDependency:
+        return "Failed Dependency";
+        break;
+
+    case Http::scUpgradeRequired:
+        return "Upgrade Required";
+        break;
+
+    case Http::scPreconditionRequired:
+        return "Precondition Required";
+        break;
+
+    case Http::scTooManyRequests:
+        return "Too Many Requests";
+        break;
+
+    case Http::scRequestHeaderFieldsTooLarge:
+        return "Request Header Fields Too Large";
+        break;
+
+    // 500-599
     case Http::scInternalServerError:
         return "Internal Server Error";
         break;
@@ -171,33 +217,41 @@ Http::StatusCodeString(const Http::StatusCode status)
         return "Service Unavailable";
         break;
 
-    case Http::scGateway_Timeout:
-        return "Gateway Time-out";
+    case Http::scGatewayTimeout:
+        return "Gateway Timeout";
         break;
 
     case Http::scHttpVersionNotSupported:
         return "HTTP Version not supported";
         break;
 
-        // RFC 6585
-    case Http::scPreconditionRequired: // 428
-        return "Precondition Required";
+    case Http::scVariantAlsoNegotiates:
+        return "Variant Also Negotiates";
         break;
 
-    case Http::scTooManyFields: // 429
-        return "Too Many Requests";
+    case Http::scInsufficientStorage:
+        return "Insufficient Storage";
         break;
 
-    case Http::scRequestHeaderFieldsTooLarge: // 431
-        return "Request Header Fields Too Large";
+    case Http::scLoopDetected:
+        return "Loop Detected";
         break;
 
-    case Http::scNetworkAuthenticationRequired: // 511
+    case Http::scNotExtended:
+        return "Not Extended";
+        break;
+
+    case Http::scNetworkAuthenticationRequired:
         return "Network Authentication Required";
         break;
 
+    // 600+
+    case Http::scInvalidHeader:
+    case Http::scHeaderTooLarge:
+        // fall through to default.
+
     default:
-        debugs(57, 3, "Unknown HTTP status code: " << status);
-        return "Unknown";
+        debugs(57, 3, "Unassigned HTTP status code: " << status);
     }
+    return "Unassigned";
 }
index 6d73844a0d159d6da47d918607834ae24de9c227..904c13e62023aab30ea409f8b2ac3b2f3f07e8df 100644 (file)
@@ -6,6 +6,8 @@ namespace Http
 
 /**
  * These basic HTTP reply status codes are defined by RFC 2616 unless otherwise stated.
+ * The IANA registry for HTTP status codes can be found at:
+ * http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
  */
 typedef enum {
     scNone = 0,
@@ -19,15 +21,17 @@ typedef enum {
     scNoContent = 204,
     scResetContent = 205,
     scPartialContent = 206,
-    scMultiStatus = 207,    /**< RFC2518 section 10.2 */
+    scMultiStatus = 207,     /**< RFC2518 section 10.2 / RFC4918 */
+    scAlreadyReported = 208, /**< RFC5842 */
+    scImUsed = 226,          /**< RFC3229 */
     scMultipleChoices = 300,
     scMovedPermanently = 301,
-    scMovedTemporarily = 302,
+    scFound = 302,
     scSeeOther = 303,
     scNotModified = 304,
     scUseProxy = 305,
     scTemporaryRedirect = 307,
-    scPermanentRedirect = 308,
+    scPermanentRedirect = 308, /**< RFC-reschke-http-status-308-07 */
     scBadRequest = 400,
     scUnauthorized = 401,
     scPaymentRequired = 402,
@@ -41,28 +45,32 @@ typedef enum {
     scGone = 410,
     scLengthRequired = 411,
     scPreconditionFailed = 412,
-    scRequestEntityTooLarge = 413,
-    scRequestUriTooLarge = 414,
+    scPayloadTooLarge = 413,
+    scUriTooLong = 414,
     scUnsupportedMediaType = 415,
     scRequestedRangeNotSatisfied = 416,
     scExpectationFailed = 417,
-    scUnprocessableEntity = 422,    /**< RFC2518 section 10.3 */
-    scLocked = 423,                  /**< RFC2518 section 10.4 */
-    scFailedDependency = 424,       /**< RFC2518 section 10.5 */
+    scUnprocessableEntity = 422,    /**< RFC2518 section 10.3 / RFC4918 */
+    scLocked = 423,                 /**< RFC2518 section 10.4 / RFC4918 */
+    scFailedDependency = 424,       /**< RFC2518 section 10.5 / RFC4918 */
+    scUpgradeRequired = 426,
     scPreconditionRequired = 428,   /**< RFC6585 */
-    scTooManyFields = 429,       /**< RFC6585 */
+    scTooManyRequests = 429,        /**< RFC6585 */
     scRequestHeaderFieldsTooLarge = 431, /**< RFC6585 */
     scInternalServerError = 500,
     scNotImplemented = 501,
     scBadGateway = 502,
     scServiceUnavailable = 503,
-    scGateway_Timeout = 504,
+    scGatewayTimeout = 504,
     scHttpVersionNotSupported = 505,
-    scInsufficientStorage = 507,    /**< RFC2518 section 10.6 */
+    scVariantAlsoNegotiates = 506,  /**< RFC2295 */
+    scInsufficientStorage = 507,    /**< RFC2518 section 10.6 / RFC4918 */
+    scLoopDetected = 508,           /**< RFC5842 */
+    scNotExtended = 510,            /**< RFC2774 */
     scNetworkAuthenticationRequired = 511, /**< RFC6585 */
 
     // The 6xx codes below are for internal use only: Bad requests result
-    // in scBadRequest; bad responses in scGateway_Timeout.
+    // in scBadRequest; bad responses in scGatewayTimeout.
 
     scInvalidHeader = 600,          /**< Squid header parsing error */
     scHeaderTooLarge = 601         /* Header too large to process */
index d7a754dcfd52753cac3e4351fc18850a6bd99537..0c4f96948a815a2298b7e096663badfb32f1cb7a 100644 (file)
@@ -69,7 +69,7 @@ void
 Mgr::Forwarder::handleError()
 {
     debugs(16, DBG_CRITICAL, "ERROR: uri " << entry->url() << " exceeds buffer size");
-    sendError(new ErrorState(ERR_INVALID_URL, Http::scRequestUriTooLarge, httpRequest));
+    sendError(new ErrorState(ERR_INVALID_URL, Http::scUriTooLong, httpRequest));
     mustStop("long URI");
 }
 
index 854422bb7f77b6d5d326a8d98033378f1306d2be..1ddedbb50a97c3a80c2966d2395e09e94362e559 100644 (file)
@@ -124,7 +124,7 @@ redirectHandleReply(void *data, const HelperReply &reply)
                 newReply.notes.append(&reply.notes);
 
                 if (status == Http::scMovedPermanently
-                        || status == Http::scMovedTemporarily
+                        || status == Http::scFound
                         || status == Http::scSeeOther
                         || status == Http::scPermanentRedirect
                         || status == Http::scTemporaryRedirect) {
@@ -289,7 +289,7 @@ constructHelperQuery(const char *name, helper *hlp, HLPCB *replyHandler, ClientH
             status = Http::scInternalServerError;
             debugs(61, DBG_CRITICAL, "ERROR: Gateway Failure. Can not build request to be passed to " << name << ". Request ABORTED.");
         } else {
-            status = Http::scRequestUriTooLarge;
+            status = Http::scUriTooLong;
             debugs(61, DBG_CRITICAL, "ERROR: Gateway Failure. Request passed to " << name << " exceeds MAX_REDIRECTOR_REQUEST_STRLEN (" << MAX_REDIRECTOR_REQUEST_STRLEN << "). Request ABORTED.");
         }
 
index 59e61d4a528fa3f992f4111b1cc74abaa85a0f6c..04075a8c136e9cf4372b96812ae85a5f0d38e7e8 100644 (file)
@@ -419,7 +419,7 @@ urnHandleReply(void *data, StoreIOBuffer result)
         "</ADDRESS>\n",
         APP_FULLNAME, getMyHostname());
     rep = new HttpReply;
-    rep->setHeaders(Http::scMovedTemporarily, NULL, "text/html", mb->contentSize(), 0, squid_curtime);
+    rep->setHeaders(Http::scFound, NULL, "text/html", mb->contentSize(), 0, squid_curtime);
 
     if (urnState->flags.force_menu) {
         debugs(51, 3, "urnHandleReply: forcing menu");