]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SourceLayout: shuffle StatusCode.h to http/StatusCode.h
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 16 Mar 2013 04:57:43 +0000 (22:57 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 16 Mar 2013 04:57:43 +0000 (22:57 -0600)
* rename of http_status to Http::StatusCode

* rename all enum values to scReason in camelCase

66 files changed:
src/AccessLogEntry.h
src/HierarchyLogEntry.h
src/HttpMsg.cc
src/HttpMsg.h
src/HttpParser.cc
src/HttpParser.h
src/HttpReply.cc
src/HttpReply.h
src/HttpRequest.cc
src/HttpRequest.h
src/HttpStatusCode.h [deleted file]
src/HttpStatusLine.cc
src/HttpStatusLine.h
src/Makefile.am
src/Server.cc
src/acl/Asn.cc
src/acl/HttpStatus.cc
src/adaptation/ecap/MessageRep.cc
src/adaptation/icap/ModXact.cc
src/adaptation/icap/OptXact.cc
src/adaptation/icap/Xaction.cc
src/auth/UserRequest.cc
src/auth/digest/UserRequest.cc
src/auth/negotiate/UserRequest.cc
src/cache_manager.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_reply.h
src/client_side_request.cc
src/client_side_request.h
src/errorpage.cc
src/errorpage.h
src/esi/Context.h
src/esi/Esi.cc
src/esi/Include.cc
src/format/Format.cc
src/forward.cc
src/forward.h
src/ftp.cc
src/gopher.cc
src/http.cc
src/http/Makefile.am
src/http/StatusCode.h [new file with mode: 0644]
src/icmp/net_db.cc
src/internal.cc
src/log/access_log.cc
src/mgr/Action.cc
src/mgr/Forwarder.cc
src/mgr/Inquirer.cc
src/mime.cc
src/peer_digest.cc
src/peer_select.cc
src/redirect.cc
src/store.cc
src/store_digest.cc
src/tests/stub_HttpReply.cc
src/tests/stub_HttpRequest.cc
src/tests/testCoss.cc
src/tests/testHttpParser.cc
src/tests/testHttpReply.cc
src/tests/testHttpRequest.cc
src/tests/testRock.cc
src/tests/testUfs.cc
src/tunnel.cc
src/urn.cc
src/whois.cc

index 2c0c807c5b6c69e43e2d80c9638c1377d53d6a8e..bea75087d00d7953317af230a6a47691bbba67d4 100644 (file)
@@ -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;
index e4fd9f8dd0db663bc2b14e024fd21e35b0c325fe..de2614ee3bd83405072da8891adc4944c2e118c1 100644 (file)
 #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
index f5b4e464adebc16ac852f3f61e53e8ceaf5d79a6..33aae9461b83f54f1f2188723511e7725b46d2c4 100644 (file)
@@ -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
     }
 
index 48fb0fdf5dcc12e80fa3ab703045b788ad3753c7..02231eada6839e2d527069fe0c363b3d54421b01 100644 (file)
@@ -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;
 
index 39ebeb30449b32c70372e522382d5007a65f501d..a9c69495769c8aab32d7063057588d0158355ec1 100644 (file)
@@ -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;
 }
 
index 349eeaf962b8385db459becbd812187f54e814fa..7e941528dbea23ff4e1b61fc66465ee86e8e4100 100644 (file)
@@ -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
index 9710eaa091d54b88d749e505e44f33a3aa6409c4..ae9333a79f6437b87978539770a5bc912c043af1 100644 (file)
@@ -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;
index c3d7b3545408571184ba1a02443e6ef8468769e4..c1fc688a47cadc917677ca7be1ef7b080305a862 100644 (file)
@@ -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;
 
index 308c072ab2aa19e548b06c4bba701bf0c3518265..09a0f6c4b8981389cb4a3f970d1f6142b5719aa2 100644 (file)
@@ -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;
     }
 
index 10968ac0903da32cc4d3a67f9a3b1d63386b843b..03120e848f92e9bf6a066bdd0b85a9c4edd9ab3d 100644 (file)
@@ -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 (file)
index edb66b4..0000000
+++ /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 */
index 46276afd1fd3338988871eeae6b5f28aefded3ab..f888634d0a6b85a1504c02eb073289b0b54933ad 100644 (file)
@@ -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<Http::StatusCode>(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;
 
index 2567622627f29b3812449253262298c44e1d694a..5e95c209575120d4d41252262cda087dc3f48aec 100644 (file)
 #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 */
index a3a2ef260ccac503b6dc0a6acf553ca304acceaa..60c477dc797871e55f3a3e23421bfd743b303e82 100644 (file)
@@ -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 \
index 746d15d0df34d92b74b3afcc6cd280e98522057b..8bfb6a3ac662d2b1b7cb0918cf4d624cc8469eae 100644 (file)
@@ -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.");
index f6865e711932ce79651f5ca858edfc2a1b90c7d3..d2a9b941b9b39d68159d8cfbcaf448a5afb77fc3 100644 (file)
@@ -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;
index fcf97039223e2784187c123024f6d536a700f68d..c5582b999a501c1a1c5d75f96b62bda35c26e7f7 100644 (file)
@@ -46,7 +46,7 @@
 
 static void aclParseHTTPStatusList(SplayNode<acl_httpstatus_data *> **curlist);
 static int aclHTTPStatusCompare(acl_httpstatus_data * const &a, acl_httpstatus_data * const &b);
-static int aclMatchHTTPStatus(SplayNode<acl_httpstatus_data*> **dataptr, http_status status);
+static int aclMatchHTTPStatus(SplayNode<acl_httpstatus_data*> **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<acl_httpstatus_data*> **dataptr, http_status status)
+aclMatchHTTPStatus(SplayNode<acl_httpstatus_data*> **dataptr, Http::StatusCode status)
 {
 
     acl_httpstatus_data X(status);
index 9e71ba618994ce9007db6fcabf1070baf8a70b22..ecdea7d70358aff448aa0fabf4ce28c72eeebcec 100644 (file)
@@ -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<http_status>(code);
+    theMessage.sline.status = static_cast<Http::StatusCode>(code);
 }
 
 int
index 72086a9b45514df37dbe58cc505a2d9f415b9ac2..3d19e2063240a467ed68e6367a59b2c0dc25013f 100644 (file)
@@ -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
 
index e4da1d18d27fac4e74c7e5125b85f159fd3bf862..e092d728434f89a95cac4cc2349c04eaed0d3a43 100644 (file)
@@ -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);
 }
 
index 996be69db8519a05069ea051f782332627823880..a7a80e76a5be5406162a57f9bd20ed0955686c1b 100644 (file)
@@ -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
 
index fa65fcc636061a438a0866136cf90e5204ab7f30..ff38b8780c0f2c540982c8921852a8e5cb312508 100644 (file)
@@ -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 */
     {
 
index f1059aa05a6cd9c31b08e3d8ee461ae58d31c3bc..98f97d5529e8fa4465de55282d281ccec9dd01c0 100644 (file)
@@ -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;
index e5963b573277ddea5ec4c1ac51424a8b90176c1e..c24fe9cd568320dc838e9ee5e4b9f56a120b7f53 100644 (file)
@@ -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;
index d5f8b3538ae9ec68b810eb0e933e48d15c201429..4f2f8a11d2e1edb7ba095254103a3634397e73f1 100644 (file)
@@ -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));
index 52e369aa11d737d7fc29f53ece05f9630f54a6a1..a6c52c9b06b75045d93c0c34f6e49b3cbf177fb7 100644 (file)
@@ -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<clientReplyContext *>(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<clientReplyContext *>(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<clientReplyContext *>(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<clientReplyContext *>(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<clientReplyContext *>(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<clientReplyContext *>(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<clientReplyContext *>(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<clientReplyContext*>(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<clientReplyContext *>(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);
index 412011c3e613cb3449b236b3b9f254a13d324f6c..90459a4171f2e7c19f0491ef35b2f0131440cab4 100644 (file)
@@ -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);
index e8a87bfe032acb3d264d34c8256c0bdcf114b480..90fec3db8c6f1cd1347cb71d7bd2f5c72665c302 100644 (file)
@@ -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);
index d77846aa44423cf790203070bcb41af700c371ce..62f7418ade222c935f9640d5556d2d72213aea8a 100644 (file)
@@ -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<clientReplyContext *>(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<Http::StatusCode>(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
index 406ea55a1e41eee9a14f1b8ec554919cbd10f00b..eaa5f9211e4b045ed4c2d10bb1d9cf5de3407465 100644 (file)
@@ -127,7 +127,7 @@ public:
     } flags;
 
     struct {
-        http_status status;
+        Http::StatusCode status;
         char *location;
     } redirect;
 
index 2ea02264248b8ed8627488efcd5a53da3e9ccf14..90c95603082f358d1f007425f04e8430d0949132 100644 (file)
@@ -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<http_status>(atoi(page_name));
+    info->page_redirect = static_cast<Http::StatusCode>(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);
index 46c15e8465bf3076e2ebd5937b93e9702e11a4a1..1c04b99c54be0702afdecf83171698631cb83e83 100644 (file)
@@ -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
index baae3fdf979da27bae24a70376a7051a75c9829d..779cfd10596756d286f158891ba2936e04a60e48 100644 (file)
@@ -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 */
index 7e54b1c0514bf24199544679c9373a6cfc88cffe..af2b7f793c3957ea720cdd3fbaeb5f9735047730 100644 (file)
@@ -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
index c62a24e9aa5e07e5ef2562ed041a1ed29fe0ec3f..837056e06891cbc529a0473c604608cd19e6d35b 100644 (file)
@@ -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;
index 59f4fcdef5c43474786b49122519f705798bfd7b..fe8cf545c17940c59d900b6ff5a3e7b91ad96089 100644 (file)
@@ -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;
index 3679dd1b27aa3d99571cc7f68d2e937e943cfd47..18a357de02b5d0cbdf469cf550ff03f9de6713d7 100644 (file)
@@ -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);
index aad16c21ac8d2488cc545813e384dc6d589bfe39..dd59ac577dbfbe063bc71ef3e96661f7d8fca65c 100644 (file)
@@ -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();
index 8f512875b3227e639927131d1b4c48652a717843..9c7e1c0007294c5f55995dc83aa6751187e487aa 100644 (file)
@@ -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 */
index ce165a9f3cdb5573112646129d4b2deb7169fe5e..bd1df5112e359af6e7ab8216965d1b2565a46f88 100644 (file)
@@ -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<GopherStateData *>(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());
index 0f6084bff03b2630feab15d5d3ce028fa6b6f719..11739ff9d22240b3ca1c8aa4d3ec5b36692bcc4c 100644 (file)
@@ -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 &params)
     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);
     }
index bff9700cadaeddd7a859dbe69c00b80fccf1aac5..73dfc89f72286d2afd5074d0d9103069ba8748dd 100644 (file)
@@ -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 (file)
index 0000000..b44bfe5
--- /dev/null
@@ -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 */
index c289e0a8282b45a4abb2e4f3199ccd136272917d..c34bac1cab9eed88c120bdd5a1494acb80b2a0c8 100644 (file)
@@ -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
index 15ef9905e756ff830a19e6a98892616dd8cb8218..a151ddac318fa6a2de03bfe664f9a7e263764db4 100644 (file)
@@ -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);
     }
 }
index a9907257c1bd2c24f7eef9669e8093340f5491d6..b4775bf9ca7a366ebfc9eba3a442b2b4a3fe939f 100644 (file)
@@ -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));
index 0d7b659904ebe244103bf1af1a2d96bc4eeeadbc..dcb2dc88cfad05285c76307c7a20bfe1f0ae79ad 100644 (file)
@@ -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 &params = command().params;
         if (params.httpOrigin.size() > 0) {
index 921f64a4bea0651174c71689e2e10234cddc9afc..d7a754dcfd52753cac3e4351fc18850a6bd99537 100644 (file)
@@ -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);
 }
 
index 3be8323799775a37985038aee87050529badcaa8..8475857ec09491072ffbd7f33bb150f80f8f0cb3 100644 (file)
@@ -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<HttpReply> reply(err.BuildHttpReply());
 #else
@@ -89,7 +89,7 @@ Mgr::Inquirer::start()
 #else
         std::auto_ptr<HttpReply> 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());
     }
index 36f3eb03b210073a83d0051da159218d0122c6c9..db5dc4d59d5a86ab7f04246396bd7f38dd099f89 100644 (file)
@@ -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);
index ea817c1c9602c6a0ea6c2ffc9182ca24f6d339c2..749bff28c82621cda0df8885b11547f789bb366f 100644 (file)
@@ -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!");
index e6897f0c7f87cc6d848e09d63490c0b80528b9d4..897a06fe67166d4692139cae1a8784eac3c6db30 100644 (file)
@@ -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;
         }
     }
index a8ced0fbb03b5c7d906952454ba5a0aec9411007..2f0cf74c6887f7d97e33f5968b7a4e03539d9aeb 100644 (file)
@@ -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<Http::StatusCode>(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.");
         }
 
index 781170f4495596bcbfe4a248f84b626e002ecbc2..2df2322480dd2317e6ffe06485094081609103fa 100644 (file)
@@ -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();
index 6420d82df7418276d9fa379cccf3d72ddc812468..f8b2cca2e02d6cab3b061b9f69bf6c201ca1650e 100644 (file)
@@ -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 <<
index f21b6f3cccae1eeb5393b342f178626de0dc3bbc..21eff0fd7e0f6c5a36a2878744678b31149121b2 100644 (file)
@@ -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
index 79187fcc1fd948c757f961f90b4afdfa03a7f7e5..ac5df4cdaf9d13bea90d716f243e88f85ee37b41 100644 (file)
@@ -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)
index 2d47acc37d976cddf2dd011672218ff3cd3cc392..72752186b8eae0bb17535f325a10fa52dac0ec7b 100644 (file)
@@ -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();
 
index 90b97dcb465c1376e4723fb4574e755e23a18338..5dde9b28d21bd890292ce765c3fd84d40ba07224 100644 (file)
@@ -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);
index 9f731ec4c8e9d83f690c7455e25aad77fdb6f44a..2510b02f1b34bcb5943c1ecb546b94dc911ee1b4 100644 (file)
@@ -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;
 }
index 72f4569b375db3ce84f9c832a782b89f016f72f8..1f1ce12faf8e5525e6a8c7b3783cd0947adcac74 100644 (file)
@@ -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;
 }
index da5cfcaad21691ed3479266c9013b5e60ad334ee..a15e3faf321a186fa7f92ca945af60b8414689ad 100644 (file)
@@ -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<HttpReply *>(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();
 
index 60eccaa2041d8a0a7949b7dd7e37237c76b115bc..7e8563fc9a38d11e568885ca2e980bde6a3aed64 100644 (file)
@@ -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();
 
index f3bfd8e21743a75fc7786c2223c1be49d0ace303..34a4fda03fa933f939c9fcdb0e4158c7f8a6d7bb 100644 (file)
@@ -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;
index bbd61fd7126a6e27c742bec08a50fd68ee35e090..a85ccb8a7c04f053f7813ba2d9a0bef7925f741d 100644 (file)
@@ -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)
         "</ADDRESS>\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");
index 35bde794f9759ca379a7309de583c2e414e8c3c3..f163fea2e2a8b4b495d2db0e63f9a20206416c86 100644 (file)
@@ -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();