From: Amos Jeffries Date: Sat, 16 Mar 2013 04:57:43 +0000 (-0600) Subject: SourceLayout: shuffle StatusCode.h to http/StatusCode.h X-Git-Tag: SQUID_3_4_0_1~237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=955394ce0309edaf9b94ffb8e0cfa7a87d38eb26;p=thirdparty%2Fsquid.git SourceLayout: shuffle StatusCode.h to http/StatusCode.h * rename of http_status to Http::StatusCode * rename all enum values to scReason in camelCase --- diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index 2c0c807c5b..bea75087d0 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -246,7 +246,7 @@ public: IcapLogEntry() : reqMethod(Adaptation::methodNone), bytesSent(0), bytesRead(0), bodyBytesRead(-1), request(NULL), reply(NULL), outcome(Adaptation::Icap::xoUnknown), trTime(0), - ioTime(0), resStatus(HTTP_STATUS_NONE), processingTime(0) {} + ioTime(0), resStatus(Http::scNone), processingTime(0) {} Ip::Address hostAddr; ///< ICAP server IP address String serviceName; ///< ICAP service name @@ -274,7 +274,7 @@ public: * ICAP response is received. */ int ioTime; - http_status resStatus; ///< ICAP response status code + Http::StatusCode resStatus; ///< ICAP response status code int processingTime; ///< total ICAP processing time in milliseconds } icap; diff --git a/src/HierarchyLogEntry.h b/src/HierarchyLogEntry.h index e4fd9f8dd0..de2614ee3b 100644 --- a/src/HierarchyLogEntry.h +++ b/src/HierarchyLogEntry.h @@ -33,15 +33,13 @@ #define SQUID_HTTPHIERARCHYLOGENTRY_H #include "comm/Connection.h" +#include "enums.h" #include "hier_code.h" -#include "HttpStatusCode.h" +#include "http/StatusCode.h" #include "lookup_t.h" #include "rfc2181.h" #include "PingData.h" -/* for http_status */ -#include "enums.h" - class HierarchyLogEntry { @@ -66,7 +64,7 @@ public: struct timeval store_complete_stop; - http_status peer_reply_status; ///< last HTTP status code received + Http::StatusCode peer_reply_status; ///< last HTTP status code received timeval peer_http_request_sent; ///< last peer finished writing req int64_t peer_response_time; ///< last peer response delay timeval first_conn_start; ///< first connection use among all peers diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index f5b4e464ad..33aae9461b 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -140,13 +140,14 @@ httpMsgIsolateStart(const char **parse_start, const char **blk_start, const char return 1; } -// negative return is the negated HTTP_ error code +// negative return is the negated Http::StatusCode error code // zero return means need more data // positive return is the size of parsed headers -bool HttpMsg::parse(MemBuf *buf, bool eof, http_status *error) +bool +HttpMsg::parse(MemBuf *buf, bool eof, Http::StatusCode *error) { assert(error); - *error = HTTP_STATUS_NONE; + *error = Http::scNone; // httpMsgParseStep() and debugging require 0-termination, unfortunately buf->terminate(); // does not affect content size @@ -158,8 +159,8 @@ bool HttpMsg::parse(MemBuf *buf, bool eof, http_status *error) if (!sanityCheckStartLine(buf, hdr_len, error)) { // NP: sanityCheck sets *error and sends debug warnings on syntax errors. // if we have seen the connection close, this is an error too - if (eof && *error==HTTP_STATUS_NONE) - *error = HTTP_INVALID_HEADER; + if (eof && *error == Http::scNone) + *error = Http::scInvalidHeader; return false; } @@ -167,7 +168,7 @@ bool HttpMsg::parse(MemBuf *buf, bool eof, http_status *error) // TODO: move to httpReplyParseStep() if (hdr_len > Config.maxReplyHeaderSize || (hdr_len <= 0 && (size_t)buf->contentSize() > Config.maxReplyHeaderSize)) { debugs(58, DBG_IMPORTANT, "HttpMsg::parse: Too large reply header (" << hdr_len << " > " << Config.maxReplyHeaderSize); - *error = HTTP_HEADER_TOO_LARGE; + *error = Http::scHeaderTooLarge; return false; } @@ -175,7 +176,7 @@ bool HttpMsg::parse(MemBuf *buf, bool eof, http_status *error) debugs(58, 3, "HttpMsg::parse: failed to find end of headers (eof: " << eof << ") in '" << buf->content() << "'"); if (eof) // iff we have seen the end, this is an error - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; } @@ -184,13 +185,13 @@ bool HttpMsg::parse(MemBuf *buf, bool eof, http_status *error) if (res < 0) { // error debugs(58, 3, "HttpMsg::parse: cannot parse isolated headers in '" << buf->content() << "'"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; } if (res == 0) { debugs(58, 2, "HttpMsg::parse: strange, need more data near '" << buf->content() << "'"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; // but this should not happen due to headersEnd() above } diff --git a/src/HttpMsg.h b/src/HttpMsg.h index 48fb0fdf5d..02231eada6 100644 --- a/src/HttpMsg.h +++ b/src/HttpMsg.h @@ -35,7 +35,7 @@ #include "BodyPipe.h" #include "HttpHeader.h" #include "HttpRequestMethod.h" -#include "HttpStatusCode.h" +#include "http/StatusCode.h" #include "HttpVersion.h" #include "typedefs.h" @@ -89,8 +89,8 @@ public: // returns true and sets hdr_sz on success // returns false and sets *error to zero when needs more data - // returns false and sets *error to a positive http_status code on error - bool parse(MemBuf *buf, bool eol, http_status *error); + // returns false and sets *error to a positive Http::StatusCode on error + bool parse(MemBuf *buf, bool eol, Http::StatusCode *error); bool parseCharBuf(const char *buf, ssize_t end); @@ -112,7 +112,7 @@ protected: * \retval true Status line has no serious problems. * \retval false Status line has a serious problem. Correct response is indicated by error. */ - virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error) = 0; + virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) = 0; virtual void packFirstLineInto(Packer * p, bool full_uri) const = 0; diff --git a/src/HttpParser.cc b/src/HttpParser.cc index 39ebeb3044..a9c6949576 100644 --- a/src/HttpParser.cc +++ b/src/HttpParser.cc @@ -8,7 +8,7 @@ void HttpParser::clear() { state = HTTP_PARSE_NONE; - request_parse_status = HTTP_STATUS_NONE; + request_parse_status = Http::scNone; buf = NULL; bufsiz = 0; req.start = req.end = -1; @@ -96,7 +96,7 @@ HttpParser::parseRequestFirstLine() // RFC 2616 section 5.1 // "No CR or LF is allowed except in the final CRLF sequence" - request_parse_status = HTTP_BAD_REQUEST; + request_parse_status = Http::scBadRequest; return -1; } } @@ -116,25 +116,25 @@ HttpParser::parseRequestFirstLine() // First non-whitespace = beginning of method if (req.start > line_end) { - request_parse_status = HTTP_BAD_REQUEST; + request_parse_status = Http::scBadRequest; return -1; } req.m_start = req.start; // First whitespace = end of method if (first_whitespace > line_end || first_whitespace < req.start) { - request_parse_status = HTTP_BAD_REQUEST; // no method + request_parse_status = Http::scBadRequest; // no method return -1; } req.m_end = first_whitespace - 1; if (req.m_end < req.m_start) { - request_parse_status = HTTP_BAD_REQUEST; // missing URI? + request_parse_status = Http::scBadRequest; // missing URI? return -1; } // First non-whitespace after first SP = beginning of URL+Version if (second_word > line_end || second_word < req.start) { - request_parse_status = HTTP_BAD_REQUEST; // missing URI + request_parse_status = Http::scBadRequest; // missing URI return -1; } req.u_start = second_word; @@ -145,7 +145,7 @@ HttpParser::parseRequestFirstLine() req.v_maj = 0; req.v_min = 9; req.u_end = line_end; - request_parse_status = HTTP_OK; // HTTP/0.9 + request_parse_status = Http::scOkay; // HTTP/0.9 return 1; } else { // otherwise last whitespace is somewhere after end of URI. @@ -154,13 +154,13 @@ HttpParser::parseRequestFirstLine() for (; req.u_end >= req.u_start && xisspace(buf[req.u_end]); --req.u_end); } if (req.u_end < req.u_start) { - request_parse_status = HTTP_BAD_REQUEST; // missing URI + request_parse_status = Http::scBadRequest; // missing URI return -1; } // Last whitespace SP = before start of protocol/version if (last_whitespace >= line_end) { - request_parse_status = HTTP_BAD_REQUEST; // missing version + request_parse_status = Http::scBadRequest; // missing version return -1; } req.v_start = last_whitespace + 1; @@ -175,10 +175,11 @@ HttpParser::parseRequestFirstLine() req.v_maj = 0; req.v_min = 9; req.u_end = line_end; - request_parse_status = HTTP_OK; // treat as HTTP/0.9 + request_parse_status = Http::scOkay; // treat as HTTP/0.9 return 1; #else - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; // protocol not supported / implemented. + // protocol not supported / implemented. + request_parse_status = Http::scHttpVersionNotSupported; return -1; #endif } @@ -187,7 +188,7 @@ HttpParser::parseRequestFirstLine() /* next should be 1 or more digits */ if (!isdigit(buf[i])) { - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; + request_parse_status = Http::scHttpVersionNotSupported; return -1; } int maj = 0; @@ -197,24 +198,24 @@ HttpParser::parseRequestFirstLine() } // catch too-big values or missing remainders if (maj >= 65536 || i > line_end) { - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; + request_parse_status = Http::scHttpVersionNotSupported; return -1; } req.v_maj = maj; /* next should be .; we -have- to have this as we have a whole line.. */ if (buf[i] != '.') { - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; + request_parse_status = Http::scHttpVersionNotSupported; return -1; } // catch missing minor part if (++i > line_end) { - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; + request_parse_status = Http::scHttpVersionNotSupported; return -1; } /* next should be one or more digits */ if (!isdigit(buf[i])) { - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; + request_parse_status = Http::scHttpVersionNotSupported; return -1; } int min = 0; @@ -224,7 +225,7 @@ HttpParser::parseRequestFirstLine() } // catch too-big values or trailing garbage if (min >= 65536 || i < line_end) { - request_parse_status = HTTP_HTTP_VERSION_NOT_SUPPORTED; + request_parse_status = Http::scHttpVersionNotSupported; return -1; } req.v_min = min; @@ -232,7 +233,7 @@ HttpParser::parseRequestFirstLine() /* * Rightio - we have all the schtuff. Return true; we've got enough. */ - request_parse_status = HTTP_OK; + request_parse_status = Http::scOkay; return 1; } diff --git a/src/HttpParser.h b/src/HttpParser.h index 349eeaf962..7e941528db 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -1,7 +1,7 @@ #ifndef _SQUID_SRC_HTTPPARSER_H #define _SQUID_SRC_HTTPPARSER_H -#include "HttpStatusCode.h" +#include "http/StatusCode.h" // Parser states #define HTTP_PARSE_NONE 0 // nothing. completely unset state. @@ -72,9 +72,9 @@ public: // TODO: Offsets for pieces of the (HTTP reply) Status-Line as per RFC 2616 /** HTTP status code to be used on the invalid-request error page - * HTTP_STATUS_NONE indicates incomplete parse, HTTP_OK indicates no error. + * Http::scNone indicates incomplete parse, Http::scOkay indicates no error. */ - http_status request_parse_status; + Http::StatusCode request_parse_status; }; // Legacy functions diff --git a/src/HttpReply.cc b/src/HttpReply.cc index 9710eaa091..ae9333a79f 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -76,7 +76,7 @@ static http_hdr_type Denied304HeadersArr[] = { void httpReplyInitModule(void) { - assert(HTTP_STATUS_NONE == 0); // HttpReply::parse() interface assumes that + assert(Http::scNone == 0); // HttpReply::parse() interface assumes that httpHeaderMaskInit(&Denied304HeadersMask, 0); httpHeaderCalcMask(&Denied304HeadersMask, Denied304HeadersArr, countof(Denied304HeadersArr)); } @@ -161,7 +161,7 @@ HttpReply::pack() #if DEAD_CODE MemBuf * -httpPackedReply(http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires) +httpPackedReply(Http::StatusCode status, const char *ctype, int64_t clen, time_t lmt, time_t expires) { HttpReply *rep = new HttpReply; rep->setHeaders(status, ctype, NULL, clen, lmt, expires); @@ -189,7 +189,7 @@ HttpReply::make304() const /* rv->content_range */ /* rv->keep_alive */ HttpVersion ver(1,1); - httpStatusLineSet(&rv->sline, ver, HTTP_NOT_MODIFIED, NULL); + httpStatusLineSet(&rv->sline, ver, Http::scNotModified, NULL); for (t = 0; ImsEntries[t] != HDR_OTHER; ++t) if ((e = header.findEntry(ImsEntries[t]))) @@ -212,7 +212,7 @@ HttpReply::packed304Reply() } void -HttpReply::setHeaders(http_status status, const char *reason, +HttpReply::setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expiresTime) { HttpHeader *hdr; @@ -248,7 +248,7 @@ HttpReply::setHeaders(http_status status, const char *reason, } void -HttpReply::redirect(http_status status, const char *loc) +HttpReply::redirect(Http::StatusCode status, const char *loc) { HttpHeader *hdr; HttpVersion ver(1,1); @@ -430,13 +430,13 @@ HttpReply::bodySize(const HttpRequestMethod& method) const return -1; else if (method.id() == Http::METHOD_HEAD) return 0; - else if (sline.status == HTTP_OK) + else if (sline.status == Http::scOkay) (void) 0; /* common case, continue */ - else if (sline.status == HTTP_NO_CONTENT) + else if (sline.status == Http::scNoContent) return 0; - else if (sline.status == HTTP_NOT_MODIFIED) + else if (sline.status == Http::scNotModified) return 0; - else if (sline.status < HTTP_OK) + else if (sline.status < Http::scOkay) return 0; return content_length; @@ -449,7 +449,7 @@ HttpReply::bodySize(const HttpRequestMethod& method) const * NP: not all error cases are detected yet. Some are left for detection later in parse. */ bool -HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error) +HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) { // hack warning: using psize instead of size here due to type mismatches with MemBuf. @@ -458,7 +458,7 @@ HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status * if ( buf->contentSize() < (protoPrefix.psize() + 4) ) { if (hdr_len > 0) { debugs(58, 3, HERE << "Too small reply header (" << hdr_len << " bytes)"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; } return false; } @@ -473,7 +473,7 @@ HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status * if (protoPrefix.cmp(buf->content(), protoPrefix.size()) != 0) { debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix << ") in '" << buf->content() << "'"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; } @@ -486,7 +486,7 @@ HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status * // catch missing version info if (pos == protoPrefix.psize()) { debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol version numbers (ie. " << protoPrefix << "/1.0) in '" << buf->content() << "'"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; } } @@ -496,7 +496,7 @@ HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status * if (pos < buf->contentSize() && !xisdigit(*(buf->content()+pos))) { debugs(58, 3, "HttpReply::sanityCheckStartLine: missing or invalid status number in '" << buf->content() << "'"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; } @@ -519,7 +519,7 @@ HttpReply::httpMsgParseError() { int result(HttpMsg::httpMsgParseError()); /* indicate an error in the status line */ - sline.status = HTTP_INVALID_HEADER; + sline.status = Http::scInvalidHeader; return result; } @@ -534,11 +534,11 @@ HttpReply::expectingBody(const HttpRequestMethod& req_method, int64_t& theSize) if (req_method == Http::METHOD_HEAD) expectBody = false; - else if (sline.status == HTTP_NO_CONTENT) + else if (sline.status == Http::scNoContent) expectBody = false; - else if (sline.status == HTTP_NOT_MODIFIED) + else if (sline.status == Http::scNotModified) expectBody = false; - else if (sline.status < HTTP_OK) + else if (sline.status < Http::scOkay) expectBody = false; else expectBody = true; diff --git a/src/HttpReply.h b/src/HttpReply.h index c3d7b35454..c1fc688a47 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -39,7 +39,7 @@ void httpReplyInitModule(void); #if DEAD_CODE /** do everything in one call: init, set, pack, clean, return MemBuf */ -MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int64_t clen, time_t lmt, time_t expires); +MemBuf *httpPackedReply(HttpVersion ver, Http::StatusCode status, const char *ctype, int64_t clen, time_t lmt, time_t expires); #endif /* Sync changes here with HttpReply.cc */ @@ -63,9 +63,9 @@ public: /** \retval true on success \retval false and sets *error to zero when needs more data - \retval false and sets *error to a positive http_status code on error + \retval false and sets *error to a positive Http::StatusCode on error */ - virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error); + virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error); /** \par public, readable; never update these or their .hdr equivalents directly */ time_t date; @@ -101,7 +101,7 @@ public: void updateOnNotModified(HttpReply const *other); /** set commonly used info with one call */ - void setHeaders(http_status status, + void setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires); /** \return a ready to use mem buffer with a packed reply */ @@ -110,7 +110,7 @@ public: /** construct a 304 reply and return it */ HttpReply *make304() const; - void redirect(http_status, const char *); + void redirect(Http::StatusCode, const char *); int64_t bodySize(const HttpRequestMethod&) const; diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 308c072ab2..09a0f6c4b8 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -293,7 +293,7 @@ HttpRequest::inheritProperties(const HttpMsg *aMsg) * NP: Other errors are left for detection later in the parse. */ bool -HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error) +HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) { // content is long enough to possibly hold a reply // 2 being magic size of a 1-byte request method plus space delimiter @@ -301,7 +301,7 @@ HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status // this is ony a real error if the headers apparently complete. if (hdr_len > 0) { debugs(58, 3, HERE << "Too large request header (" << hdr_len << " bytes)"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; } return false; } @@ -309,7 +309,7 @@ HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status /* See if the request buffer starts with a known HTTP request method. */ if (HttpRequestMethod(buf->content(),NULL) == Http::METHOD_NONE) { debugs(73, 3, "HttpRequest::sanityCheckStartLine: did not find HTTP request method"); - *error = HTTP_INVALID_HEADER; + *error = Http::scInvalidHeader; return false; } diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 10968ac090..03120e848f 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -269,7 +269,7 @@ private: protected: virtual void packFirstLineInto(Packer * p, bool full_uri) const; - virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error); + virtual bool sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error); virtual void hdrCacheInit(); diff --git a/src/HttpStatusCode.h b/src/HttpStatusCode.h deleted file mode 100644 index edb66b4c9a..0000000000 --- a/src/HttpStatusCode.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _SQUID_SRC_HTTP_STATUSCODE_H -#define _SQUID_SRC_HTTP_STATUSCODE_H - -/** - * These basic HTTP reply status codes are defined by RFC 2616 unless otherwise stated. - */ -typedef enum { - HTTP_STATUS_NONE = 0, - HTTP_CONTINUE = 100, - HTTP_SWITCHING_PROTOCOLS = 101, - HTTP_PROCESSING = 102, /**< RFC2518 section 10.1 */ - HTTP_OK = 200, - HTTP_CREATED = 201, - HTTP_ACCEPTED = 202, - HTTP_NON_AUTHORITATIVE_INFORMATION = 203, - HTTP_NO_CONTENT = 204, - HTTP_RESET_CONTENT = 205, - HTTP_PARTIAL_CONTENT = 206, - HTTP_MULTI_STATUS = 207, /**< RFC2518 section 10.2 */ - HTTP_MULTIPLE_CHOICES = 300, - HTTP_MOVED_PERMANENTLY = 301, - HTTP_MOVED_TEMPORARILY = 302, - HTTP_SEE_OTHER = 303, - HTTP_NOT_MODIFIED = 304, - HTTP_USE_PROXY = 305, - HTTP_TEMPORARY_REDIRECT = 307, - HTTP_PERMANENT_REDIRECT = 308, - HTTP_BAD_REQUEST = 400, - HTTP_UNAUTHORIZED = 401, - HTTP_PAYMENT_REQUIRED = 402, - HTTP_FORBIDDEN = 403, - HTTP_NOT_FOUND = 404, - HTTP_METHOD_NOT_ALLOWED = 405, - HTTP_NOT_ACCEPTABLE = 406, - HTTP_PROXY_AUTHENTICATION_REQUIRED = 407, - HTTP_REQUEST_TIMEOUT = 408, - HTTP_CONFLICT = 409, - HTTP_GONE = 410, - HTTP_LENGTH_REQUIRED = 411, - HTTP_PRECONDITION_FAILED = 412, - HTTP_REQUEST_ENTITY_TOO_LARGE = 413, - HTTP_REQUEST_URI_TOO_LARGE = 414, - HTTP_UNSUPPORTED_MEDIA_TYPE = 415, - HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416, - HTTP_EXPECTATION_FAILED = 417, - HTTP_UNPROCESSABLE_ENTITY = 422, /**< RFC2518 section 10.3 */ - HTTP_LOCKED = 423, /**< RFC2518 section 10.4 */ - HTTP_FAILED_DEPENDENCY = 424, /**< RFC2518 section 10.5 */ - HTTP_PRECONDITION_REQUIRED = 428, /**< RFC6585 */ - HTTP_TOO_MANY_REQUESTS = 429, /**< RFC6585 */ - HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431, /**< RFC6585 */ - HTTP_INTERNAL_SERVER_ERROR = 500, - HTTP_NOT_IMPLEMENTED = 501, - HTTP_BAD_GATEWAY = 502, - HTTP_SERVICE_UNAVAILABLE = 503, - HTTP_GATEWAY_TIMEOUT = 504, - HTTP_HTTP_VERSION_NOT_SUPPORTED = 505, - HTTP_INSUFFICIENT_STORAGE = 507, /**< RFC2518 section 10.6 */ - HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511, /**< RFC6585 */ - - // The 6xx codes below are for internal use only: Bad requests result - // in HTTP_BAD_REQUEST; bad responses in HTTP_GATEWAY_TIMEOUT. - - HTTP_INVALID_HEADER = 600, /**< Squid header parsing error */ - HTTP_HEADER_TOO_LARGE = 601 /* Header too large to process */ -} http_status; - -#endif /* _SQUID_SRC_HTTP_STATUSCODE_H */ diff --git a/src/HttpStatusLine.cc b/src/HttpStatusLine.cc index 46276afd1f..f888634d0a 100644 --- a/src/HttpStatusLine.cc +++ b/src/HttpStatusLine.cc @@ -45,19 +45,19 @@ void httpStatusLineInit(HttpStatusLine * sline) { HttpVersion version; - httpStatusLineSet(sline, version, HTTP_STATUS_NONE, NULL); + httpStatusLineSet(sline, version, Http::scNone, NULL); } void httpStatusLineClean(HttpStatusLine * sline) { HttpVersion version; - httpStatusLineSet(sline, version, HTTP_INTERNAL_SERVER_ERROR, NULL); + httpStatusLineSet(sline, version, Http::scInternalServerError, NULL); } /* set values */ void -httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, http_status status, const char *reason) +httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, Http::StatusCode status, const char *reason) { assert(sline); sline->protocol = AnyP::PROTO_HTTP; @@ -101,7 +101,7 @@ int httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, const char *start, const char *end) { assert(sline); - sline->status = HTTP_INVALID_HEADER; /* Squid header parsing error */ + sline->status = Http::scInvalidHeader; /* Squid header parsing error */ // XXX: HttpMsg::parse() has a similar check but is using // casesensitive comparison (which is required by HTTP errata?) @@ -126,7 +126,7 @@ httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, const cha if (!(start = strchr(start, ' '))) return 0; - sline->status = (http_status) atoi(++start); + sline->status = static_cast(atoi(++start)); /* we ignore 'reason-phrase' */ /* Should assert start < end ? */ @@ -141,7 +141,7 @@ httpStatusLineReason(const HttpStatusLine * sline) } const char * -httpStatusString(http_status status) +httpStatusString(Http::StatusCode status) { /* why not to return matching string instead of using "p" ? @?@ */ const char *p = NULL; @@ -152,188 +152,188 @@ httpStatusString(http_status status) p = "Init"; /* we init .status with code 0 */ break; - case HTTP_CONTINUE: + case Http::scContinue: p = "Continue"; break; - case HTTP_SWITCHING_PROTOCOLS: + case Http::scSwitchingProtocols: p = "Switching Protocols"; break; - case HTTP_OK: + case Http::scOkay: p = "OK"; break; - case HTTP_CREATED: + case Http::scCreated: p = "Created"; break; - case HTTP_ACCEPTED: + case Http::scAccepted: p = "Accepted"; break; - case HTTP_NON_AUTHORITATIVE_INFORMATION: + case Http::scNonAuthoritativeInformation: p = "Non-Authoritative Information"; break; - case HTTP_NO_CONTENT: + case Http::scNoContent: p = "No Content"; break; - case HTTP_RESET_CONTENT: + case Http::scResetContent: p = "Reset Content"; break; - case HTTP_PARTIAL_CONTENT: + case Http::scPartialContent: p = "Partial Content"; break; - case HTTP_MULTI_STATUS: + case Http::scMultiStatus: p = "Multi-Status"; break; - case HTTP_MULTIPLE_CHOICES: + case Http::scMultipleChoices: p = "Multiple Choices"; break; - case HTTP_MOVED_PERMANENTLY: + case Http::scMovedPermanently: p = "Moved Permanently"; break; - case HTTP_MOVED_TEMPORARILY: + case Http::scMovedTemporarily: p = "Moved Temporarily"; break; - case HTTP_SEE_OTHER: + case Http::scSeeOther: p = "See Other"; break; - case HTTP_NOT_MODIFIED: + case Http::scNotModified: p = "Not Modified"; break; - case HTTP_USE_PROXY: + case Http::scUseProxy: p = "Use Proxy"; break; - case HTTP_TEMPORARY_REDIRECT: + case Http::scTemporaryRedirect: p = "Temporary Redirect"; break; - case HTTP_PERMANENT_REDIRECT: + case Http::scPermanentRedirect: p = "Permanent Redirect"; break; - case HTTP_BAD_REQUEST: + case Http::scBadRequest: p = "Bad Request"; break; - case HTTP_UNAUTHORIZED: + case Http::scUnauthorized: p = "Unauthorized"; break; - case HTTP_PAYMENT_REQUIRED: + case Http::scPaymentRequired: p = "Payment Required"; break; - case HTTP_FORBIDDEN: + case Http::scForbidden: p = "Forbidden"; break; - case HTTP_NOT_FOUND: + case Http::scNotFound: p = "Not Found"; break; - case HTTP_METHOD_NOT_ALLOWED: + case Http::scMethodNotAllowed: p = "Method Not Allowed"; break; - case HTTP_NOT_ACCEPTABLE: + case Http::scNotAcceptable: p = "Not Acceptable"; break; - case HTTP_PROXY_AUTHENTICATION_REQUIRED: + case Http::scProxyAuthenticationRequired: p = "Proxy Authentication Required"; break; - case HTTP_REQUEST_TIMEOUT: + case Http::scRequestTimeout: p = "Request Time-out"; break; - case HTTP_CONFLICT: + case Http::scConflict: p = "Conflict"; break; - case HTTP_GONE: + case Http::scGone: p = "Gone"; break; - case HTTP_LENGTH_REQUIRED: + case Http::scLengthRequired: p = "Length Required"; break; - case HTTP_PRECONDITION_FAILED: + case Http::scPreconditionFailed: p = "Precondition Failed"; break; - case HTTP_REQUEST_ENTITY_TOO_LARGE: + case Http::scRequestEntityTooLarge: p = "Request Entity Too Large"; break; - case HTTP_REQUEST_URI_TOO_LARGE: + case Http::scRequestUriTooLarge: p = "Request-URI Too Large"; break; - case HTTP_UNSUPPORTED_MEDIA_TYPE: + case Http::scUnsupportedMediaType: p = "Unsupported Media Type"; break; - case HTTP_REQUESTED_RANGE_NOT_SATISFIABLE: + case Http::scRequestedRangeNotSatisfied: p = "Requested Range Not Satisfiable"; break; - case HTTP_EXPECTATION_FAILED: + case Http::scExpectationFailed: p = "Expectation Failed"; break; - case HTTP_INTERNAL_SERVER_ERROR: + case Http::scInternalServerError: p = "Internal Server Error"; break; - case HTTP_NOT_IMPLEMENTED: + case Http::scNotImplemented: p = "Not Implemented"; break; - case HTTP_BAD_GATEWAY: + case Http::scBadGateway: p = "Bad Gateway"; break; - case HTTP_SERVICE_UNAVAILABLE: + case Http::scServiceUnavailable: p = "Service Unavailable"; break; - case HTTP_GATEWAY_TIMEOUT: + case Http::scGateway_Timeout: p = "Gateway Time-out"; break; - case HTTP_HTTP_VERSION_NOT_SUPPORTED: + case Http::scHttpVersionNotSupported: p = "HTTP Version not supported"; break; // RFC 6585 - case HTTP_PRECONDITION_REQUIRED: // 428 + case Http::scPreconditionRequired: // 428 p = "Precondition Required"; break; - case HTTP_TOO_MANY_REQUESTS: // 429 + case Http::scTooManyFields: // 429 p = "Too Many Requests"; break; - case HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE: // 431 + case Http::scRequestHeaderFieldsTooLarge: // 431 p = "Request Header Fields Too Large"; break; - case HTTP_NETWORK_AUTHENTICATION_REQUIRED: // 511 + case Http::scNetworkAuthenticationRequired: // 511 p = "Network Authentication Required"; break; diff --git a/src/HttpStatusLine.h b/src/HttpStatusLine.h index 2567622627..5e95c20957 100644 --- a/src/HttpStatusLine.h +++ b/src/HttpStatusLine.h @@ -31,14 +31,14 @@ #ifndef SQUID_HTTPSTATUSLINE_H #define SQUID_HTTPSTATUSLINE_H -class Packer; -class String; - -#include "HttpStatusCode.h" +#include "http/StatusCode.h" #include "HttpVersion.h" #include "anyp/ProtocolType.h" #include "SquidString.h" +class Packer; +class String; + /** * Holds the values parsed from an HTTP reply status line. * @@ -57,7 +57,7 @@ public: AnyP::ProtocolType protocol; HttpVersion version; ///< breakdown of protocol version labels: 0.9 1.0 1.1 - http_status status; ///< status code. ie 200 404 + Http::StatusCode status; ///< status code. ie 200 404 const char *reason; ///< points to a _constant_ string (default or supplied), never free()d */ }; @@ -66,7 +66,7 @@ void httpStatusLineInit(HttpStatusLine * sline); void httpStatusLineClean(HttpStatusLine * sline); /* set/get values */ void httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, - http_status status, const char *reason); + Http::StatusCode status, const char *reason); const char *httpStatusLineReason(const HttpStatusLine * sline); /* parse/pack */ /* parse a 0-terminating buffer and fill internal structires; returns true on success */ @@ -75,6 +75,6 @@ int httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, /* pack fields using Packer */ void httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p); -const char *httpStatusString(http_status status); +const char *httpStatusString(Http::StatusCode status); #endif /* SQUID_HTTPSTATUSLINE_H */ diff --git a/src/Makefile.am b/src/Makefile.am index a3a2ef260c..60c477dc79 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -371,7 +371,7 @@ squid_SOURCES = \ HttpStateFlags.h \ http.cc \ http.h \ - HttpStatusCode.h \ + http/StatusCode.h \ HttpStatusLine.cc \ HttpStatusLine.h \ HttpHeaderFieldStat.h \ @@ -1154,7 +1154,7 @@ tests_testHttpReply_SOURCES=\ HttpMsg.h \ HttpReply.cc \ HttpReply.h \ - HttpStatusCode.h \ + http/StatusCode.h \ HttpStatusLine.cc \ HttpStatusLine.h \ Mem.h \ diff --git a/src/Server.cc b/src/Server.cc index 746d15d0df..8bfb6a3ac6 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -383,7 +383,7 @@ ServerStateData::sentRequestBody(const CommIoCbParams &io) if (io.flag) { debugs(11, DBG_IMPORTANT, "sentRequestBody error: FD " << io.fd << ": " << xstrerr(io.xerrno)); ErrorState *err; - err = new ErrorState(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request); + err = new ErrorState(ERR_WRITE_ERROR, Http::scBadGateway, fwd->request); err->xerrno = io.xerrno; fwd->fail(err); abortTransaction("I/O error while sending request body"); @@ -828,7 +828,7 @@ ServerStateData::handleAdaptationAborted(bool bypassable) if (entry->isEmpty()) { debugs(11,9, HERE << "creating ICAP error entry after ICAP failure"); - ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); + ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, Http::scInternalServerError, request); err->detailError(ERR_DETAIL_ICAP_RESPMOD_EARLY); fwd->fail(err); fwd->dontRetry(true); @@ -862,7 +862,7 @@ ServerStateData::handleAdaptationBlocked(const Adaptation::Answer &answer) if (page_id == ERR_NONE) page_id = ERR_ACCESS_DENIED; - ErrorState *err = new ErrorState(page_id, HTTP_FORBIDDEN, request); + ErrorState *err = new ErrorState(page_id, Http::scForbidden, request); err->detailError(ERR_DETAIL_RESPMOD_BLOCK_EARLY); fwd->fail(err); fwd->dontRetry(true); @@ -901,7 +901,7 @@ ServerStateData::noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer grou void ServerStateData::sendBodyIsTooLargeError() { - ErrorState *err = new ErrorState(ERR_TOO_BIG, HTTP_FORBIDDEN, request); + ErrorState *err = new ErrorState(ERR_TOO_BIG, Http::scForbidden, request); fwd->fail(err); fwd->dontRetry(true); abortTransaction("Virgin body too large."); diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index f6865e7119..d2a9b941b9 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -296,7 +296,7 @@ asHandleReply(void *data, StoreIOBuffer result) debugs(53, DBG_IMPORTANT, "asHandleReply: Called with Error set and size=" << (unsigned int) result.length); asStateFree(asState); return; - } else if (HTTP_OK != e->getReply()->sline.status) { + } else if (Http::scOkay != e->getReply()->sline.status) { debugs(53, DBG_IMPORTANT, "WARNING: AS " << asState->as_number << " whois request failed"); asStateFree(asState); return; diff --git a/src/acl/HttpStatus.cc b/src/acl/HttpStatus.cc index fcf9703922..c5582b999a 100644 --- a/src/acl/HttpStatus.cc +++ b/src/acl/HttpStatus.cc @@ -46,7 +46,7 @@ static void aclParseHTTPStatusList(SplayNode **curlist); static int aclHTTPStatusCompare(acl_httpstatus_data * const &a, acl_httpstatus_data * const &b); -static int aclMatchHTTPStatus(SplayNode **dataptr, http_status status); +static int aclMatchHTTPStatus(SplayNode **dataptr, Http::StatusCode status); acl_httpstatus_data::acl_httpstatus_data(int x) : status1(x), status2(x) { ; } @@ -160,7 +160,7 @@ ACLHTTPStatus::match(ACLChecklist *checklist) } int -aclMatchHTTPStatus(SplayNode **dataptr, http_status status) +aclMatchHTTPStatus(SplayNode **dataptr, Http::StatusCode status) { acl_httpstatus_data X(status); diff --git a/src/adaptation/ecap/MessageRep.cc b/src/adaptation/ecap/MessageRep.cc index 9e71ba6189..ecdea7d703 100644 --- a/src/adaptation/ecap/MessageRep.cc +++ b/src/adaptation/ecap/MessageRep.cc @@ -99,7 +99,7 @@ Adaptation::Ecap::HeaderRep::parse(const Area &buf) MemBuf mb; mb.init(); mb.append(buf.start, buf.size); - http_status error; + Http::StatusCode error; Must(theMessage.parse(&mb, true, &error)); } @@ -293,7 +293,7 @@ void Adaptation::Ecap::StatusLineRep::statusCode(int code) { // TODO: why is .status a enum? Do we not support unknown statuses? - theMessage.sline.status = static_cast(code); + theMessage.sline.status = static_cast(code); } int diff --git a/src/adaptation/icap/ModXact.cc b/src/adaptation/icap/ModXact.cc index 72086a9b45..3d19e20632 100644 --- a/src/adaptation/icap/ModXact.cc +++ b/src/adaptation/icap/ModXact.cc @@ -958,7 +958,7 @@ void Adaptation::Icap::ModXact::prepEchoing() } // parse the buffer back - http_status error = HTTP_STATUS_NONE; + Http::StatusCode error = Http::scNone; Must(adapted.header->parse(&httpBuf, true, &error)); @@ -1071,7 +1071,7 @@ bool Adaptation::Icap::ModXact::parseHead(HttpMsg *head) debugs(93, 5, HERE << "have " << readBuf.contentSize() << " head bytes to parse" << "; state: " << state.parsing); - http_status error = HTTP_STATUS_NONE; + Http::StatusCode error = Http::scNone; const bool parsed = head->parse(&readBuf, commEof, &error); Must(parsed || !error); // success or need more data diff --git a/src/adaptation/icap/OptXact.cc b/src/adaptation/icap/OptXact.cc index e4da1d18d2..e092d72843 100644 --- a/src/adaptation/icap/OptXact.cc +++ b/src/adaptation/icap/OptXact.cc @@ -56,7 +56,7 @@ void Adaptation::Icap::OptXact::makeRequest(MemBuf &buf) buf.append(ICAP::crlf, 2); // XXX: HttpRequest cannot fully parse ICAP Request-Line - http_status reqStatus; + Http::StatusCode reqStatus; Must(icapRequest->parse(&buf, true, &reqStatus) > 0); } diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index 996be69db8..a7a80e76a5 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -439,7 +439,7 @@ bool Adaptation::Icap::Xaction::parseHttpMsg(HttpMsg *msg) { debugs(93, 5, HERE << "have " << readBuf.contentSize() << " head bytes to parse"); - http_status error = HTTP_STATUS_NONE; + Http::StatusCode error = Http::scNone; const bool parsed = msg->parse(&readBuf, commEof, &error); Must(parsed || !error); // success or need more data diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index fa65fcc636..ff38b8780c 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -481,12 +481,12 @@ Auth::UserRequest::addReplyAuthHeader(HttpReply * rep, Auth::UserRequest::Pointe switch (rep->sline.status) { - case HTTP_PROXY_AUTHENTICATION_REQUIRED: + case Http::scProxyAuthenticationRequired: /* Proxy authorisation needed */ type = HDR_PROXY_AUTHENTICATE; break; - case HTTP_UNAUTHORIZED: + case Http::scUnauthorized: /* WWW Authorisation needed */ type = HDR_WWW_AUTHENTICATE; break; @@ -500,8 +500,8 @@ Auth::UserRequest::addReplyAuthHeader(HttpReply * rep, Auth::UserRequest::Pointe debugs(29, 9, HERE << "headertype:" << type << " authuser:" << auth_user_request); - if (((rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED) - || (rep->sline.status == HTTP_UNAUTHORIZED)) && internal) + if (((rep->sline.status == Http::scProxyAuthenticationRequired) + || (rep->sline.status == Http::scUnauthorized)) && internal) /* this is a authenticate-needed response */ { diff --git a/src/auth/digest/UserRequest.cc b/src/auth/digest/UserRequest.cc index f1059aa05a..98f97d5529 100644 --- a/src/auth/digest/UserRequest.cc +++ b/src/auth/digest/UserRequest.cc @@ -200,9 +200,8 @@ Auth::Digest::UserRequest::addAuthenticationInfoHeader(HttpReply * rep, int acce http_hdr_type type; /* don't add to authentication error pages */ - - if ((!accel && rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED) - || (accel && rep->sline.status == HTTP_UNAUTHORIZED)) + if ((!accel && rep->sline.status == Http::scProxyAuthenticationRequired) + || (accel && rep->sline.status == Http::scUnauthorized)) return; type = accel ? HDR_AUTHENTICATION_INFO : HDR_PROXY_AUTHENTICATION_INFO; @@ -234,8 +233,8 @@ Auth::Digest::UserRequest::addAuthenticationInfoTrailer(HttpReply * rep, int acc return; /* don't add to authentication error pages */ - if ((!accel && rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED) - || (accel && rep->sline.status == HTTP_UNAUTHORIZED)) + if ((!accel && rep->sline.status == Http::scProxyAuthenticationRequired) + || (accel && rep->sline.status == Http::scUnauthorized)) return; type = accel ? HDR_AUTHENTICATION_INFO : HDR_PROXY_AUTHENTICATION_INFO; diff --git a/src/auth/negotiate/UserRequest.cc b/src/auth/negotiate/UserRequest.cc index e5963b5732..c24fe9cd56 100644 --- a/src/auth/negotiate/UserRequest.cc +++ b/src/auth/negotiate/UserRequest.cc @@ -385,8 +385,8 @@ Auth::Negotiate::UserRequest::addAuthenticationInfoHeader(HttpReply * rep, int a return; /* don't add to authentication error pages */ - if ((!accel && rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED) - || (accel && rep->sline.status == HTTP_UNAUTHORIZED)) + if ((!accel && rep->sline.status == Http::scProxyAuthenticationRequired) + || (accel && rep->sline.status == Http::scUnauthorized)) return; type = accel ? HDR_AUTHENTICATION_INFO : HDR_PROXY_AUTHENTICATION_INFO; diff --git a/src/cache_manager.cc b/src/cache_manager.cc index d5f8b3538a..4f2f8a11d2 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -330,7 +330,7 @@ CacheManager::Start(const Comm::ConnectionPointer &client, HttpRequest * request Mgr::Command::Pointer cmd = ParseUrl(entry->url()); if (!cmd) { - ErrorState *err = new ErrorState(ERR_INVALID_URL, HTTP_NOT_FOUND, request); + ErrorState *err = new ErrorState(ERR_INVALID_URL, Http::scNotFound, request); err->url = xstrdup(entry->url()); errorAppendEntry(entry, err); entry->expires = squid_curtime; @@ -353,7 +353,7 @@ CacheManager::Start(const Comm::ConnectionPointer &client, HttpRequest * request if (CheckPassword(*cmd) != 0) { /* build error message */ - ErrorState errState(ERR_CACHE_MGR_ACCESS_DENIED, HTTP_UNAUTHORIZED, request); + ErrorState errState(ERR_CACHE_MGR_ACCESS_DENIED, Http::scUnauthorized, request); /* warn if user specified incorrect password */ if (cmd->params.password.size()) { @@ -407,11 +407,11 @@ CacheManager::Start(const Comm::ConnectionPointer &client, HttpRequest * request // special case: /squid-internal-mgr/ index page if (!strcmp(cmd->profile->name, "index")) { - ErrorState err(MGR_INDEX, HTTP_OK, request); + ErrorState err(MGR_INDEX, Http::scOkay, request); err.url = xstrdup(entry->url()); HttpReply *rep = err.BuildHttpReply(); if (strncmp(rep->body.content(),"Internal Error:", 15) == 0) - rep->sline.status = HTTP_NOT_FOUND; + rep->sline.status = Http::scNotFound; // Allow cachemgr and other XHR scripts access to our version string if (request->header.has(HDR_ORIGIN)) { rep->header.putExt("Access-Control-Allow-Origin",request->header.getStr(HDR_ORIGIN)); diff --git a/src/client_side.cc b/src/client_side.cc index 52e369aa11..a6c52c9b06 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1278,7 +1278,7 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep) if (!rep) range_err = "no [parse-able] reply"; - else if ((rep->sline.status != HTTP_OK) && (rep->sline.status != HTTP_PARTIAL_CONTENT)) + else if ((rep->sline.status != Http::scOkay) && (rep->sline.status != Http::scPartialContent)) range_err = "wrong status code"; else if (hdr->has(HDR_CONTENT_RANGE)) range_err = "origin server does ranges"; @@ -1311,8 +1311,7 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep) http->request->range = NULL; } else { /* XXX: TODO: Review, this unconditional set may be wrong. - TODO: review. */ - httpStatusLineSet(&rep->sline, rep->sline.version, - HTTP_PARTIAL_CONTENT, NULL); + httpStatusLineSet(&rep->sline, rep->sline.version, Http::scPartialContent, NULL); // web server responded with a valid, but unexpected range. // will (try-to) forward as-is. //TODO: we should cope with multirange request/responses @@ -2052,7 +2051,7 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url, #if SHOULD_REJECT_UNKNOWN_URLS if (!url) { - hp->request_parse_status = HTTP_BAD_REQUEST; + hp->request_parse_status = Http::scBadRequest; return parseHttpRequestAbort(conn, "error:invalid-request"); } #endif @@ -2180,7 +2179,7 @@ parseHttpRequest(ConnStateData *csd, HttpParser *hp, HttpRequestMethod * method_ return NULL; } else if ( (size_t)hp->bufsiz >= Config.maxRequestHeaderSize && headersEnd(hp->buf, Config.maxRequestHeaderSize) == 0) { debugs(33, 5, "parseHttpRequest: Too large request"); - hp->request_parse_status = HTTP_HEADER_TOO_LARGE; + hp->request_parse_status = Http::scHeaderTooLarge; return parseHttpRequestAbort(csd, "error:request-too-large"); } @@ -2225,7 +2224,7 @@ parseHttpRequest(ConnStateData *csd, HttpParser *hp, HttpRequestMethod * method_ /* Enforce max_request_size */ if (req_sz >= Config.maxRequestHeaderSize) { debugs(33, 5, "parseHttpRequest: Too large request"); - hp->request_parse_status = HTTP_HEADER_TOO_LARGE; + hp->request_parse_status = Http::scHeaderTooLarge; return parseHttpRequestAbort(csd, "error:request-too-large"); } @@ -2237,14 +2236,14 @@ parseHttpRequest(ConnStateData *csd, HttpParser *hp, HttpRequestMethod * method_ debugs(33, DBG_IMPORTANT, "WARNING: CONNECT method received on " << csd->port->protocol << " Accelerator port " << csd->port->s.GetPort() ); /* XXX need a way to say "this many character length string" */ debugs(33, DBG_IMPORTANT, "WARNING: for request: " << hp->buf); - hp->request_parse_status = HTTP_METHOD_NOT_ALLOWED; + hp->request_parse_status = Http::scMethodNotAllowed; return parseHttpRequestAbort(csd, "error:method-not-allowed"); } if (*method_p == Http::METHOD_NONE) { /* XXX need a way to say "this many character length string" */ debugs(33, DBG_IMPORTANT, "clientParseRequestMethod: Unsupported method in request '" << hp->buf << "'"); - hp->request_parse_status = HTTP_METHOD_NOT_ALLOWED; + hp->request_parse_status = Http::scMethodNotAllowed; return parseHttpRequestAbort(csd, "error:unsupported-request-method"); } @@ -2468,7 +2467,7 @@ ConnStateData::checkHeaderLimits() clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); repContext->setReplyToError(ERR_TOO_BIG, - HTTP_BAD_REQUEST, Http::METHOD_NONE, NULL, + Http::scBadRequest, Http::METHOD_NONE, NULL, clientConnection->remote, NULL, NULL, NULL); context->registerWithConn(); context->pullData(); @@ -2561,7 +2560,7 @@ bool ConnStateData::serveDelayedError(ClientSocketContext *context) request->hier.note(peekerRequest->hier.tcpServer, request->GetHost()); // Create an error object and fill it - ErrorState *err = new ErrorState(ERR_SECURE_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request); + ErrorState *err = new ErrorState(ERR_SECURE_CONNECT_FAIL, Http::scServiceUnavailable, request); err->src_addr = clientConnection->remote; Ssl::ErrorDetail *errDetail = new Ssl::ErrorDetail( SQUID_X509_V_ERR_DOMAIN_MISMATCH, @@ -2608,11 +2607,11 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); switch (hp->request_parse_status) { - case HTTP_HEADER_TOO_LARGE: - repContext->setReplyToError(ERR_TOO_BIG, HTTP_BAD_REQUEST, method, http->uri, conn->clientConnection->remote, NULL, conn->in.buf, NULL); + case Http::scHeaderTooLarge: + repContext->setReplyToError(ERR_TOO_BIG, Http::scBadRequest, method, http->uri, conn->clientConnection->remote, NULL, conn->in.buf, NULL); break; - case HTTP_METHOD_NOT_ALLOWED: - repContext->setReplyToError(ERR_UNSUP_REQ, HTTP_METHOD_NOT_ALLOWED, method, http->uri, + case Http::scMethodNotAllowed: + repContext->setReplyToError(ERR_UNSUP_REQ, Http::scMethodNotAllowed, method, http->uri, conn->clientConnection->remote, NULL, conn->in.buf, NULL); break; default: @@ -2632,7 +2631,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c setLogUri(http, http->uri, true); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, conn->clientConnection->remote, NULL, NULL, NULL); + repContext->setReplyToError(ERR_INVALID_URL, Http::scBadRequest, method, http->uri, conn->clientConnection->remote, NULL, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); goto finish; @@ -2651,7 +2650,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c setLogUri(http, http->uri, true); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_UNSUP_HTTPVERSION, HTTP_HTTP_VERSION_NOT_SUPPORTED, method, http->uri, + repContext->setReplyToError(ERR_UNSUP_HTTPVERSION, Http::scHttpVersionNotSupported, method, http->uri, conn->clientConnection->remote, NULL, HttpParserHdrBuf(hp), NULL); assert(context->http->out.offset == 0); context->pullData(); @@ -2669,7 +2668,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c setLogUri(http, http->uri, true); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, http->uri, conn->clientConnection->remote, NULL, NULL, NULL); + repContext->setReplyToError(ERR_INVALID_REQ, Http::scBadRequest, method, http->uri, conn->clientConnection->remote, NULL, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); goto finish; @@ -2746,7 +2745,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c conn->quitAfterError(request.getRaw()); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED, request->method, NULL, + repContext->setReplyToError(ERR_UNSUP_REQ, Http::scNotImplemented, request->method, NULL, conn->clientConnection->remote, request.getRaw(), NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); @@ -2759,7 +2758,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c assert (repContext); conn->quitAfterError(request.getRaw()); repContext->setReplyToError(ERR_INVALID_REQ, - HTTP_LENGTH_REQUIRED, request->method, NULL, + Http::scLengthRequired, request->method, NULL, conn->clientConnection->remote, request.getRaw(), NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); @@ -2774,7 +2773,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); conn->quitAfterError(request.getRaw()); - repContext->setReplyToError(ERR_INVALID_REQ, HTTP_EXPECTATION_FAILED, request->method, http->uri, + repContext->setReplyToError(ERR_INVALID_REQ, Http::scExpectationFailed, request->method, http->uri, conn->clientConnection->remote, request.getRaw(), NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); @@ -2815,7 +2814,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c assert (repContext); conn->quitAfterError(request.getRaw()); repContext->setReplyToError(ERR_TOO_BIG, - HTTP_REQUEST_ENTITY_TOO_LARGE, Http::METHOD_NONE, NULL, + Http::scRequestEntityTooLarge, Http::METHOD_NONE, NULL, conn->clientConnection->remote, http->request, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); @@ -3169,8 +3168,8 @@ ConnStateData::abortChunkedRequestBody(const err_type error) clientStreamNode *node = context->getClientReplyContext(); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert(repContext); - const http_status scode = (error == ERR_TOO_BIG) ? - HTTP_REQUEST_ENTITY_TOO_LARGE : HTTP_BAD_REQUEST; + const Http::StatusCode scode = (error == ERR_TOO_BIG) ? + Http::scRequestEntityTooLarge : HTTP_BAD_REQUEST; repContext->setReplyToError(error, scode, repContext->http->request->method, repContext->http->uri, @@ -3243,7 +3242,7 @@ ConnStateData::requestTimeout(const CommTimeoutCbParams &io) clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); repContext->setReplyToError(ERR_LIFETIME_EXP, - HTTP_REQUEST_TIMEOUT, Http::METHOD_NONE, "N/A", &CachePeer.sin_addr, + Http::scRequestTimeout, Http::METHOD_NONE, "N/A", &CachePeer.sin_addr, NULL, NULL, NULL); /* No requests can be outstanded */ assert(chr == NULL); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 412011c3e6..90459a4171 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -76,7 +76,7 @@ CBDATA_CLASS_INIT(clientReplyContext); /* Local functions */ extern "C" CSS clientReplyStatus; -ErrorState *clientBuildError(err_type, http_status, char const *, Ip::Address &, HttpRequest *); +ErrorState *clientBuildError(err_type, Http::StatusCode, char const *, Ip::Address &, HttpRequest *); /* privates */ @@ -105,7 +105,7 @@ clientReplyContext::clientReplyContext(ClientHttpRequest *clientContext) : http */ void clientReplyContext::setReplyToError( - err_type err, http_status status, const HttpRequestMethod& method, char const *uri, + err_type err, Http::StatusCode status, const HttpRequestMethod& method, char const *uri, Ip::Address &addr, HttpRequest * failedrequest, const char *unparsedrequest, #if USE_AUTH Auth::UserRequest::Pointer auth_user_request @@ -127,7 +127,7 @@ clientReplyContext::setReplyToError( void clientReplyContext::setReplyToError(const HttpRequestMethod& method, ErrorState *errstate) { - if (errstate->httpStatus == HTTP_NOT_IMPLEMENTED && http->request) + if (errstate->httpStatus == Http::scNotImplemented && http->request) /* prevent confusion over whether we default to persistent or not */ http->request->flags.proxyKeepalive = false; @@ -376,7 +376,7 @@ clientReplyContext::handleIMSReply(StoreIOBuffer result) /* update size of the request */ reqsize = result.length + reqofs; - const http_status status = http->storeEntry()->getReply()->sline.status; + const Http::StatusCode status = http->storeEntry()->getReply()->sline.status; // request to origin was aborted if (EBIT_TEST(http->storeEntry()->flags, ENTRY_ABORTED)) { @@ -388,7 +388,7 @@ clientReplyContext::handleIMSReply(StoreIOBuffer result) HttpReply *old_rep = (HttpReply *) old_entry->getReply(); // origin replied 304 - if (status == HTTP_NOT_MODIFIED) { + if (status == Http::scNotModified) { http->logType = LOG_TCP_REFRESH_UNMODIFIED; http->request->flags.staleIfHit = false; // old_entry is no longer stale @@ -411,7 +411,7 @@ clientReplyContext::handleIMSReply(StoreIOBuffer result) } // origin replied with a non-error code - else if (status > HTTP_STATUS_NONE && status < HTTP_INTERNAL_SERVER_ERROR) { + else if (status > Http::scNone && status < Http::scInternalServerError) { // forward response from origin http->logType = LOG_TCP_REFRESH_MODIFIED; debugs(88, 3, "handleIMSReply: origin replied " << status << ", replacing existing entry and forwarding to client"); @@ -657,8 +657,8 @@ clientReplyContext::processMiss() /// Deny loops if (r->flags.loopDetected) { - http->al->http.code = HTTP_FORBIDDEN; - err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConnection->remote, http->request); + http->al->http.code = Http::scForbidden; + err = clientBuildError(ERR_ACCESS_DENIED, Http::scForbidden, NULL, http->getConn()->clientConnection->remote, http->request); createStoreEntry(r->method, RequestFlags()); errorAppendEntry(http->storeEntry(), err); triggerInitialStoreRead(); @@ -701,8 +701,8 @@ clientReplyContext::processOnlyIfCachedMiss() { debugs(88, 4, "clientProcessOnlyIfCachedMiss: '" << RequestMethodStr(http->request->method) << " " << http->uri << "'"); - http->al->http.code = HTTP_GATEWAY_TIMEOUT; - ErrorState *err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT, NULL, + http->al->http.code = Http::scGateway_Timeout; + ErrorState *err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, Http::scGateway_Timeout, NULL, http->getConn()->clientConnection->remote, http->request); removeClientStoreReference(&sc, http); startError(err); @@ -714,7 +714,7 @@ clientReplyContext::processConditional(StoreIOBuffer &result) { StoreEntry *const e = http->storeEntry(); - if (e->getReply()->sline.status != HTTP_OK) { + if (e->getReply()->sline.status != Http::scOkay) { debugs(88, 4, "clientReplyContext::processConditional: Reply code " << e->getReply()->sline.status << " != 200"); http->logType = LOG_TCP_MISS; @@ -869,7 +869,7 @@ clientReplyContext::purgeFoundObject(StoreEntry *entry) if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) { http->logType = LOG_TCP_DENIED; - ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, + ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, Http::scForbidden, NULL, http->getConn()->clientConnection->remote, http->request); startError(err); return; @@ -908,7 +908,7 @@ clientReplyContext::purgeRequest() if (!Config2.onoff.enable_purge) { http->logType = LOG_TCP_DENIED; - ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConnection->remote, http->request); + ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, Http::scForbidden, NULL, http->getConn()->clientConnection->remote, http->request); startError(err); return; } @@ -935,7 +935,7 @@ clientReplyContext::purgeDoPurgeGet(StoreEntry *newEntry) { assert (newEntry); /* Move to new() when that is created */ - purgeStatus = HTTP_NOT_FOUND; + purgeStatus = Http::scNotFound; if (!newEntry->isNull()) { /* Release the cached URI */ @@ -944,7 +944,7 @@ clientReplyContext::purgeDoPurgeGet(StoreEntry *newEntry) neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(Http::METHOD_GET), HTCP_CLR_PURGE); #endif newEntry->release(); - purgeStatus = HTTP_OK; + purgeStatus = Http::scOkay; } lookingforstore = 4; @@ -960,7 +960,7 @@ clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry) neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(Http::METHOD_HEAD), HTCP_CLR_PURGE); #endif newEntry->release(); - purgeStatus = HTTP_OK; + purgeStatus = Http::scOkay; } /* And for Vary, release the base URI if none of the headers was included in the request */ @@ -975,7 +975,7 @@ clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry) neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(Http::METHOD_GET), HTCP_CLR_PURGE); #endif entry->release(); - purgeStatus = HTTP_OK; + purgeStatus = Http::scOkay; } entry = storeGetPublic(urlCanonical(http->request), Http::METHOD_HEAD); @@ -986,7 +986,7 @@ clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry) neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(Http::METHOD_HEAD), HTCP_CLR_PURGE); #endif entry->release(); - purgeStatus = HTTP_OK; + purgeStatus = Http::scOkay; } } @@ -1021,7 +1021,7 @@ clientReplyContext::traceReply(clientStreamNode * node) http->storeEntry()->releaseRequest(); http->storeEntry()->buffer(); HttpReply *rep = new HttpReply; - rep->setHeaders(HTTP_OK, NULL, "text/plain", http->request->prefixLen(), 0, squid_curtime); + rep->setHeaders(Http::scOkay, NULL, "text/plain", http->request->prefixLen(), 0, squid_curtime); http->storeEntry()->replaceHttpReply(rep); http->request->swapOut(http->storeEntry()); http->storeEntry()->complete(); @@ -1232,21 +1232,21 @@ clientReplyContext::replyStatus() * mysterious breakages. */ bool -clientReplyContext::alwaysAllowResponse(http_status sline) const +clientReplyContext::alwaysAllowResponse(Http::StatusCode sline) const { bool result; switch (sline) { - case HTTP_CONTINUE: + case Http::scContinue: - case HTTP_SWITCHING_PROTOCOLS: + case Http::scSwitchingProtocols: - case HTTP_PROCESSING: + case Http::scProcessing: - case HTTP_NO_CONTENT: + case Http::scNoContent: - case HTTP_NOT_MODIFIED: + case Http::scNotModified: result = true; break; @@ -1430,8 +1430,8 @@ clientReplyContext::buildReplyHeader() #if USE_AUTH /* Handle authentication headers */ if (http->logType == LOG_TCP_DENIED && - ( reply->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED || - reply->sline.status == HTTP_UNAUTHORIZED) + ( reply->sline.status == Http::scProxyAuthenticationRequired || + reply->sline.status == Http::scUnauthorized) ) { /* Add authentication header */ /*! \todo alter errorstate to be accel on|off aware. The 0 on the next line @@ -1868,7 +1868,7 @@ clientReplyContext::sendBodyTooLargeError() Ip::Address tmp_noaddr; tmp_noaddr.SetNoAddr(); // TODO: make a global const http->logType = LOG_TCP_DENIED_REPLY; - ErrorState *err = clientBuildError(ERR_TOO_BIG, HTTP_FORBIDDEN, NULL, + ErrorState *err = clientBuildError(ERR_TOO_BIG, Http::scForbidden, NULL, http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmp_noaddr, http->request); removeClientStoreReference(&(sc), http); @@ -1883,7 +1883,7 @@ clientReplyContext::sendPreconditionFailedError() { http->logType = LOG_TCP_HIT; ErrorState *const err = - clientBuildError(ERR_PRECONDITION_FAILED, HTTP_PRECONDITION_FAILED, + clientBuildError(ERR_PRECONDITION_FAILED, Http::scPreconditionFailed, NULL, http->getConn()->clientConnection->remote, http->request); removeClientStoreReference(&sc, http); HTTPMSGUNLOCK(reply); @@ -1990,7 +1990,7 @@ clientReplyContext::processReplyAccessResult(const allow_t &accessAllowed) Ip::Address tmp_noaddr; tmp_noaddr.SetNoAddr(); - err = clientBuildError(page_id, HTTP_FORBIDDEN, NULL, + err = clientBuildError(page_id, Http::scForbidden, NULL, http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmp_noaddr, http->request); @@ -2018,7 +2018,7 @@ clientReplyContext::processReplyAccessResult(const allow_t &accessAllowed) #if USE_SQUID_ESI - if (http->flags.accel && reply->sline.status != HTTP_FORBIDDEN && + if (http->flags.accel && reply->sline.status != Http::scForbidden && !alwaysAllowResponse(reply->sline.status) && esiEnableProcessing(reply)) { debugs(88, 2, "Enabling ESI processing for " << http->uri); @@ -2214,7 +2214,7 @@ clientReplyContext::createStoreEntry(const HttpRequestMethod& m, RequestFlags re } ErrorState * -clientBuildError(err_type page_id, http_status status, char const *url, +clientBuildError(err_type page_id, Http::StatusCode status, char const *url, Ip::Address &src_addr, HttpRequest * request) { ErrorState *err = new ErrorState(page_id, status, request); diff --git a/src/client_side_reply.h b/src/client_side_reply.h index e8a87bfe03..90fec3db8c 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -75,7 +75,7 @@ public: /// replaces current response store entry with the given one void setReplyToStoreEntry(StoreEntry *e); /// builds error using clientBuildError() and calls setReplyToError() below - void setReplyToError(err_type, http_status, const HttpRequestMethod&, char const *, Ip::Address &, HttpRequest *, const char *, + void setReplyToError(err_type, Http::StatusCode, const HttpRequestMethod&, char const *, Ip::Address &, HttpRequest *, const char *, #if USE_AUTH Auth::UserRequest::Pointer); #else @@ -93,7 +93,7 @@ public: void traceReply(clientStreamNode * node); const char *storeId() const { return (http->store_id.size() > 0 ? http->store_id.termedBuf() : http->uri); } - http_status purgeStatus; + Http::StatusCode purgeStatus; /* state variable - replace with class to handle storeentries at some point */ int lookingforstore; @@ -135,7 +135,7 @@ private: void processReplyAccessResult(const allow_t &accessAllowed); void cloneReply(); void buildReplyHeader (); - bool alwaysAllowResponse(http_status sline) const; + bool alwaysAllowResponse(Http::StatusCode sline) const; int checkTransferDone(); void processOnlyIfCachedMiss(); void processConditional(StoreIOBuffer &result); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index d77846aa44..62f7418ade 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -103,7 +103,7 @@ static const char *const crlf = "\r\n"; static void clientFollowXForwardedForCheck(allow_t answer, void *data); #endif /* FOLLOW_X_FORWARDED_FOR */ -ErrorState *clientBuildError(err_type, http_status, char const *url, Ip::Address &, HttpRequest *); +ErrorState *clientBuildError(err_type, Http::StatusCode, char const *url, Ip::Address &, HttpRequest *); CBDATA_CLASS_INIT(ClientRequestContext); @@ -611,7 +611,7 @@ ClientRequestContext::hostHeaderVerifyFailed(const char *A, const char *B) clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->prev->data; clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_CONFLICT_HOST, HTTP_CONFLICT, + repContext->setReplyToError(ERR_CONFLICT_HOST, Http::scConflict, http->request->method, NULL, http->getConn()->clientConnection->remote, http->request, @@ -777,7 +777,7 @@ ClientRequestContext::clientAccessCheckDone(const allow_t &answer) { acl_checklist = NULL; err_type page_id; - http_status status; + Http::StatusCode status; debugs(85, 2, "The request " << RequestMethodStr(http->request->method) << " " << http->uri << " is " << answer << @@ -819,22 +819,22 @@ ClientRequestContext::clientAccessCheckDone(const allow_t &answer) #if USE_AUTH if (http->request->flags.sslBumped) { /*SSL Bumped request, authentication is not possible*/ - status = HTTP_FORBIDDEN; + status = Http::scForbidden; } else if (!http->flags.accel) { /* Proxy authorisation needed */ - status = HTTP_PROXY_AUTHENTICATION_REQUIRED; + status = Http::scProxyAuthenticationRequired; } else { /* WWW authorisation needed */ - status = HTTP_UNAUTHORIZED; + status = Http::scUnauthorized; } #else // need auth, but not possible to do. - status = HTTP_FORBIDDEN; + status = Http::scForbidden; #endif if (page_id == ERR_NONE) page_id = ERR_CACHE_ACCESS_DENIED; } else { - status = HTTP_FORBIDDEN; + status = Http::scForbidden; if (page_id == ERR_NONE) page_id = ERR_ACCESS_DENIED; @@ -1298,20 +1298,20 @@ 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_MOVED_TEMPORARILY) - // HTTP/1.1 client contacting reverse-proxy should get 307 (HTTP_TEMPORARY_REDIRECT) - // HTTP/1.1 client being diverted by forward-proxy should get 303 (HTTP_SEE_OTHER) - http_status status = HTTP_MOVED_TEMPORARILY; + // HTTP/1.0 client should get 302 (Http::scMovedTemporarily) + // 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; if (statusNote != NULL) { const char * result = statusNote->firstValue(); - status = (http_status) atoi(result); + status = static_cast(atoi(result)); } - if (status == HTTP_MOVED_PERMANENTLY - || status == HTTP_MOVED_TEMPORARILY - || status == HTTP_SEE_OTHER - || status == HTTP_PERMANENT_REDIRECT - || status == HTTP_TEMPORARY_REDIRECT) { + if (status == Http::scMovedPermanently + || status == Http::scMovedTemporarily + || status == Http::scSeeOther + || status == Http::scPermanentRedirect + || status == Http::scTemporaryRedirect) { http->redirect.status = status; http->redirect.location = xstrdup(urlNote->firstValue()); // TODO: validate the URL produced here is RFC 2616 compliant absolute URI @@ -1485,7 +1485,7 @@ ClientRequestContext::sslBumpAccessCheck() // Do not bump during authentication: clients would not proxy-authenticate // if we delay a 407 response and respond with 200 OK to CONNECT. - if (error && error->httpStatus == HTTP_PROXY_AUTHENTICATION_REQUIRED) { + if (error && error->httpStatus == Http::scProxyAuthenticationRequired) { http->al->ssl.bumpMode = Ssl::bumpEnd; // SslBump does not apply; log - debugs(85, 5, HERE << "no SslBump during proxy authentication"); return false; @@ -2083,7 +2083,7 @@ ClientHttpRequest::handleAdaptationFailure(int errDetail, bool bypassable) Ip::Address noAddr; noAddr.SetNoAddr(); ConnStateData * c = getConn(); - calloutContext->error = clientBuildError(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, + calloutContext->error = clientBuildError(ERR_ICAP_FAILURE, Http::scInternalServerError, NULL, c != NULL ? c->clientConnection->remote : noAddr, request diff --git a/src/client_side_request.h b/src/client_side_request.h index 406ea55a1e..eaa5f9211e 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -127,7 +127,7 @@ public: } flags; struct { - http_status status; + Http::StatusCode status; char *location; } redirect; diff --git a/src/errorpage.cc b/src/errorpage.cc index 2ea0226424..90c9560308 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -87,7 +87,7 @@ CBDATA_CLASS_INIT(ErrorState); typedef struct { int id; char *page_name; - http_status page_redirect; + Http::StatusCode page_redirect; } ErrorDynamicPageInfo; /* local constant and vars */ @@ -210,7 +210,7 @@ errorInitialize(void) assert(info && info->id == i && info->page_name); const char *pg = info->page_name; - if (info->page_redirect != HTTP_STATUS_NONE) + if (info->page_redirect != Http::scNone) pg = info->page_name +4; if (strchr(pg, ':') == NULL) { @@ -477,7 +477,7 @@ errorDynamicPageInfoCreate(int id, const char *page_name) ErrorDynamicPageInfo *info = new ErrorDynamicPageInfo; info->id = id; info->page_name = xstrdup(page_name); - info->page_redirect = static_cast(atoi(page_name)); + info->page_redirect = static_cast(atoi(page_name)); /* WARNING on redirection status: * 2xx are permitted, but not documented officially. @@ -490,7 +490,7 @@ errorDynamicPageInfoCreate(int id, const char *page_name) * - current result is Squid crashing or XSS problems as dynamic deny_info load random disk files. * - a future redesign of the file loading may result in loading remote objects sent inline as local body. */ - if (info->page_redirect == HTTP_STATUS_NONE) + if (info->page_redirect == Http::scNone) ; // special case okay. else if (info->page_redirect < 200 || info->page_redirect > 599) { // out of range @@ -568,7 +568,7 @@ errorPageName(int pageId) return "ERR_UNKNOWN"; /* should not happen */ } -ErrorState::ErrorState(err_type t, http_status status, HttpRequest * req) : +ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req) : type(t), page_id(t), err_language(NULL), @@ -595,7 +595,7 @@ ErrorState::ErrorState(err_type t, http_status status, HttpRequest * req) : { memset(&ftp, 0, sizeof(ftp)); - if (page_id >= ERR_MAX && ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect != HTTP_STATUS_NONE) + if (page_id >= ERR_MAX && ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect != Http::scNone) httpStatus = ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect; if (req != NULL) { @@ -1157,14 +1157,14 @@ ErrorState::BuildHttpReply() if (name[0] == '3' || (name[0] != '2' && name[0] != '4' && name[0] != '5' && strchr(name, ':'))) { /* Redirection */ - http_status status = HTTP_MOVED_TEMPORARILY; + Http::StatusCode status = Http::scMovedTemporarily; // Use configured 3xx reply status if set. if (name[0] == '3') status = httpStatus; else { // Use 307 for HTTP/1.1 non-GET/HEAD requests. if (request->method != Http::METHOD_GET && request->method != Http::METHOD_HEAD && request->http_ver >= HttpVersion(1,1)) - status = HTTP_TEMPORARY_REDIRECT; + status = Http::scTemporaryRedirect; } rep->setHeaders(status, NULL, "text/html", 0, 0, -1); diff --git a/src/errorpage.h b/src/errorpage.h index 46c15e8465..1c04b99c54 100644 --- a/src/errorpage.h +++ b/src/errorpage.h @@ -38,7 +38,7 @@ #include "comm/forward.h" #include "err_detail_type.h" #include "err_type.h" -#include "HttpStatusCode.h" +#include "http/StatusCode.h" #include "ip/Address.h" #include "SquidString.h" /* auth/UserRequest.h is empty unless USE_AUTH is defined */ @@ -97,7 +97,7 @@ class MemBuf; class ErrorState { public: - ErrorState(err_type type, http_status, HttpRequest * request); + ErrorState(err_type type, Http::StatusCode, HttpRequest * request); ErrorState(); // not implemented. ~ErrorState(); @@ -153,7 +153,7 @@ public: err_type type; int page_id; char *err_language; - http_status httpStatus; + Http::StatusCode httpStatus; #if USE_AUTH Auth::UserRequest::Pointer auth_user_request; #endif diff --git a/src/esi/Context.h b/src/esi/Context.h index baae3fdf97..779cfd1059 100644 --- a/src/esi/Context.h +++ b/src/esi/Context.h @@ -36,7 +36,7 @@ #include "esi/Element.h" #include "clientStream.h" #include "err_type.h" -#include "HttpStatusCode.h" +#include "http/StatusCode.h" class ESIVarState; class ClientHttpRequest; @@ -54,7 +54,7 @@ public: thisNode(NULL), http(NULL), errorpage(ERR_NONE), - errorstatus(HTTP_STATUS_NONE), + errorstatus(Http::scNone), errormessage(NULL), rep(NULL), outbound_offset(0), @@ -114,7 +114,7 @@ public: } flags; err_type errorpage; /* if we error what page to use */ - http_status errorstatus; /* if we error, what code to return */ + Http::StatusCode errorstatus; /* if we error, what code to return */ char *errormessage; /* error to pass to error page */ HttpReply *rep; /* buffered until we pass data downstream */ ESISegment::Pointer buffered; /* unprocessed data - for whatever reason */ diff --git a/src/esi/Esi.cc b/src/esi/Esi.cc index 7e54b1c051..af2b7f793c 100644 --- a/src/esi/Esi.cc +++ b/src/esi/Esi.cc @@ -296,7 +296,7 @@ void ESIContext::setError() { errorpage = ERR_ESI; - errorstatus = HTTP_INTERNAL_SERVER_ERROR; + errorstatus = Http::scInternalServerError; flags.error = 1; } @@ -541,21 +541,21 @@ esiStreamStatus (clientStreamNode *thisNode, ClientHttpRequest *http) } static int -esiAlwaysPassthrough(http_status sline) +esiAlwaysPassthrough(Http::StatusCode sline) { int result; switch (sline) { - case HTTP_CONTINUE: /* Should never reach us... but squid needs to alter to accomodate this */ + case Http::scContinue: /* Should never reach us... but squid needs to alter to accomodate this */ - case HTTP_SWITCHING_PROTOCOLS: /* Ditto */ + case Http::scSwitchingProtocols: /* Ditto */ - case HTTP_PROCESSING: /* Unknown - some extension */ + case Http::scProcessing: /* Unknown - some extension */ - case HTTP_NO_CONTENT: /* no body, no esi */ + case Http::scNoContent: /* no body, no esi */ - case HTTP_NOT_MODIFIED: /* ESI does not affect assembled page headers, so 304s are valid */ + case Http::scNotModified: /* ESI does not affect assembled page headers, so 304s are valid */ result = 1; /* unreached */ break; @@ -1451,7 +1451,7 @@ ESIContext::freeResources () /* don't touch incoming, it's a pointer into buffered anyway */ } -ErrorState *clientBuildError (err_type, http_status, char const *, Ip::Address &, HttpRequest *); +ErrorState *clientBuildError (err_type, Http::StatusCode, char const *, Ip::Address &, HttpRequest *); /* This can ONLY be used before we have sent *any* data to the client */ void diff --git a/src/esi/Include.cc b/src/esi/Include.cc index c62a24e9aa..837056e068 100644 --- a/src/esi/Include.cc +++ b/src/esi/Include.cc @@ -114,7 +114,7 @@ esiBufferRecipient (clientStreamNode *node, ClientHttpRequest *http, HttpReply * assert(rep == NULL); } else { if (rep) { - if (rep->sline.status != HTTP_OK) { + if (rep->sline.status != Http::scOkay) { rep = NULL; esiStream->include->includeFail (esiStream); esiStream->finished = 1; diff --git a/src/format/Format.cc b/src/format/Format.cc index 59f4fcdef5..fe8cf545c1 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -797,7 +797,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS break; case LFT_HTTP_RECEIVED_STATUS_CODE: - if (al->hier.peer_reply_status == HTTP_STATUS_NONE) { + if (al->hier.peer_reply_status == Http::scNone) { out = "-"; } else { outint = al->hier.peer_reply_status; diff --git a/src/forward.cc b/src/forward.cc index 3679dd1b27..18a357de02 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -93,7 +93,7 @@ static CNCB fwdConnectDoneWrapper; static OBJH fwdStats; #define MAX_FWD_STATS_IDX 9 -static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][HTTP_INVALID_HEADER + 1]; +static int FwdReplyCodes[MAX_FWD_STATS_IDX + 1][Http::scInvalidHeader + 1]; static PconnPool *fwdPconnPool = new PconnPool("server-side"); CBDATA_CLASS_INIT(FwdState); @@ -184,7 +184,7 @@ FwdState::selectPeerForIntercepted() serverDestinations.push_back(p); } else { debugs(17,2, "Pinned connection is not valid: " << p); - ErrorState *anErr = new ErrorState(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, request); + ErrorState *anErr = new ErrorState(ERR_ZERO_SIZE_OBJECT, Http::scServiceUnavailable, request); fail(anErr); } // Either use the valid pinned connection or fail if it is invalid. @@ -225,7 +225,7 @@ FwdState::completed() if (entry->store_status == STORE_PENDING) { if (entry->isEmpty()) { if (!err) // we quit (e.g., fd closed) before an error or content - fail(new ErrorState(ERR_READ_ERROR, HTTP_BAD_GATEWAY, request)); + fail(new ErrorState(ERR_READ_ERROR, Http::scBadGateway, request)); assert(err); errorAppendEntry(entry, err); err = NULL; @@ -312,7 +312,7 @@ FwdState::Start(const Comm::ConnectionPointer &clientConn, StoreEntry *entry, Ht if (page_id == ERR_NONE) page_id = ERR_FORWARDING_DENIED; - ErrorState *anErr = new ErrorState(page_id, HTTP_FORBIDDEN, request); + ErrorState *anErr = new ErrorState(page_id, Http::scForbidden, request); errorAppendEntry(entry, anErr); // frees anErr return; } @@ -332,7 +332,7 @@ FwdState::Start(const Comm::ConnectionPointer &clientConn, StoreEntry *entry, Ht if (shutting_down) { /* more yuck */ - ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request); + ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, Http::scServiceUnavailable, request); errorAppendEntry(entry, anErr); // frees anErr return; } @@ -389,7 +389,7 @@ FwdState::startConnectionOrFail() } else { debugs(17, 3, HERE << "Connection failed: " << entry->url()); if (!err) { - ErrorState *anErr = new ErrorState(ERR_CANNOT_FORWARD, HTTP_INTERNAL_SERVER_ERROR, request); + ErrorState *anErr = new ErrorState(ERR_CANNOT_FORWARD, Http::scInternalServerError, request); fail(anErr); } // else use actual error from last connection attempt self = NULL; // refcounted @@ -623,7 +623,7 @@ FwdState::retryOrBail() doneWithRetries(); if (self != NULL && !err && shutting_down) { - ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request); + ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, Http::scServiceUnavailable, request); errorAppendEntry(entry, anErr); } @@ -786,7 +786,7 @@ FwdState::negotiateSSL(int fd) " certificate: " << e.what() << "; will now block to " << "validate that certificate."); // fall through to do blocking in-process generation. - ErrorState *anErr = new ErrorState(ERR_GATEWAY_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); + ErrorState *anErr = new ErrorState(ERR_GATEWAY_FAILURE, Http::scInternalServerError, request); fail(anErr); if (serverConnection()->getPeer()) { peerConnectFailed(serverConnection()->getPeer()); @@ -831,7 +831,7 @@ FwdState::sslCrtvdHandleReply(Ssl::CertValidationResponse const &validationRespo ErrorState *anErr = NULL; if (validatorFailed) { - anErr = new ErrorState(ERR_GATEWAY_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); + anErr = new ErrorState(ERR_GATEWAY_FAILURE, Http::scInternalServerError, request); } else { // Check the list error with @@ -935,7 +935,7 @@ FwdState::initiateSSL() if ((ssl = SSL_new(sslContext)) == NULL) { debugs(83, DBG_IMPORTANT, "fwdInitiateSSL: Error allocating handle: " << ERR_error_string(ERR_get_error(), NULL) ); - ErrorState *anErr = new ErrorState(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); + ErrorState *anErr = new ErrorState(ERR_SOCKET_FAILURE, Http::scInternalServerError, request); // TODO: create Ssl::ErrorDetail with OpenSSL-supplied error code fail(anErr); self = NULL; // refcounted @@ -1056,7 +1056,7 @@ FwdState::connectTimeout(int fd) assert(fd == serverDestinations[0]->fd); if (entry->isEmpty()) { - ErrorState *anErr = new ErrorState(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, request); + ErrorState *anErr = new ErrorState(ERR_CONNECT_FAIL, Http::scGateway_Timeout, request); anErr->xerrno = ETIMEDOUT; fail(anErr); @@ -1104,7 +1104,7 @@ FwdState::connectStart() if (serverDestinations[0]->getPeer() && request->flags.sslBumped) { debugs(50, 4, "fwdConnectStart: Ssl bumped connections through parrent proxy are not allowed"); - ErrorState *anErr = new ErrorState(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request); + ErrorState *anErr = new ErrorState(ERR_CANNOT_FORWARD, Http::scServiceUnavailable, request); fail(anErr); self = NULL; // refcounted return; @@ -1139,7 +1139,7 @@ FwdState::connectStart() } // Pinned connection failure. debugs(17,2,HERE << "Pinned connection failed: " << pinned_connection); - ErrorState *anErr = new ErrorState(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, request); + ErrorState *anErr = new ErrorState(ERR_ZERO_SIZE_OBJECT, Http::scServiceUnavailable, request); fail(anErr); self = NULL; // refcounted return; @@ -1321,7 +1321,7 @@ FwdState::dispatch() default: debugs(17, DBG_IMPORTANT, "WARNING: Cannot retrieve '" << entry->url() << "'."); - ErrorState *anErr = new ErrorState(ERR_UNSUP_REQ, HTTP_BAD_REQUEST, request); + ErrorState *anErr = new ErrorState(ERR_UNSUP_REQ, Http::scBadRequest, request); fail(anErr); // Set the dont_retry flag because this is not a transient (network) error. flags.dont_retry = true; @@ -1345,7 +1345,6 @@ int FwdState::reforward() { StoreEntry *e = entry; - http_status s; if (EBIT_TEST(e->flags, ENTRY_ABORTED)) { debugs(17, 3, HERE << "entry aborted"); @@ -1381,7 +1380,7 @@ FwdState::reforward() return 0; } - s = e->getReply()->sline.status; + const Http::StatusCode s = e->getReply()->sline.status; debugs(17, 3, HERE << "status " << s); return reforwardableStatus(s); } @@ -1396,7 +1395,7 @@ ErrorState * FwdState::makeConnectingError(const err_type type) const { return new ErrorState(type, request->flags.needValidation ? - HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request); + Http::scGateway_Timeout : Http::scServiceUnavailable, request); } static void @@ -1412,7 +1411,7 @@ fwdStats(StoreEntry * s) storeAppendPrintf(s, "\n"); - for (i = 0; i <= (int) HTTP_INVALID_HEADER; ++i) { + for (i = 0; i <= (int) Http::scInvalidHeader; ++i) { if (FwdReplyCodes[0][i] == 0) continue; @@ -1429,22 +1428,22 @@ fwdStats(StoreEntry * s) /**** STATIC MEMBER FUNCTIONS *************************************************/ bool -FwdState::reforwardableStatus(http_status s) +FwdState::reforwardableStatus(const Http::StatusCode s) const { switch (s) { - case HTTP_BAD_GATEWAY: + case Http::scBadGateway: - case HTTP_GATEWAY_TIMEOUT: + case Http::scGateway_Timeout: return true; - case HTTP_FORBIDDEN: + case Http::scForbidden: - case HTTP_INTERNAL_SERVER_ERROR: + case Http::scInternalServerError: - case HTTP_NOT_IMPLEMENTED: + case Http::scNotImplemented: - case HTTP_SERVICE_UNAVAILABLE: + case Http::scServiceUnavailable: return Config.retry.onerror; default: @@ -1483,9 +1482,9 @@ FwdState::RegisterWithCacheManager(void) } void -FwdState::logReplyStatus(int tries, http_status status) +FwdState::logReplyStatus(int tries, const Http::StatusCode status) { - if (status > HTTP_INVALID_HEADER) + if (status > Http::scInvalidHeader) return; assert(tries >= 0); diff --git a/src/forward.h b/src/forward.h index aad16c21ac..dd59ac577d 100644 --- a/src/forward.h +++ b/src/forward.h @@ -7,7 +7,7 @@ #include "comm/Connection.h" #include "err_type.h" #include "fde.h" -#include "HttpStatusCode.h" +#include "http/StatusCode.h" #include "ip/Address.h" #if USE_SSL #include "ssl/support.h" @@ -65,7 +65,7 @@ public: void complete(); void handleUnregisteredServerEnd(); int reforward(); - bool reforwardableStatus(http_status s); + bool reforwardableStatus(const Http::StatusCode s) const; void serverClosed(int fd); void connectStart(); void connectDone(const Comm::ConnectionPointer & conn, comm_err_t status, int xerrno); @@ -100,7 +100,7 @@ private: #if STRICT_ORIGINAL_DST void selectPeerForIntercepted(); #endif - static void logReplyStatus(int tries, http_status status); + static void logReplyStatus(int tries, const Http::StatusCode status); void doneWithRetries(); void completed(); void retryOrBail(); diff --git a/src/ftp.cc b/src/ftp.cc index 8f512875b3..9c7e1c0007 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1919,16 +1919,16 @@ FtpStateData::loginFailed() if ((state == SENT_USER || state == SENT_PASS) && ctrl.replycode >= 400) { if (ctrl.replycode == 421 || ctrl.replycode == 426) { // 421/426 - Service Overload - retry permitted. - err = new ErrorState(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request); + err = new ErrorState(ERR_FTP_UNAVAILABLE, Http::scServiceUnavailable, fwd->request); } else if (ctrl.replycode >= 430 && ctrl.replycode <= 439) { // 43x - Invalid or Credential Error - retry challenge required. - err = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request); + err = new ErrorState(ERR_FTP_FORBIDDEN, Http::scUnauthorized, fwd->request); } else if (ctrl.replycode >= 530 && ctrl.replycode <= 539) { // 53x - Credentials Missing - retry challenge required if (password_url) // but they were in the URI! major fail. - err = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request); + err = new ErrorState(ERR_FTP_FORBIDDEN, Http::scForbidden, fwd->request); else - err = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request); + err = new ErrorState(ERR_FTP_FORBIDDEN, Http::scUnauthorized, fwd->request); } } @@ -3294,7 +3294,7 @@ FtpStateData::completedListing() { assert(entry); entry->lock(); - ErrorState ferr(ERR_DIR_LISTING, HTTP_OK, request); + ErrorState ferr(ERR_DIR_LISTING, Http::scOkay, request); ferr.ftp.listing = &listing; ferr.ftp.cwd_msg = xstrdup(cwd_message.size()? cwd_message.termedBuf() : ""); ferr.ftp.server_msg = ctrl.message; @@ -3516,12 +3516,12 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno) if (ctrl.replycode > 500) if (password_url) - ftperr = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request); + ftperr = new ErrorState(ERR_FTP_FORBIDDEN, Http::scForbidden, fwd->request); else - ftperr = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request); + ftperr = new ErrorState(ERR_FTP_FORBIDDEN, Http::scUnauthorized, fwd->request); else if (ctrl.replycode == 421) - ftperr = new ErrorState(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request); + ftperr = new ErrorState(ERR_FTP_UNAVAILABLE, Http::scServiceUnavailable, fwd->request); break; @@ -3529,7 +3529,7 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno) case SENT_RETR: if (ctrl.replycode == 550) - ftperr = new ErrorState(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND, fwd->request); + ftperr = new ErrorState(ERR_FTP_NOT_FOUND, Http::scNotFound, fwd->request); break; @@ -3540,16 +3540,16 @@ FtpStateData::failedErrorMessage(err_type error, int xerrno) break; case ERR_READ_TIMEOUT: - ftperr = new ErrorState(error, HTTP_GATEWAY_TIMEOUT, fwd->request); + ftperr = new ErrorState(error, Http::scGateway_Timeout, fwd->request); break; default: - ftperr = new ErrorState(error, HTTP_BAD_GATEWAY, fwd->request); + ftperr = new ErrorState(error, Http::scBadGateway, fwd->request); break; } if (ftperr == NULL) - ftperr = new ErrorState(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY, fwd->request); + ftperr = new ErrorState(ERR_FTP_FAILURE, Http::scBadGateway, fwd->request); ftperr->xerrno = xerrno; @@ -3584,7 +3584,7 @@ static void ftpSendReply(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - http_status http_code; + Http::StatusCode http_code; err_type err_code = ERR_NONE; debugs(9, 3, HERE << ftpState->entry->url() << ", code " << code); @@ -3594,13 +3594,13 @@ ftpSendReply(FtpStateData * ftpState) if (code == 226 || code == 250) { err_code = (ftpState->mdtm > 0) ? ERR_FTP_PUT_MODIFIED : ERR_FTP_PUT_CREATED; - http_code = (ftpState->mdtm > 0) ? HTTP_ACCEPTED : HTTP_CREATED; + http_code = (ftpState->mdtm > 0) ? Http::scAccepted : Http::scCreated; } else if (code == 227) { err_code = ERR_FTP_PUT_CREATED; - http_code = HTTP_CREATED; + http_code = Http::scCreated; } else { err_code = ERR_FTP_PUT_ERROR; - http_code = HTTP_INTERNAL_SERVER_ERROR; + http_code = Http::scInternalServerError; } ErrorState err(err_code, http_code, ftpState->request); @@ -3676,7 +3676,7 @@ FtpStateData::appendSuccessHeader() if (0 == getCurrentOffset()) { /* Full reply */ - reply->setHeaders(HTTP_OK, "Gatewaying", mime_type, theSize, mdtm, -2); + reply->setHeaders(Http::scOkay, "Gatewaying", mime_type, theSize, mdtm, -2); } else if (theSize < getCurrentOffset()) { /* * DPW 2007-05-04 @@ -3688,13 +3688,13 @@ FtpStateData::appendSuccessHeader() " current offset=" << getCurrentOffset() << ", but theSize=" << theSize << ". assuming full content response"); - reply->setHeaders(HTTP_OK, "Gatewaying", mime_type, theSize, mdtm, -2); + reply->setHeaders(Http::scOkay, "Gatewaying", mime_type, theSize, mdtm, -2); } else { /* Partial reply */ HttpHdrRangeSpec range_spec; range_spec.offset = getCurrentOffset(); range_spec.length = theSize - getCurrentOffset(); - reply->setHeaders(HTTP_PARTIAL_CONTENT, "Gatewaying", mime_type, theSize - getCurrentOffset(), mdtm, -2); + reply->setHeaders(Http::scPartialContent, "Gatewaying", mime_type, theSize - getCurrentOffset(), mdtm, -2); httpHeaderAddContRange(&reply->header, range_spec, theSize); } @@ -3730,7 +3730,7 @@ FtpStateData::haveParsedReplyHeaders() HttpReply * FtpStateData::ftpAuthRequired(HttpRequest * request, const char *realm) { - ErrorState err(ERR_CACHE_ACCESS_DENIED, HTTP_UNAUTHORIZED, request); + ErrorState err(ERR_CACHE_ACCESS_DENIED, Http::scUnauthorized, request); HttpReply *newrep = err.BuildHttpReply(); #if HAVE_AUTH_MODULE_BASIC /* add Authenticate header */ diff --git a/src/gopher.cc b/src/gopher.cc index ce165a9f3c..bd1df5112e 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -257,7 +257,7 @@ gopherMimeCreate(GopherStateData * gopherState) HttpReply *reply = new HttpReply; entry->buffer(); - reply->setHeaders(HTTP_OK, "Gatewaying", mime_type, -1, -1, -2); + reply->setHeaders(Http::scOkay, "Gatewaying", mime_type, -1, -1, -2); if (mime_enc) reply->header.putStr(HDR_CONTENT_ENCODING, mime_enc); @@ -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_GATEWAY_TIMEOUT, gopherState->fwd->request)); + gopherState->fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGateway_Timeout, gopherState->fwd->request)); if (Comm::IsConnOpen(io.conn)) io.conn->close(); @@ -804,13 +804,13 @@ gopherReadReply(const Comm::ConnectionPointer &conn, char *buf, size_t len, comm CommIoCbPtrFun(gopherReadReply, gopherState)); comm_read(conn, buf, read_sz, call); } else { - ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, gopherState->fwd->request); + ErrorState *err = new ErrorState(ERR_READ_ERROR, Http::scInternalServerError, gopherState->fwd->request); err->xerrno = xerrno; gopherState->fwd->fail(err); gopherState->serverConn->close(); } } else if (len == 0 && entry->isEmpty()) { - gopherState->fwd->fail(new ErrorState(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request)); + gopherState->fwd->fail(new ErrorState(ERR_ZERO_SIZE_OBJECT, Http::scServiceUnavailable, gopherState->fwd->request)); gopherState->serverConn->close(); } else if (len == 0) { /* Connection closed; retrieval done. */ @@ -854,7 +854,7 @@ gopherSendComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, if (errflag) { ErrorState *err; - err = new ErrorState(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request); + err = new ErrorState(ERR_WRITE_ERROR, Http::scServiceUnavailable, gopherState->fwd->request); err->xerrno = xerrno; err->port = gopherState->fwd->request->port; err->url = xstrdup(entry->url()); diff --git a/src/http.cc b/src/http.cc index 0f6084bff0..11739ff9d2 100644 --- a/src/http.cc +++ b/src/http.cc @@ -97,7 +97,7 @@ CBDATA_CLASS_INIT(HttpStateData); static const char *const crlf = "\r\n"; -static void httpMaybeRemovePublic(StoreEntry *, http_status); +static void httpMaybeRemovePublic(StoreEntry *, Http::StatusCode); static void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request, HttpHeader * hdr_out, const int we_do_ranges, const HttpStateFlags &); //Declared in HttpHeaderTools.cc @@ -182,14 +182,14 @@ 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_GATEWAY_TIMEOUT, fwd->request)); + fwd->fail(new ErrorState(ERR_READ_TIMEOUT, Http::scGateway_Timeout, fwd->request)); } serverConnection->close(); } static void -httpMaybeRemovePublic(StoreEntry * e, http_status status) +httpMaybeRemovePublic(StoreEntry * e, Http::StatusCode status) { int remove = 0; int forbidden = 0; @@ -200,33 +200,33 @@ httpMaybeRemovePublic(StoreEntry * e, http_status status) switch (status) { - case HTTP_OK: + case Http::scOkay: - case HTTP_NON_AUTHORITATIVE_INFORMATION: + case Http::scNonAuthoritativeInformation: - case HTTP_MULTIPLE_CHOICES: + case Http::scMultipleChoices: - case HTTP_MOVED_PERMANENTLY: + case Http::scMovedPermanently: - case HTTP_MOVED_TEMPORARILY: + case Http::scMovedTemporarily: - case HTTP_GONE: + case Http::scGone: - case HTTP_NOT_FOUND: + case Http::scNotFound: remove = 1; break; - case HTTP_FORBIDDEN: + case Http::scForbidden: - case HTTP_METHOD_NOT_ALLOWED: + case Http::scMethodNotAllowed: forbidden = 1; break; #if WORK_IN_PROGRESS - case HTTP_UNAUTHORIZED: + case Http::scUnauthorized: forbidden = 1; break; @@ -445,16 +445,16 @@ HttpStateData::cacheableReply() switch (rep->sline.status) { /* Responses that are cacheable */ - case HTTP_OK: + case Http::scOkay: - case HTTP_NON_AUTHORITATIVE_INFORMATION: + case Http::scNonAuthoritativeInformation: - case HTTP_MULTIPLE_CHOICES: + case Http::scMultipleChoices: - case HTTP_MOVED_PERMANENTLY: - case HTTP_PERMANENT_REDIRECT: + case Http::scMovedPermanently: + case Http::scPermanentRedirect: - case HTTP_GONE: + case Http::scGone: /* * Don't cache objects that need to be refreshed on next request, * unless we know how to refresh it. @@ -472,8 +472,8 @@ HttpStateData::cacheableReply() /* Responses that only are cacheable if the server says so */ - case HTTP_MOVED_TEMPORARILY: - case HTTP_TEMPORARY_REDIRECT: + case Http::scMovedTemporarily: + case Http::scTemporaryRedirect: if (rep->date <= 0) { debugs(22, 3, HERE << "NO because HTTP status " << rep->sline.status << " and Date missing/invalid"); return 0; @@ -490,29 +490,29 @@ HttpStateData::cacheableReply() /* Errors can be negatively cached */ - case HTTP_NO_CONTENT: + case Http::scNoContent: - case HTTP_USE_PROXY: + case Http::scUseProxy: - case HTTP_BAD_REQUEST: + case Http::scBadRequest: - case HTTP_FORBIDDEN: + case Http::scForbidden: - case HTTP_NOT_FOUND: + case Http::scNotFound: - case HTTP_METHOD_NOT_ALLOWED: + case Http::scMethodNotAllowed: - case HTTP_REQUEST_URI_TOO_LARGE: + case Http::scRequestUriTooLarge: - case HTTP_INTERNAL_SERVER_ERROR: + case Http::scInternalServerError: - case HTTP_NOT_IMPLEMENTED: + case Http::scNotImplemented: - case HTTP_BAD_GATEWAY: + case Http::scBadGateway: - case HTTP_SERVICE_UNAVAILABLE: + case Http::scServiceUnavailable: - case HTTP_GATEWAY_TIMEOUT: + case Http::scGateway_Timeout: debugs(22, 3, HERE << "MAYBE because HTTP status " << rep->sline.status); return -1; @@ -521,34 +521,34 @@ HttpStateData::cacheableReply() /* Some responses can never be cached */ - case HTTP_PARTIAL_CONTENT: /* Not yet supported */ + case Http::scPartialContent: /* Not yet supported */ - case HTTP_SEE_OTHER: + case Http::scSeeOther: - case HTTP_NOT_MODIFIED: + case Http::scNotModified: - case HTTP_UNAUTHORIZED: + case Http::scUnauthorized: - case HTTP_PROXY_AUTHENTICATION_REQUIRED: + case Http::scProxyAuthenticationRequired: - case HTTP_INVALID_HEADER: /* Squid header parsing error */ + case Http::scInvalidHeader: /* Squid header parsing error */ - case HTTP_HEADER_TOO_LARGE: + case Http::scHeaderTooLarge: - case HTTP_PAYMENT_REQUIRED: - case HTTP_NOT_ACCEPTABLE: - case HTTP_REQUEST_TIMEOUT: - case HTTP_CONFLICT: - case HTTP_LENGTH_REQUIRED: - case HTTP_PRECONDITION_FAILED: - case HTTP_REQUEST_ENTITY_TOO_LARGE: - case HTTP_UNSUPPORTED_MEDIA_TYPE: - case HTTP_UNPROCESSABLE_ENTITY: - case HTTP_LOCKED: - case HTTP_FAILED_DEPENDENCY: - case HTTP_INSUFFICIENT_STORAGE: - case HTTP_REQUESTED_RANGE_NOT_SATISFIABLE: - case HTTP_EXPECTATION_FAILED: + case Http::scPaymentRequired: + case Http::scNotAcceptable: + case Http::scRequestTimeout: + case Http::scConflict: + case Http::scLengthRequired: + case Http::scPreconditionFailed: + case Http::scRequestEntityTooLarge: + case Http::scUnsupportedMediaType: + case Http::scUnprocessableEntity: + case Http::scLocked: + case Http::scFailedDependency: + case Http::scInsufficientStorage: + case Http::scRequestedRangeNotSatisfied: + case Http::scExpectationFailed: debugs(22, 3, HERE << "NO because HTTP status " << rep->sline.status); return 0; @@ -696,7 +696,7 @@ HttpStateData::processReplyHeader() return; } - http_status error = HTTP_STATUS_NONE; + Http::StatusCode error = Http::scNone; HttpReply *newrep = new HttpReply; const bool parsed = newrep->parse(readBuf, eof, &error); @@ -704,7 +704,7 @@ HttpStateData::processReplyHeader() if (!parsed && readBuf->contentSize() > 5 && strncmp(readBuf->content(), "HTTP/", 5) != 0 && strncmp(readBuf->content(), "ICY", 3) != 0) { MemBuf *mb; HttpReply *tmprep = new HttpReply; - tmprep->setHeaders(HTTP_OK, "Gatewaying", NULL, -1, -1, -1); + tmprep->setHeaders(Http::scOkay, "Gatewaying", NULL, -1, -1, -1); tmprep->header.putExt("X-Transformed-From", "HTTP/0.9"); mb = tmprep->pack(); newrep->parse(mb, eof, &error); @@ -848,10 +848,10 @@ bool HttpStateData::peerSupportsConnectionPinning() const /*The peer supports connection pinning and the http reply status is not unauthorized, so the related connection can be pinned */ - if (rep->sline.status != HTTP_UNAUTHORIZED) + if (rep->sline.status != Http::scUnauthorized) return true; - /*The server respond with HTTP_UNAUTHORIZED and the peer configured + /*The server respond with Http::scUnauthorized and the peer configured with "connection-auth=on" we know that the peer supports pinned connections */ @@ -897,7 +897,7 @@ HttpStateData::haveParsedReplyHeaders() Ctx ctx = ctx_enter(entry->mem_obj->url); HttpReply *rep = finalReply(); - if (rep->sline.status == HTTP_PARTIAL_CONTENT && + if (rep->sline.status == Http::scPartialContent && rep->content_range) currentOffset = rep->content_range->spec.offset; @@ -1135,7 +1135,7 @@ HttpStateData::readReply(const CommIoCbParams &io) if (ignoreErrno(io.xerrno)) { flags.do_next_read = true; } else { - ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_BAD_GATEWAY, fwd->request); + ErrorState *err = new ErrorState(ERR_READ_ERROR, Http::scBadGateway, fwd->request); err->xerrno = io.xerrno; fwd->fail(err); flags.do_next_read = false; @@ -1260,12 +1260,12 @@ HttpStateData::continueAfterParsingHeader() if (flags.headers_parsed) { // parsed headers, possibly with errors // check for header parsing errors if (HttpReply *vrep = virginReply()) { - const http_status s = vrep->sline.status; + const Http::StatusCode s = vrep->sline.status; const HttpVersion &v = vrep->sline.version; - if (s == HTTP_INVALID_HEADER && v != HttpVersion(0,9)) { + if (s == Http::scInvalidHeader && v != HttpVersion(0,9)) { debugs(11, DBG_IMPORTANT, "WARNING: HTTP: Invalid Response: Bad header encountered from " << entry->url() << " AKA " << request->GetHost() << request->urlpath.termedBuf() ); error = ERR_INVALID_RESP; - } else if (s == HTTP_HEADER_TOO_LARGE) { + } else if (s == Http::scHeaderTooLarge) { fwd->dontRetry(true); error = ERR_TOO_BIG; } else { @@ -1290,7 +1290,7 @@ HttpStateData::continueAfterParsingHeader() assert(error != ERR_NONE); entry->reset(); - fwd->fail(new ErrorState(error, HTTP_BAD_GATEWAY, fwd->request)); + fwd->fail(new ErrorState(error, Http::scBadGateway, fwd->request)); flags.do_next_read = false; serverConnection->close(); return false; // quit on error @@ -1514,7 +1514,7 @@ HttpStateData::wroteLast(const CommIoCbParams &io) return; if (io.flag) { - ErrorState *err = new ErrorState(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request); + ErrorState *err = new ErrorState(ERR_WRITE_ERROR, Http::scBadGateway, fwd->request); err->xerrno = io.xerrno; fwd->fail(err); serverConnection->close(); @@ -2316,7 +2316,7 @@ HttpStateData::handleMoreRequestBodyAvailable() flags.abuse_detected = true; debugs(11, DBG_IMPORTANT, "http handleMoreRequestBodyAvailable: Likely proxy abuse detected '" << request->client_addr << "' -> '" << entry->url() << "'" ); - if (virginReply()->sline.status == HTTP_INVALID_HEADER) { + if (virginReply()->sline.status == Http::scInvalidHeader) { serverConnection->close(); return; } @@ -2337,7 +2337,7 @@ HttpStateData::handleRequestBodyProducerAborted() // We might also get here if client-side aborts, but then our response // should not matter because either client-side will provide its own or // there will be no response at all (e.g., if the the client has left). - ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, fwd->request); + ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, Http::scInternalServerError, fwd->request); err->detailError(ERR_DETAIL_SRV_REQMOD_REQ_BODY); fwd->fail(err); } diff --git a/src/http/Makefile.am b/src/http/Makefile.am index bff9700cad..73dfc89f72 100644 --- a/src/http/Makefile.am +++ b/src/http/Makefile.am @@ -5,10 +5,11 @@ noinst_LTLIBRARIES = libsquid-http.la libsquid_http_la_SOURCES = \ MethodType.cc \ - MethodType.h + MethodType.h \ + StatusCode.h MethodType.cc: MethodType.h $(top_srcdir)/src/mk-string-arrays.awk - ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk < $(srcdir)/MethodType.h | sed -e 's%METHOD_%%' | \ - sed -e 's%_C%-C%' >$@) || ($(RM) -f $@ && exit 1) + ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk < $(srcdir)/MethodType.h | \ + sed -e 's%METHOD_%%' -e 's%_C%-C%' >$@) || ($(RM) -f $@ && exit 1) CLEANFILES += MethodType.cc diff --git a/src/http/StatusCode.h b/src/http/StatusCode.h new file mode 100644 index 0000000000..b44bfe58a7 --- /dev/null +++ b/src/http/StatusCode.h @@ -0,0 +1,72 @@ +#ifndef _SQUID_SRC_HTTP_STATUSCODE_H +#define _SQUID_SRC_HTTP_STATUSCODE_H + +namespace Http { + +/** + * These basic HTTP reply status codes are defined by RFC 2616 unless otherwise stated. + */ +typedef enum { + scNone = 0, + scContinue = 100, + scSwitchingProtocols = 101, + scProcessing = 102, /**< RFC2518 section 10.1 */ + scOkay = 200, + scCreated = 201, + scAccepted = 202, + scNonAuthoritativeInformation = 203, + scNoContent = 204, + scResetContent = 205, + scPartialContent = 206, + scMultiStatus = 207, /**< RFC2518 section 10.2 */ + scMultipleChoices = 300, + scMovedPermanently = 301, + scMovedTemporarily = 302, + scSeeOther = 303, + scNotModified = 304, + scUseProxy = 305, + scTemporaryRedirect = 307, + scPermanentRedirect = 308, + scBadRequest = 400, + scUnauthorized = 401, + scPaymentRequired = 402, + scForbidden = 403, + scNotFound = 404, + scMethodNotAllowed = 405, + scNotAcceptable = 406, + scProxyAuthenticationRequired = 407, + scRequestTimeout = 408, + scConflict = 409, + scGone = 410, + scLengthRequired = 411, + scPreconditionFailed = 412, + scRequestEntityTooLarge = 413, + scRequestUriTooLarge = 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 */ + scPreconditionRequired = 428, /**< RFC6585 */ + scTooManyFields = 429, /**< RFC6585 */ + scRequestHeaderFieldsTooLarge = 431, /**< RFC6585 */ + scInternalServerError = 500, + scNotImplemented = 501, + scBadGateway = 502, + scServiceUnavailable = 503, + scGateway_Timeout = 504, + scHttpVersionNotSupported = 505, + scInsufficientStorage = 507, /**< RFC2518 section 10.6 */ + scNetworkAuthenticationRequired = 511, /**< RFC6585 */ + + // The 6xx codes below are for internal use only: Bad requests result + // in scBadRequest; bad responses in scGateway_Timeout. + + scInvalidHeader = 600, /**< Squid header parsing error */ + scHeaderTooLarge = 601 /* Header too large to process */ +} StatusCode; + +} // namespace Http + +#endif /* _SQUID_SRC_HTTP_STATUSCODE_H */ diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index c289e0a828..c34bac1cab 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -745,7 +745,7 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer receivedData) assert (0 != rep->sline.status); debugs(38, 3, "netdbExchangeHandleReply: reply status " << rep->sline.status); - if (HTTP_OK != rep->sline.status) { + if (Http::scOkay != rep->sline.status) { netdbExchangeDone(ex); return; } @@ -1232,7 +1232,7 @@ netdbBinaryExchange(StoreEntry * s) struct in_addr line_addr; s->buffer(); - reply->setHeaders(HTTP_OK, "OK", NULL, -1, squid_curtime, -2); + reply->setHeaders(Http::scOkay, "OK", NULL, -1, squid_curtime, -2); s->replaceHttpReply(reply); rec_sz = 0; rec_sz += 1 + sizeof(struct in_addr); @@ -1298,7 +1298,7 @@ netdbBinaryExchange(StoreEntry * s) memFree(buf, MEM_4K_BUF); #else - reply->setHeaders(HTTP_BAD_REQUEST, "Bad Request", NULL, -1, squid_curtime, -2); + reply->setHeaders(Http::scBadRequest, "Bad Request", NULL, -1, squid_curtime, -2); s->replaceHttpReply(reply); storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n"); #endif diff --git a/src/internal.cc b/src/internal.cc index 15ef9905e7..a151ddac31 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -48,7 +48,7 @@ /* called when we "miss" on an internal object; * generate known dynamic objects, - * return HTTP_NOT_FOUND for others + * return Http::scNotFound for others */ void internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest * request, StoreEntry * entry) @@ -68,7 +68,7 @@ internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest * request, #endif HttpReply *reply = new HttpReply; - reply->setHeaders(HTTP_NOT_FOUND, "Not Found", "text/plain", strlen(msgbuf), squid_curtime, -2); + reply->setHeaders(Http::scNotFound, "Not Found", "text/plain", strlen(msgbuf), squid_curtime, -2); entry->replaceHttpReply(reply); entry->append(msgbuf, strlen(msgbuf)); entry->complete(); @@ -77,7 +77,7 @@ internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest * request, } else { debugObj(76, 1, "internalStart: unknown request:\n", request, (ObjPackMethod) & httpRequestPack); - err = new ErrorState(ERR_INVALID_REQ, HTTP_NOT_FOUND, request); + err = new ErrorState(ERR_INVALID_REQ, Http::scNotFound, request); errorAppendEntry(entry, err); } } diff --git a/src/log/access_log.cc b/src/log/access_log.cc index a9907257c1..b4775bf9ca 100644 --- a/src/log/access_log.cc +++ b/src/log/access_log.cc @@ -253,7 +253,7 @@ HierarchyLogEntry::HierarchyLogEntry() : cd_lookup(LOOKUP_NONE), n_choices(0), n_ichoices(0), - peer_reply_status(HTTP_STATUS_NONE), + peer_reply_status(Http::scNone), peer_response_time(-1), total_response_time(-1), tcpServer(NULL), @@ -569,7 +569,7 @@ headersLog(int cs, int pq, const HttpRequestMethod& method, void *data) if (0 == pq) S = (unsigned short) rep->sline.status; else - S = (unsigned short) HTTP_STATUS_NONE; + S = (unsigned short) Http::scNone; logfileWrite(headerslog, &magic, sizeof(magic)); logfileWrite(headerslog, &M, sizeof(M)); diff --git a/src/mgr/Action.cc b/src/mgr/Action.cc index 0d7b659904..dcb2dc88cf 100644 --- a/src/mgr/Action.cc +++ b/src/mgr/Action.cc @@ -98,7 +98,7 @@ Mgr::Action::fillEntry(StoreEntry* entry, bool writeHttpHeader) if (writeHttpHeader) { HttpReply *rep = new HttpReply; - rep->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime); + rep->setHeaders(Http::scOkay, NULL, "text/plain", -1, squid_curtime, squid_curtime); // Allow cachemgr and other XHR scripts access to our version string const ActionParams ¶ms = command().params; if (params.httpOrigin.size() > 0) { diff --git a/src/mgr/Forwarder.cc b/src/mgr/Forwarder.cc index 921f64a4be..d7a754dcfd 100644 --- a/src/mgr/Forwarder.cc +++ b/src/mgr/Forwarder.cc @@ -69,14 +69,14 @@ void Mgr::Forwarder::handleError() { debugs(16, DBG_CRITICAL, "ERROR: uri " << entry->url() << " exceeds buffer size"); - sendError(new ErrorState(ERR_INVALID_URL, HTTP_REQUEST_URI_TOO_LARGE, httpRequest)); + sendError(new ErrorState(ERR_INVALID_URL, Http::scRequestUriTooLarge, httpRequest)); mustStop("long URI"); } void Mgr::Forwarder::handleTimeout() { - sendError(new ErrorState(ERR_LIFETIME_EXP, HTTP_REQUEST_TIMEOUT, httpRequest)); + sendError(new ErrorState(ERR_LIFETIME_EXP, Http::scRequestTimeout, httpRequest)); Ipc::Forwarder::handleTimeout(); } @@ -84,7 +84,7 @@ void Mgr::Forwarder::handleException(const std::exception& e) { if (entry != NULL && httpRequest != NULL && Comm::IsConnOpen(conn)) - sendError(new ErrorState(ERR_INVALID_RESP, HTTP_INTERNAL_SERVER_ERROR, httpRequest)); + sendError(new ErrorState(ERR_INVALID_RESP, Http::scInternalServerError, httpRequest)); Ipc::Forwarder::handleException(e); } diff --git a/src/mgr/Inquirer.cc b/src/mgr/Inquirer.cc index 3be8323799..8475857ec0 100644 --- a/src/mgr/Inquirer.cc +++ b/src/mgr/Inquirer.cc @@ -76,7 +76,7 @@ Mgr::Inquirer::start() LOCAL_ARRAY(char, url, MAX_URL); snprintf(url, MAX_URL, "%s", aggrAction->command().params.httpUri.termedBuf()); HttpRequest *req = HttpRequest::CreateFromUrl(url); - ErrorState err(ERR_INVALID_URL, HTTP_NOT_FOUND, req); + ErrorState err(ERR_INVALID_URL, Http::scNotFound, req); #if HAVE_UNIQUE_PTR std::unique_ptr reply(err.BuildHttpReply()); #else @@ -89,7 +89,7 @@ Mgr::Inquirer::start() #else std::auto_ptr reply(new HttpReply); #endif - reply->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime); + reply->setHeaders(Http::scOkay, NULL, "text/plain", -1, squid_curtime, squid_curtime); reply->header.putStr(HDR_CONNECTION, "close"); // until we chunk response replyBuf.reset(reply->pack()); } diff --git a/src/mime.cc b/src/mime.cc index 36f3eb03b2..db5dc4d59d 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -425,7 +425,7 @@ MimeIcon::created (StoreEntry *newEntry) HttpReply *reply = new HttpReply; - reply->setHeaders(HTTP_OK, NULL, mimeGetContentType(icon_), sb.st_size, sb.st_mtime, -1); + reply->setHeaders(Http::scOkay, NULL, mimeGetContentType(icon_), sb.st_size, sb.st_mtime, -1); reply->cache_control = new HttpHdrCc(); reply->cache_control->maxAge(86400); reply->header.putCc(reply->cache_control); diff --git a/src/peer_digest.cc b/src/peer_digest.cc index ea817c1c96..749bff28c8 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -546,7 +546,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) return -1; if ((hdr_size = headersEnd(buf, size))) { - http_status status; + Http::StatusCode status; HttpReply const *reply = fetch->entry->getReply(); assert(reply); assert (reply->sline.status != 0); @@ -557,7 +557,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) /* this "if" is based on clientHandleIMSReply() */ - if (status == HTTP_NOT_MODIFIED) { + if (status == Http::scNotModified) { /* our old entry is fine */ assert(fetch->old_entry); @@ -586,7 +586,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) /* preserve request -- we need its size to update counters */ /* requestUnlink(r); */ /* fetch->entry->mem_obj->request = NULL; */ - } else if (status == HTTP_OK) { + } else if (status == Http::scOkay) { /* get rid of old entry if any */ if (fetch->old_entry) { @@ -604,7 +604,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) /* must have a ready-to-use store entry if we got here */ /* can we stay with the old in-memory digest? */ - if (status == HTTP_NOT_MODIFIED && fetch->pd->cd) { + if (status == Http::scNotModified && fetch->pd->cd) { peerDigestFetchStop(fetch, buf, "Not modified"); fetch->state = DIGEST_READ_DONE; } else { @@ -640,7 +640,7 @@ peerDigestSwapInHeaders(void *data, char *buf, ssize_t size) assert(fetch->entry->getReply()); assert (fetch->entry->getReply()->sline.status != 0); - if (fetch->entry->getReply()->sline.status != HTTP_OK) { + if (fetch->entry->getReply()->sline.status != Http::scOkay) { debugs(72, DBG_IMPORTANT, "peerDigestSwapInHeaders: " << fetch->pd->host << " status " << fetch->entry->getReply()->sline.status << " got cached!"); diff --git a/src/peer_select.cc b/src/peer_select.cc index e6897f0c7f..897a06fe67 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -374,7 +374,7 @@ peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, v delete psstate->lastError; psstate->lastError = NULL; if (fs->code == HIER_DIRECT) { - psstate->lastError = new ErrorState(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, psstate->request); + psstate->lastError = new ErrorState(ERR_DNS_FAIL, Http::scServiceUnavailable, psstate->request); psstate->lastError->dnsError = details.error; } } diff --git a/src/redirect.cc b/src/redirect.cc index a8ced0fbb0..2f0cf74c68 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -113,17 +113,17 @@ redirectHandleReply(void *data, const HelperReply &reply) * When Bug 1961 is resolved and urlParse has a const API, this needs to die. */ const char * result = reply.other().content(); - const http_status status = (http_status) atoi(result); + const Http::StatusCode status = static_cast(atoi(result)); HelperReply newReply; newReply.result = reply.result; newReply.notes = reply.notes; - if (status == HTTP_MOVED_PERMANENTLY - || status == HTTP_MOVED_TEMPORARILY - || status == HTTP_SEE_OTHER - || status == HTTP_PERMANENT_REDIRECT - || status == HTTP_TEMPORARY_REDIRECT) { + if (status == Http::scMovedPermanently + || status == Http::scMovedTemporarily + || status == Http::scSeeOther + || status == Http::scPermanentRedirect + || status == Http::scTemporaryRedirect) { if (const char *t = strchr(result, ':')) { char statusBuf[4]; @@ -219,7 +219,7 @@ constructHelperQuery(const char *name, helper *hlp, HLPCB *replyHandler, ClientH const char *fqdn; char buf[MAX_REDIRECTOR_REQUEST_STRLEN]; int sz; - http_status status; + Http::StatusCode status; char claddr[MAX_IPSTRLEN]; char myaddr[MAX_IPSTRLEN]; @@ -282,10 +282,10 @@ constructHelperQuery(const char *name, helper *hlp, HLPCB *replyHandler, ClientH if ((sz<=0) || (sz>=MAX_REDIRECTOR_REQUEST_STRLEN)) { if (sz<=0) { - status = HTTP_INTERNAL_SERVER_ERROR; + status = Http::scInternalServerError; debugs(61, DBG_CRITICAL, "ERROR: Gateway Failure. Can not build request to be passed to " << name << ". Request ABORTED."); } else { - status = HTTP_REQUEST_URI_TOO_LARGE; + status = Http::scRequestUriTooLarge; 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/store.cc b/src/store.cc index 781170f449..2df2322480 100644 --- a/src/store.cc +++ b/src/store.cc @@ -776,7 +776,7 @@ StoreEntry::setPublicKey() StoreEntry *pe = storeCreateEntry(mem_obj->url, mem_obj->log_url, request->flags, request->method); /* We are allowed to do this typecast */ HttpReply *rep = new HttpReply; - rep->setHeaders(HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); + rep->setHeaders(Http::scOkay, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); vary = mem_obj->getReply()->header.getList(HDR_VARY); if (vary.size()) { @@ -1402,10 +1402,10 @@ StoreEntry::validLength() const return 1; } - if (reply->sline.status == HTTP_NOT_MODIFIED) + if (reply->sline.status == Http::scNotModified) return 1; - if (reply->sline.status == HTTP_NO_CONTENT) + if (reply->sline.status == Http::scNoContent) return 1; diff = reply->hdr_sz + reply->content_length - objectLen(); diff --git a/src/store_digest.cc b/src/store_digest.cc index 6420d82df7..f8b2cca2e0 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -424,7 +424,7 @@ storeDigestRewriteResume(void) e->setPublicKey(); /* fake reply */ HttpReply *rep = new HttpReply; - rep->setHeaders(HTTP_OK, "Cache Digest OK", + rep->setHeaders(Http::scOkay, "Cache Digest OK", "application/cache-digest", (store_digest->mask_size + sizeof(sd_state.cblock)), squid_curtime, (squid_curtime + Config.digest.rewrite_period) ); debugs(71, 3, "storeDigestRewrite: entry expires on " << rep->expires << diff --git a/src/tests/stub_HttpReply.cc b/src/tests/stub_HttpReply.cc index f21b6f3ccc..21eff0fd7e 100644 --- a/src/tests/stub_HttpReply.cc +++ b/src/tests/stub_HttpReply.cc @@ -9,11 +9,11 @@ HttpReply::HttpReply() : HttpMsg(hoReply), date (0), last_modified (0), protoPrefix("HTTP/"), bodySizeMax(-2) STUB_NOP HttpReply::~HttpReply() STUB - void HttpReply::setHeaders(http_status status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires_) STUB + void HttpReply::setHeaders(Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires_) STUB void HttpReply::packHeadersInto(Packer * p) const STUB void HttpReply::reset() STUB void httpBodyPackInto(const HttpBody * body, Packer * p) STUB - bool HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error) STUB_RETVAL(false) + bool HttpReply::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false) int HttpReply::httpMsgParseError() STUB_RETVAL(0) bool HttpReply::expectingBody(const HttpRequestMethod&, int64_t&) const STUB_RETVAL(false) void HttpReply::packFirstLineInto(Packer * p, bool) const STUB diff --git a/src/tests/stub_HttpRequest.cc b/src/tests/stub_HttpRequest.cc index 79187fcc1f..ac5df4cdaf 100644 --- a/src/tests/stub_HttpRequest.cc +++ b/src/tests/stub_HttpRequest.cc @@ -9,7 +9,7 @@ HttpRequest::HttpRequest() : HttpMsg(hoRequest) STUB HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) STUB HttpRequest::~HttpRequest() STUB void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const STUB - bool HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error) STUB_RETVAL(false) + bool HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, Http::StatusCode *error) STUB_RETVAL(false) void HttpRequest::hdrCacheInit() STUB void HttpRequest::reset() STUB bool HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t&) const STUB_RETVAL(false) diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index 2d47acc37d..72752186b8 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -193,7 +193,7 @@ testCoss::testCossSearch() flags.cachable = true; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const - rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); + rep->setHeaders(Http::scOkay, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000); pe->setPublicKey(); diff --git a/src/tests/testHttpParser.cc b/src/tests/testHttpParser.cc index 90b97dcb46..5dde9b28d2 100644 --- a/src/tests/testHttpParser.cc +++ b/src/tests/testHttpParser.cc @@ -39,7 +39,7 @@ testHttpParser::testParseRequestLineProtocols() input.append("GET /\r\n", 7); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET /\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -60,7 +60,7 @@ testHttpParser::testParseRequestLineProtocols() input.append("POST /\r\n", 7); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET /\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -81,7 +81,7 @@ testHttpParser::testParseRequestLineProtocols() input.append("GET / HTTP/1.0\r\n", 16); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.0\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -102,7 +102,7 @@ testHttpParser::testParseRequestLineProtocols() input.append("GET / HTTP/1.1\r\n", 16); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -124,7 +124,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.2\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -147,7 +147,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/10.12\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -171,14 +171,14 @@ testHttpParser::testParseRequestLineProtocols() output.reset(input.content(), input.contentSize()); #if USE_HTTP_VIOLATIONS CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(12, output.req.u_end); CPPUNIT_ASSERT(memcmp("/ FOO/1.0", &output.buf[output.req.u_start],(output.req.u_end-output.req.u_start+1)) == 0); CPPUNIT_ASSERT_EQUAL(0, output.req.v_maj); CPPUNIT_ASSERT_EQUAL(9, output.req.v_min); #else CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(4, output.req.u_end); CPPUNIT_ASSERT(memcmp("/", &output.buf[output.req.u_start],(output.req.u_end-output.req.u_start+1)) == 0); CPPUNIT_ASSERT_EQUAL(0, output.req.v_maj); @@ -201,7 +201,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -223,7 +223,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -245,7 +245,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/11\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -267,7 +267,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/-999999.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -289,7 +289,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -311,7 +311,7 @@ testHttpParser::testParseRequestLineProtocols() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_HTTP_VERSION_NOT_SUPPORTED, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scHttpVersionNotSupported, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.-999999\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -344,7 +344,7 @@ testHttpParser::testParseRequestLineStrange() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -366,7 +366,7 @@ testHttpParser::testParseRequestLineStrange() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET /fo o/ HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -388,7 +388,7 @@ testHttpParser::testParseRequestLineStrange() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-5, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -421,7 +421,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -443,7 +443,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-2, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -467,7 +467,7 @@ testHttpParser::testParseRequestLineTerminators() Config.onoff.relaxed_header_parser = 1; // Being tolerant we can ignore and elide these apparently benign CR CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\r\r\r\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -491,7 +491,7 @@ testHttpParser::testParseRequestLineTerminators() // strict mode treats these as several bare-CR in the request line which is explicitly invalid. Config.onoff.relaxed_header_parser = 0; CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); @@ -511,7 +511,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1 \n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -533,7 +533,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(0, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_STATUS_NONE, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scNone, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); @@ -550,7 +550,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(0, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_STATUS_NONE, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scNone, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); @@ -567,7 +567,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(0, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_STATUS_NONE, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scNone, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); @@ -584,7 +584,7 @@ testHttpParser::testParseRequestLineTerminators() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(0, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_STATUS_NONE, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scNone, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); @@ -613,7 +613,7 @@ testHttpParser::testParseRequestLineMethods() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp(". / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -635,7 +635,7 @@ testHttpParser::testParseRequestLineMethods() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("OPTIONS * HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -657,7 +657,7 @@ testHttpParser::testParseRequestLineMethods() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("HELLOWORLD / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -679,7 +679,7 @@ testHttpParser::testParseRequestLineMethods() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("A\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -697,7 +697,7 @@ testHttpParser::testParseRequestLineMethods() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -717,7 +717,7 @@ testHttpParser::testParseRequestLineMethods() output.reset(input.content(), input.contentSize()); Config.onoff.relaxed_header_parser = 1; CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(1, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -740,7 +740,7 @@ testHttpParser::testParseRequestLineMethods() output.reset(input.content(), input.contentSize()); Config.onoff.relaxed_header_parser = 0; CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp(" GET / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -759,7 +759,7 @@ testHttpParser::testParseRequestLineMethods() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("\tGET / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -793,7 +793,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("/ HTTP/1.0\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -816,7 +816,7 @@ testHttpParser::testParseRequestLineInvalid() // When tolerantly ignoring SP prefix this case becomes ambiguous with HTTP/0.9 simple-request) Config.onoff.relaxed_header_parser = 1; CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(1, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("/ HTTP/1.0\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -839,7 +839,7 @@ testHttpParser::testParseRequestLineInvalid() // When tolerantly ignoring SP prefix this case becomes ambiguous with HTTP/0.9 simple-request) Config.onoff.relaxed_header_parser = 0; CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp(" / HTTP/1.0\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -858,7 +858,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: %d-%d/%d '%.*s'\n", output.req.start, output.req.end, input.contentSize(), 16, input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET\x0B / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -881,7 +881,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); @@ -899,7 +899,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: %d-%d/%d '%.*s'\n", output.req.start, output.req.end, input.contentSize(), 16, input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET\0 / HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -921,7 +921,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -942,7 +942,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: '%s'\n",input.content()); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_OK, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scOkay, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("GET HTTP/1.1\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -963,7 +963,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: binary-line\n"); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("\xB\xC\xE\xF\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -984,7 +984,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: mixed whitespace\n"); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL((int)input.contentSize()-1, output.req.end); CPPUNIT_ASSERT(memcmp("\t \t \t\n", &output.buf[output.req.start],(output.req.end-output.req.start+1)) == 0); @@ -1006,7 +1006,7 @@ testHttpParser::testParseRequestLineInvalid() //printf("TEST: mixed whitespace with CR\n"); output.reset(input.content(), input.contentSize()); CPPUNIT_ASSERT_EQUAL(-1, HttpParserParseReqLine(&output)); - CPPUNIT_ASSERT_EQUAL(HTTP_BAD_REQUEST, output.request_parse_status); + CPPUNIT_ASSERT_EQUAL(Http::scBadRequest, output.request_parse_status); CPPUNIT_ASSERT_EQUAL(0, output.req.start); CPPUNIT_ASSERT_EQUAL(-1, output.req.end); CPPUNIT_ASSERT_EQUAL(-1, output.req.m_start); diff --git a/src/tests/testHttpReply.cc b/src/tests/testHttpReply.cc index 9f731ec4c8..2510b02f1b 100644 --- a/src/tests/testHttpReply.cc +++ b/src/tests/testHttpReply.cc @@ -45,7 +45,7 @@ testHttpReply::testSanityCheckFirstLine() { MemBuf input; HttpReply engine; - http_status error = HTTP_STATUS_NONE; + Http::StatusCode error = Http::scNone; size_t hdr_len; input.init(); @@ -53,41 +53,41 @@ testHttpReply::testSanityCheckFirstLine() input.append("HTTP/1.1 200 Okay\n\n", 19); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( 1 && engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 200 Okay \n\n", 28); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( 2 && engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; #if TODO // these cases are only checked after parse... // invalid status line input.append("HTTP/1.1 999 Okay\n\n", 19); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( 3 && !engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 2000 Okay \n\n", 29); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( 4 && engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; #endif // valid ICY protocol status line input.append("ICY 200 Okay\n\n", 14); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; /* NP: the engine saves details about the protocol. even when being reset :( */ engine.protoPrefix="HTTP/"; engine.reset(); @@ -96,110 +96,110 @@ testHttpReply::testSanityCheckFirstLine() input.append("\n\n", 2); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( 5 && !engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append(" \n\n", 8); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT( 6 && !engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // status line with no message input.append("HTTP/1.1 200\n\n", 14); /* real case seen */ hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 200 \n\n", 15); /* real case seen */ hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // incomplete (short) status lines... not sane (yet), but no error either. input.append("H", 1); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/", 5); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1", 6); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1", 8); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 ", 9); /* real case seen */ hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 20", 14); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // status line with no status input.append("HTTP/1.1 \n\n", 11); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 \n\n", 15); hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("HTTP/1.1 Okay\n\n", 16); /* real case seen */ hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // status line with nul-byte input.append("HTTP/1.1\0200 Okay\n\n", 19); /* real case seen */ hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // status line with negative status input.append("HTTP/1.1 -000\n\n", 15); /* real case seen */ hdr_len = headersEnd(input.content(),input.contentSize()); CPPUNIT_ASSERT(!engine.sanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; } diff --git a/src/tests/testHttpRequest.cc b/src/tests/testHttpRequest.cc index 72f4569b37..1f1ce12faf 100644 --- a/src/tests/testHttpRequest.cc +++ b/src/tests/testHttpRequest.cc @@ -15,7 +15,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( testHttpRequest ); class PrivateHttpRequest : public HttpRequest { public: - bool doSanityCheckStartLine(MemBuf *b, const size_t h, http_status *e) { return sanityCheckStartLine(b,h,e); }; + bool doSanityCheckStartLine(MemBuf *b, const size_t h, Http::StatusCode *e) { return sanityCheckStartLine(b,h,e); }; }; /* init memory pools */ @@ -150,7 +150,7 @@ testHttpRequest::testSanityCheckStartLine() { MemBuf input; PrivateHttpRequest engine; - http_status error = HTTP_STATUS_NONE; + Http::StatusCode error = Http::scNone; size_t hdr_len; input.init(); @@ -158,31 +158,31 @@ testHttpRequest::testSanityCheckStartLine() input.append("GET / HTTP/1.1\n\n", 16); hdr_len = headersEnd(input.content(), input.contentSize()); CPPUNIT_ASSERT(engine.doSanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("GET / HTTP/1.1\n\n", 18); hdr_len = headersEnd(input.content(), input.contentSize()); CPPUNIT_ASSERT(engine.doSanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // strange but valid methods input.append(". / HTTP/1.1\n\n", 14); hdr_len = headersEnd(input.content(), input.contentSize()); CPPUNIT_ASSERT(engine.doSanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; input.append("OPTIONS * HTTP/1.1\n\n", 20); hdr_len = headersEnd(input.content(), input.contentSize()); CPPUNIT_ASSERT(engine.doSanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); + CPPUNIT_ASSERT_EQUAL(error, Http::scNone); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; // TODO no method @@ -197,7 +197,7 @@ testHttpRequest::testSanityCheckStartLine() input.append(" \n\n", 8); hdr_len = headersEnd(input.content(), input.contentSize()); CPPUNIT_ASSERT(!engine.doSanityCheckStartLine(&input, hdr_len, &error) ); - CPPUNIT_ASSERT_EQUAL(error, HTTP_INVALID_HEADER); + CPPUNIT_ASSERT_EQUAL(error, Http::scInvalidHeader); input.reset(); - error = HTTP_STATUS_NONE; + error = Http::scNone; } diff --git a/src/tests/testRock.cc b/src/tests/testRock.cc index da5cfcaad2..a15e3faf32 100644 --- a/src/tests/testRock.cc +++ b/src/tests/testRock.cc @@ -180,7 +180,7 @@ testRock::createEntry(const int i) StoreEntry *const pe = storeCreateEntry(url, "dummy log url", flags, Http::METHOD_GET); HttpReply *const rep = const_cast(pe->getReply()); - rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000); + rep->setHeaders(Http::scOkay, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000); pe->setPublicKey(); diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index 60eccaa204..7e8563fc9a 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -146,7 +146,7 @@ testUfs::testUfsSearch() flags.cachable = true; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, Http::METHOD_GET); HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const - rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000); + rep->setHeaders(Http::scOkay, "dummy test object", "x-squid-internal/test", 0, -1, squid_curtime + 100000); pe->setPublicKey(); diff --git a/src/tunnel.cc b/src/tunnel.cc index f3bfd8e217..34a4fda03f 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -505,7 +505,7 @@ TunnelStateData::copyRead(Connection &from, IOCB *completion) static void tunnelStartShoveling(TunnelStateData *tunnelState) { - *tunnelState->status_ptr = HTTP_OK; + *tunnelState->status_ptr = Http::scOkay; if (cbdataReferenceValid(tunnelState)) { tunnelState->copyRead(tunnelState->server, TunnelStateData::ReadServer); tunnelState->copyRead(tunnelState->client, TunnelStateData::ReadClient); @@ -524,7 +524,7 @@ tunnelConnectedWriteDone(const Comm::ConnectionPointer &conn, char *buf, size_t debugs(26, 3, HERE << conn << ", flag=" << flag); if (flag != COMM_OK) { - *tunnelState->status_ptr = HTTP_INTERNAL_SERVER_ERROR; + *tunnelState->status_ptr = Http::scInternalServerError; tunnelErrorComplete(conn->fd, data, 0); return; } @@ -597,8 +597,8 @@ tunnelConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int xe AsyncJob::Start(cs); } else { debugs(26, 4, HERE << "terminate with error."); - ErrorState *err = new ErrorState(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, tunnelState->request); - *tunnelState->status_ptr = HTTP_SERVICE_UNAVAILABLE; + ErrorState *err = new ErrorState(ERR_CONNECT_FAIL, Http::scServiceUnavailable, tunnelState->request); + *tunnelState->status_ptr = Http::scServiceUnavailable; err->xerrno = xerrno; // on timeout is this still: err->xerrno = ETIMEDOUT; err->port = conn->remote.GetPort(); @@ -670,8 +670,8 @@ tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr) ch.my_addr = request->my_addr; if (ch.fastCheck() == ACCESS_DENIED) { debugs(26, 4, HERE << "MISS access forbidden."); - err = new ErrorState(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN, request); - *status_ptr = HTTP_FORBIDDEN; + err = new ErrorState(ERR_FORWARDING_DENIED, Http::scForbidden, request); + *status_ptr = Http::scForbidden; errorSend(http->getConn()->clientConnection, err); return; } @@ -747,7 +747,7 @@ tunnelPeerSelectComplete(Comm::ConnectionList *peer_paths, ErrorState *err, void if (peer_paths == NULL || peer_paths->size() < 1) { debugs(26, 3, HERE << "No paths found. Aborting CONNECT"); if (!err) { - err = new ErrorState(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, tunnelState->request); + err = new ErrorState(ERR_CANNOT_FORWARD, Http::scServiceUnavailable, tunnelState->request); } *tunnelState->status_ptr = err->httpStatus; err->callback = tunnelErrorComplete; diff --git a/src/urn.cc b/src/urn.cc index bbd61fd712..a85ccb8a7c 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -223,7 +223,7 @@ UrnState::setUriResFromRequest(HttpRequest *r) if (urlres_r == NULL) { debugs(52, 3, "urnStart: Bad uri-res URL " << urlres); - ErrorState *err = new ErrorState(ERR_URN_RESOLVE, HTTP_NOT_FOUND, r); + ErrorState *err = new ErrorState(ERR_URN_RESOLVE, Http::scNotFound, r); err->url = urlres; urlres = NULL; errorAppendEntry(entry, err); @@ -374,9 +374,9 @@ urnHandleReply(void *data, StoreIOBuffer result) rep->parseCharBuf(buf, k); debugs(52, 3, "reply exists, code=" << rep->sline.status << "."); - if (rep->sline.status != HTTP_OK) { + if (rep->sline.status != Http::scOkay) { debugs(52, 3, "urnHandleReply: failed."); - err = new ErrorState(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request); + err = new ErrorState(ERR_URN_RESOLVE, Http::scNotFound, urnState->request); err->url = xstrdup(e->url()); errorAppendEntry(e, err); delete rep; @@ -398,7 +398,7 @@ urnHandleReply(void *data, StoreIOBuffer result) if (urls == NULL) { /* unkown URN error */ debugs(52, 3, "urnTranslateDone: unknown URN " << e->url() ); - err = new ErrorState(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request); + err = new ErrorState(ERR_URN_RESOLVE, Http::scNotFound, urnState->request); err->url = xstrdup(e->url()); errorAppendEntry(e, err); urnHandleReplyError(urnState, urlres_e); @@ -439,7 +439,7 @@ urnHandleReply(void *data, StoreIOBuffer result) "\n", APP_FULLNAME, getMyHostname()); rep = new HttpReply; - rep->setHeaders(HTTP_MOVED_TEMPORARILY, NULL, "text/html", mb->contentSize(), 0, squid_curtime); + rep->setHeaders(Http::scMovedTemporarily, NULL, "text/html", mb->contentSize(), 0, squid_curtime); if (urnState->flags.force_menu) { debugs(51, 3, "urnHandleReply: forcing menu"); diff --git a/src/whois.cc b/src/whois.cc index 35bde794f9..f163fea2e2 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -139,7 +139,7 @@ WhoisState::setReplyToOK(StoreEntry *sentry) { HttpReply *reply = new HttpReply; sentry->buffer(); - reply->setHeaders(HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2); + reply->setHeaders(Http::scOkay, "Gatewaying", "text/plain", -1, -1, -2); sentry->replaceHttpReply(reply); } @@ -162,7 +162,7 @@ WhoisState::readReply(const Comm::ConnectionPointer &conn, char *aBuffer, size_t CommIoCbPtrFun(whoisReadReply, this)); comm_read(conn, aBuffer, BUFSIZ, call); } else { - ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, fwd->request); + ErrorState *err = new ErrorState(ERR_READ_ERROR, Http::scInternalServerError, fwd->request); err->xerrno = xerrno; fwd->fail(err); conn->close();