From: Amos Jeffries Date: Wed, 9 Apr 2014 16:53:05 +0000 (-0700) Subject: HTTP/1.1: Update registered status codes from IANA registry X-Git-Tag: SQUID_3_4_4_1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c30213429752b2293dbb924c48f2bff479316485;p=thirdparty%2Fsquid.git HTTP/1.1: Update registered status codes from IANA registry 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. --- diff --git a/src/FwdState.cc b/src/FwdState.cc index 2936ad20ff..6c65b3b368 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -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: diff --git a/src/client_side.cc b/src/client_side.cc index 817ec4623d..4f928bd255 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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(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, diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 01da7dc5d8..bcd7d91189 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 8e9368f9b5..232130b835 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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(atoi(result)); } if (status == Http::scMovedPermanently - || status == Http::scMovedTemporarily + || status == Http::scFound || status == Http::scSeeOther || status == Http::scPermanentRedirect || status == Http::scTemporaryRedirect) { diff --git a/src/errorpage.cc b/src/errorpage.cc index edea909c66..8d161e1be6 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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; diff --git a/src/ftp.cc b/src/ftp.cc index 50df61c3c3..8d037d319e 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -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: diff --git a/src/gopher.cc b/src/gopher.cc index 0d99ff4433..f01f746ee6 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -726,7 +726,7 @@ gopherTimeout(const CommTimeoutCbParams &io) GopherStateData *gopherState = static_cast(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(); diff --git a/src/http.cc b/src/http.cc index 1d071f57f3..0e6eb0c8c6 100644 --- a/src/http.cc +++ b/src/http.cc @@ -182,7 +182,7 @@ HttpStateData::httpTimeout(const CommTimeoutCbParams ¶ms) 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: diff --git a/src/http/StatusCode.cc b/src/http/StatusCode.cc index f9e2aa82a6..4afbcc7e07 100644 --- a/src/http/StatusCode.cc +++ b/src/http/StatusCode.cc @@ -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"; } diff --git a/src/http/StatusCode.h b/src/http/StatusCode.h index 6d73844a0d..904c13e620 100644 --- a/src/http/StatusCode.h +++ b/src/http/StatusCode.h @@ -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 */ diff --git a/src/mgr/Forwarder.cc b/src/mgr/Forwarder.cc index d7a754dcfd..0c4f96948a 100644 --- a/src/mgr/Forwarder.cc +++ b/src/mgr/Forwarder.cc @@ -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"); } diff --git a/src/redirect.cc b/src/redirect.cc index 854422bb7f..1ddedbb50a 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -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."); } diff --git a/src/urn.cc b/src/urn.cc index 59e61d4a52..04075a8c13 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -419,7 +419,7 @@ urnHandleReply(void *data, StoreIOBuffer result) "\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");