]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
HTTP/1.1: Update registered status codes from IANA registry
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 31 Mar 2014 06:57:27 +0000 (23:57 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 31 Mar 2014 06:57:27 +0000 (23:57 -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 38d3270834bd0c793e2077d421d619b9c325de31..8392b3ab51ce29ba7abb4c7c2fd8ea9e0eb11120 100644 (file)
@@ -1054,7 +1054,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);
 
@@ -1385,7 +1385,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
@@ -1424,7 +1424,7 @@ FwdState::reforwardableStatus(const Http::StatusCode s) const
 
     case Http::scBadGateway:
 
-    case Http::scGateway_Timeout:
+    case Http::scGatewayTimeout:
         return true;
 
     case Http::scForbidden:
index 3975b748ca6523da8bcb25e30ef272d9d5683339..5fa28947642d6e1fab493080093c7c0d04da5365 100644 (file)
@@ -2837,7 +2837,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();
@@ -3191,7 +3191,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 a0ab9d9fd5ebb2ed17272b7354b484f0023b6a8d..9716c0368b67d326fea30628c3a2365071de075f 100644 (file)
@@ -710,8 +710,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 48400d7bb61bd7d11c585c0efddae2c8bfb100c9..22b41862f8dc628ab204ec45f59489043b408315 100644 (file)
@@ -1279,17 +1279,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 1630f9e8fa91f5a172da60ed768bc341b50697d6..8f728070787bc28f7b3a7144a0e3e9589e374c74 100644 (file)
@@ -1156,7 +1156,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 9901ffc2481d690d9b9bd153adb918a7af50919b..9f1fd39e3a6fdd829bc6b9cf225770977fe0ae25 100644 (file)
@@ -3509,7 +3509,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 eb7054187c8d9ee370365ee9a112fd72ad8f826d..8a467737fbc53590dad564cfea9f09a6f28e9b2a 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 f79f6bdb5ff36accc1c70cb20c349b0d88cdefef..76b2b068179256f73cfeed512790927d21dc80eb 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();
@@ -212,7 +212,7 @@ httpMaybeRemovePublic(StoreEntry * e, Http::StatusCode status)
 
     case Http::scMovedPermanently:
 
-    case Http::scMovedTemporarily:
+    case Http::scFound:
 
     case Http::scGone:
 
@@ -496,7 +496,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");
@@ -526,7 +526,7 @@ HttpStateData::cacheableReply()
 
     case Http::scMethodNotAllowed:
 
-    case Http::scRequestUriTooLarge:
+    case Http::scUriTooLong:
 
     case Http::scInternalServerError:
 
@@ -536,8 +536,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 */
@@ -565,7 +565,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 c0244b380633452d51d8e02e61c1d7ea7742b82e..e114efb003ab22769cf9862cd8a62e881855219a 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 1b2f698ce326ca0324a04f4581577991f332cd06..770a8af2ae9400448d955d9a6e782742e69bd6a8 100644 (file)
@@ -143,7 +143,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) {
@@ -257,7 +257,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 b907d7ca37c8380065c0b335760b690073c4a75f..248352354e103869476040d4548cf189605da158 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");