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
* 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;
#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
{
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
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
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;
}
// 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;
}
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;
}
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
}
#include "BodyPipe.h"
#include "HttpHeader.h"
#include "HttpRequestMethod.h"
-#include "HttpStatusCode.h"
+#include "http/StatusCode.h"
#include "HttpVersion.h"
#include "typedefs.h"
// 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);
* \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;
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;
// 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;
}
}
// 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;
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.
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;
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
}
/* 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;
}
// 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;
}
// 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;
/*
* Rightio - we have all the schtuff. Return true; we've got enough.
*/
- request_parse_status = HTTP_OK;
+ request_parse_status = Http::scOkay;
return 1;
}
#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.
// 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
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));
}
#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);
/* 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])))
}
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;
}
void
-HttpReply::redirect(http_status status, const char *loc)
+HttpReply::redirect(Http::StatusCode status, const char *loc)
{
HttpHeader *hdr;
HttpVersion ver(1,1);
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;
* 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.
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;
}
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;
}
// 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;
}
}
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;
}
{
int result(HttpMsg::httpMsgParseError());
/* indicate an error in the status line */
- sline.status = HTTP_INVALID_HEADER;
+ sline.status = Http::scInvalidHeader;
return result;
}
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;
#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 */
/**
\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;
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 */
/** 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;
* 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
// 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;
}
/* 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;
}
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();
+++ /dev/null
-#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 */
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;
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?)
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 ? */
}
const char *
-httpStatusString(http_status status)
+httpStatusString(Http::StatusCode status)
{
/* why not to return matching string instead of using "p" ? @?@ */
const char *p = NULL;
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;
#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.
*
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 */
};
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 */
/* 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 */
HttpStateFlags.h \
http.cc \
http.h \
- HttpStatusCode.h \
+ http/StatusCode.h \
HttpStatusLine.cc \
HttpStatusLine.h \
HttpHeaderFieldStat.h \
HttpMsg.h \
HttpReply.cc \
HttpReply.h \
- HttpStatusCode.h \
+ http/StatusCode.h \
HttpStatusLine.cc \
HttpStatusLine.h \
Mem.h \
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");
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);
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);
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.");
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;
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) { ; }
}
int
-aclMatchHTTPStatus(SplayNode<acl_httpstatus_data*> **dataptr, http_status status)
+aclMatchHTTPStatus(SplayNode<acl_httpstatus_data*> **dataptr, Http::StatusCode status)
{
acl_httpstatus_data X(status);
MemBuf mb;
mb.init();
mb.append(buf.start, buf.size);
- http_status error;
+ Http::StatusCode error;
Must(theMessage.parse(&mb, true, &error));
}
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
}
// parse the buffer back
- http_status error = HTTP_STATUS_NONE;
+ Http::StatusCode error = Http::scNone;
Must(adapted.header->parse(&httpBuf, true, &error));
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
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);
}
{
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
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;
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 */
{
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;
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;
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;
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;
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()) {
// 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));
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";
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
#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
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");
}
/* 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");
}
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");
}
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();
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,
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:
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;
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();
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;
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();
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();
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();
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();
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,
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);
/* 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 */
*/
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
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;
/* 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)) {
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
}
// 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");
/// 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();
{
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);
{
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;
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;
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;
}
{
assert (newEntry);
/* Move to new() when that is created */
- purgeStatus = HTTP_NOT_FOUND;
+ purgeStatus = Http::scNotFound;
if (!newEntry->isNull()) {
/* Release the cached URI */
neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(Http::METHOD_GET), HTCP_CLR_PURGE);
#endif
newEntry->release();
- purgeStatus = HTTP_OK;
+ purgeStatus = Http::scOkay;
}
lookingforstore = 4;
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 */
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);
neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(Http::METHOD_HEAD), HTCP_CLR_PURGE);
#endif
entry->release();
- purgeStatus = HTTP_OK;
+ purgeStatus = Http::scOkay;
}
}
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();
* 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;
#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
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);
{
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);
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);
#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);
}
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);
/// 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
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;
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);
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);
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,
{
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 <<
#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;
// 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
// 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;
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
} flags;
struct {
- http_status status;
+ Http::StatusCode status;
char *location;
} redirect;
typedef struct {
int id;
char *page_name;
- http_status page_redirect;
+ Http::StatusCode page_redirect;
} ErrorDynamicPageInfo;
/* local constant and vars */
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) {
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.
* - 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
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),
{
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) {
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);
#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 */
class ErrorState
{
public:
- ErrorState(err_type type, http_status, HttpRequest * request);
+ ErrorState(err_type type, Http::StatusCode, HttpRequest * request);
ErrorState(); // not implemented.
~ErrorState();
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
#include "esi/Element.h"
#include "clientStream.h"
#include "err_type.h"
-#include "HttpStatusCode.h"
+#include "http/StatusCode.h"
class ESIVarState;
class ClientHttpRequest;
thisNode(NULL),
http(NULL),
errorpage(ERR_NONE),
- errorstatus(HTTP_STATUS_NONE),
+ errorstatus(Http::scNone),
errormessage(NULL),
rep(NULL),
outbound_offset(0),
} 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 */
ESIContext::setError()
{
errorpage = ERR_ESI;
- errorstatus = HTTP_INTERNAL_SERVER_ERROR;
+ errorstatus = Http::scInternalServerError;
flags.error = 1;
}
}
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;
/* 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
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;
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;
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);
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.
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;
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;
}
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;
}
} 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
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);
}
" 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());
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
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
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);
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;
}
// 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;
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;
FwdState::reforward()
{
StoreEntry *e = entry;
- http_status s;
if (EBIT_TEST(e->flags, ENTRY_ABORTED)) {
debugs(17, 3, HERE << "entry aborted");
return 0;
}
- s = e->getReply()->sline.status;
+ const Http::StatusCode s = e->getReply()->sline.status;
debugs(17, 3, HERE << "status " << s);
return reforwardableStatus(s);
}
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
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;
/**** 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:
}
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);
#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"
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);
#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();
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);
}
}
{
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;
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;
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;
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;
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);
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);
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
" 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);
}
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 */
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);
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();
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. */
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());
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
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;
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;
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.
/* 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;
/* 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;
/* 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;
return;
}
- http_status error = HTTP_STATUS_NONE;
+ Http::StatusCode error = Http::scNone;
HttpReply *newrep = new HttpReply;
const bool parsed = newrep->parse(readBuf, eof, &error);
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);
/*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
*/
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;
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;
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 {
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
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();
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;
}
// 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);
}
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
--- /dev/null
+#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 */
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;
}
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);
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
/* 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)
#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();
} 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);
}
}
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),
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));
if (writeHttpHeader) {
HttpReply *rep = new HttpReply;
- rep->setHeaders(HTTP_OK, NULL, "text/plain", -1, squid_curtime, squid_curtime);
+ rep->setHeaders(Http::scOkay, NULL, "text/plain", -1, squid_curtime, squid_curtime);
// Allow cachemgr and other XHR scripts access to our version string
const ActionParams ¶ms = command().params;
if (params.httpOrigin.size() > 0) {
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();
}
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);
}
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
#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());
}
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);
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);
/* this "if" is based on clientHandleIMSReply() */
- if (status == HTTP_NOT_MODIFIED) {
+ if (status == Http::scNotModified) {
/* our old entry is fine */
assert(fetch->old_entry);
/* 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) {
/* 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 {
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!");
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;
}
}
* 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];
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];
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.");
}
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()) {
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();
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 <<
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
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)
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();
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);
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);
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);
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);
//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);
//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);
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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
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);
// 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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
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);
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);
//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);
//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);
// 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);
// 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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
//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);
{
MemBuf input;
HttpReply engine;
- http_status error = HTTP_STATUS_NONE;
+ Http::StatusCode error = Http::scNone;
size_t hdr_len;
input.init();
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();
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;
}
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 */
{
MemBuf input;
PrivateHttpRequest engine;
- http_status error = HTTP_STATUS_NONE;
+ Http::StatusCode error = Http::scNone;
size_t hdr_len;
input.init();
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
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;
}
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();
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();
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);
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;
}
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();
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;
}
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;
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);
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;
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);
"</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");
{
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);
}
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();