added additional HTTP status codes

This commit is contained in:
Guenter Obiltschnig 2016-08-02 22:57:26 +08:00
parent 8e7018df90
commit aed776b7ae
3 changed files with 131 additions and 24 deletions

View File

@ -47,6 +47,7 @@ public:
{
HTTP_CONTINUE = 100,
HTTP_SWITCHING_PROTOCOLS = 101,
HTTP_PROCESSING = 102,
HTTP_OK = 200,
HTTP_CREATED = 201,
HTTP_ACCEPTED = 202,
@ -54,14 +55,19 @@ public:
HTTP_NO_CONTENT = 204,
HTTP_RESET_CONTENT = 205,
HTTP_PARTIAL_CONTENT = 206,
HTTP_MULTI_STATUS = 207,
HTTP_ALREADY_REPORTED = 208,
HTTP_IM_USED = 226,
HTTP_MULTIPLE_CHOICES = 300,
HTTP_MOVED_PERMANENTLY = 301,
HTTP_FOUND = 302,
HTTP_SEE_OTHER = 303,
HTTP_NOT_MODIFIED = 304,
HTTP_USEPROXY = 305,
HTTP_USE_PROXY = 305,
HTTP_USEPROXY = 305, /// @deprecated
// UNUSED: 306
HTTP_TEMPORARY_REDIRECT = 307,
HTTP_PERMANENT_REDIRECT = 308,
HTTP_BAD_REQUEST = 400,
HTTP_UNAUTHORIZED = 401,
HTTP_PAYMENT_REQUIRED = 402,
@ -75,17 +81,36 @@ public:
HTTP_GONE = 410,
HTTP_LENGTH_REQUIRED = 411,
HTTP_PRECONDITION_FAILED = 412,
HTTP_REQUESTENTITYTOOLARGE = 413,
HTTP_REQUESTURITOOLONG = 414,
HTTP_UNSUPPORTEDMEDIATYPE = 415,
HTTP_REQUEST_ENTITY_TOO_LARGE = 413,
HTTP_REQUESTENTITYTOOLARGE = 413, /// @deprecated
HTTP_REQUEST_URI_TOO_LONG = 414,
HTTP_REQUESTURITOOLONG = 414, /// @deprecated
HTTP_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_UNSUPPORTEDMEDIATYPE = 415, /// @deprecated
HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
HTTP_EXPECTATION_FAILED = 417,
HTTP_IM_A_TEAPOT = 418,
HTTP_ENCHANCE_YOUR_CALM = 420,
HTTP_MISDIRECTED_REQUEST = 421,
HTTP_UNPROCESSABLE_ENTITY = 422,
HTTP_LOCKED = 423,
HTTP_FAILED_DEPENDENCY = 424,
HTTP_UPGRADE_REQUIRED = 426,
HTTP_PRECONDITION_REQUIRED = 428,
HTTP_TOO_MANY_REQUESTS = 429,
HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
HTTP_INTERNAL_SERVER_ERROR = 500,
HTTP_NOT_IMPLEMENTED = 501,
HTTP_BAD_GATEWAY = 502,
HTTP_SERVICE_UNAVAILABLE = 503,
HTTP_GATEWAY_TIMEOUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505
HTTP_VERSION_NOT_SUPPORTED = 505,
HTTP_VARIANT_ALSO_NEGOTIATES = 506,
HTTP_INSUFFICIENT_STORAGE = 507,
HTTP_LOOP_DETECTED = 508,
HTTP_NOT_EXTENDED = 510,
HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511
};
HTTPResponse();
@ -171,6 +196,7 @@ public:
static const std::string HTTP_REASON_CONTINUE;
static const std::string HTTP_REASON_SWITCHING_PROTOCOLS;
static const std::string HTTP_REASON_PROCESSING;
static const std::string HTTP_REASON_OK;
static const std::string HTTP_REASON_CREATED;
static const std::string HTTP_REASON_ACCEPTED;
@ -178,13 +204,17 @@ public:
static const std::string HTTP_REASON_NO_CONTENT;
static const std::string HTTP_REASON_RESET_CONTENT;
static const std::string HTTP_REASON_PARTIAL_CONTENT;
static const std::string HTTP_REASON_MULTI_STATUS;
static const std::string HTTP_REASON_ALREADY_REPORTED;
static const std::string HTTP_REASON_IM_USED;
static const std::string HTTP_REASON_MULTIPLE_CHOICES;
static const std::string HTTP_REASON_MOVED_PERMANENTLY;
static const std::string HTTP_REASON_FOUND;
static const std::string HTTP_REASON_SEE_OTHER;
static const std::string HTTP_REASON_NOT_MODIFIED;
static const std::string HTTP_REASON_USEPROXY;
static const std::string HTTP_REASON_USE_PROXY;
static const std::string HTTP_REASON_TEMPORARY_REDIRECT;
static const std::string HTTP_REASON_PERMANENT_REDIRECT;
static const std::string HTTP_REASON_BAD_REQUEST;
static const std::string HTTP_REASON_UNAUTHORIZED;
static const std::string HTTP_REASON_PAYMENT_REQUIRED;
@ -198,17 +228,33 @@ public:
static const std::string HTTP_REASON_GONE;
static const std::string HTTP_REASON_LENGTH_REQUIRED;
static const std::string HTTP_REASON_PRECONDITION_FAILED;
static const std::string HTTP_REASON_REQUESTENTITYTOOLARGE;
static const std::string HTTP_REASON_REQUESTURITOOLONG;
static const std::string HTTP_REASON_UNSUPPORTEDMEDIATYPE;
static const std::string HTTP_REASON_REQUEST_ENTITY_TOO_LARGE;
static const std::string HTTP_REASON_REQUEST_URI_TOO_LONG;
static const std::string HTTP_REASON_UNSUPPORTED_MEDIA_TYPE;
static const std::string HTTP_REASON_REQUESTED_RANGE_NOT_SATISFIABLE;
static const std::string HTTP_REASON_EXPECTATION_FAILED;
static const std::string HTTP_REASON_IM_A_TEAPOT;
static const std::string HTTP_REASON_ENCHANCE_YOUR_CALM;
static const std::string HTTP_REASON_MISDIRECTED_REQUEST;
static const std::string HTTP_REASON_UNPROCESSABLE_ENTITY;
static const std::string HTTP_REASON_LOCKED;
static const std::string HTTP_REASON_FAILED_DEPENDENCY;
static const std::string HTTP_REASON_UPGRADE_REQUIRED;
static const std::string HTTP_REASON_PRECONDITION_REQUIRED;
static const std::string HTTP_REASON_TOO_MANY_REQUESTS;
static const std::string HTTP_REASON_REQUEST_HEADER_FIELDS_TOO_LARGE;
static const std::string HTTP_REASON_UNAVAILABLE_FOR_LEGAL_REASONS;
static const std::string HTTP_REASON_INTERNAL_SERVER_ERROR;
static const std::string HTTP_REASON_NOT_IMPLEMENTED;
static const std::string HTTP_REASON_BAD_GATEWAY;
static const std::string HTTP_REASON_SERVICE_UNAVAILABLE;
static const std::string HTTP_REASON_GATEWAY_TIMEOUT;
static const std::string HTTP_REASON_VERSION_NOT_SUPPORTED;
static const std::string HTTP_REASON_VARIANT_ALSO_NEGOTIATES;
static const std::string HTTP_REASON_INSUFFICIENT_STORAGE;
static const std::string HTTP_REASON_LOOP_DETECTED;
static const std::string HTTP_REASON_NOT_EXTENDED;
static const std::string HTTP_REASON_NETWORK_AUTHENTICATION_REQUIRED;
static const std::string HTTP_REASON_UNKNOWN;
static const std::string DATE;

View File

@ -40,6 +40,7 @@ namespace Net {
const std::string HTTPResponse::HTTP_REASON_CONTINUE = "Continue";
const std::string HTTPResponse::HTTP_REASON_SWITCHING_PROTOCOLS = "Switching Protocols";
const std::string HTTPResponse::HTTP_REASON_PROCESSING = "Processing";
const std::string HTTPResponse::HTTP_REASON_OK = "OK";
const std::string HTTPResponse::HTTP_REASON_CREATED = "Created";
const std::string HTTPResponse::HTTP_REASON_ACCEPTED = "Accepted";
@ -47,13 +48,17 @@ const std::string HTTPResponse::HTTP_REASON_NONAUTHORITATIVE = "N
const std::string HTTPResponse::HTTP_REASON_NO_CONTENT = "No Content";
const std::string HTTPResponse::HTTP_REASON_RESET_CONTENT = "Reset Content";
const std::string HTTPResponse::HTTP_REASON_PARTIAL_CONTENT = "Partial Content";
const std::string HTTPResponse::HTTP_REASON_MULTI_STATUS = "Multi Status";
const std::string HTTPResponse::HTTP_REASON_ALREADY_REPORTED = "Already Reported";
const std::string HTTPResponse::HTTP_REASON_IM_USED = "IM Used";
const std::string HTTPResponse::HTTP_REASON_MULTIPLE_CHOICES = "Multiple Choices";
const std::string HTTPResponse::HTTP_REASON_MOVED_PERMANENTLY = "Moved Permanently";
const std::string HTTPResponse::HTTP_REASON_FOUND = "Found";
const std::string HTTPResponse::HTTP_REASON_SEE_OTHER = "See Other";
const std::string HTTPResponse::HTTP_REASON_NOT_MODIFIED = "Not Modified";
const std::string HTTPResponse::HTTP_REASON_USEPROXY = "Use Proxy";
const std::string HTTPResponse::HTTP_REASON_USE_PROXY = "Use Proxy";
const std::string HTTPResponse::HTTP_REASON_TEMPORARY_REDIRECT = "Temporary Redirect";
const std::string HTTPResponse::HTTP_REASON_PERMANENT_REDIRECT = "Permanent Redirect";
const std::string HTTPResponse::HTTP_REASON_BAD_REQUEST = "Bad Request";
const std::string HTTPResponse::HTTP_REASON_UNAUTHORIZED = "Unauthorized";
const std::string HTTPResponse::HTTP_REASON_PAYMENT_REQUIRED = "Payment Required";
@ -67,17 +72,33 @@ const std::string HTTPResponse::HTTP_REASON_CONFLICT = "C
const std::string HTTPResponse::HTTP_REASON_GONE = "Gone";
const std::string HTTPResponse::HTTP_REASON_LENGTH_REQUIRED = "Length Required";
const std::string HTTPResponse::HTTP_REASON_PRECONDITION_FAILED = "Precondition Failed";
const std::string HTTPResponse::HTTP_REASON_REQUESTENTITYTOOLARGE = "Request Entity Too Large";
const std::string HTTPResponse::HTTP_REASON_REQUESTURITOOLONG = "Request-URI Too Large";
const std::string HTTPResponse::HTTP_REASON_UNSUPPORTEDMEDIATYPE = "Unsupported Media Type";
const std::string HTTPResponse::HTTP_REASON_REQUEST_ENTITY_TOO_LARGE = "Request Entity Too Large";
const std::string HTTPResponse::HTTP_REASON_REQUEST_URI_TOO_LONG = "Request-URI Too Large";
const std::string HTTPResponse::HTTP_REASON_UNSUPPORTED_MEDIA_TYPE = "Unsupported Media Type";
const std::string HTTPResponse::HTTP_REASON_REQUESTED_RANGE_NOT_SATISFIABLE = "Requested Range Not Satisfiable";
const std::string HTTPResponse::HTTP_REASON_EXPECTATION_FAILED = "Expectation Failed";
const std::string HTTPResponse::HTTP_REASON_IM_A_TEAPOT = "I'm a Teapot";
const std::string HTTPResponse::HTTP_REASON_ENCHANCE_YOUR_CALM = "Enchance Your Calm";
const std::string HTTPResponse::HTTP_REASON_MISDIRECTED_REQUEST = "Misdirected Request";
const std::string HTTPResponse::HTTP_REASON_UNPROCESSABLE_ENTITY = "Unprocessable Entity";
const std::string HTTPResponse::HTTP_REASON_LOCKED = "Locked";
const std::string HTTPResponse::HTTP_REASON_FAILED_DEPENDENCY = "Failed Dependency";
const std::string HTTPResponse::HTTP_REASON_UPGRADE_REQUIRED = "Upgrade Required";
const std::string HTTPResponse::HTTP_REASON_PRECONDITION_REQUIRED = "Precondition Required";
const std::string HTTPResponse::HTTP_REASON_TOO_MANY_REQUESTS = "Too Many Requests";
const std::string HTTPResponse::HTTP_REASON_REQUEST_HEADER_FIELDS_TOO_LARGE = "Request Header Fields Too Large";
const std::string HTTPResponse::HTTP_REASON_UNAVAILABLE_FOR_LEGAL_REASONS = "Unavailable For Legal Reasons";
const std::string HTTPResponse::HTTP_REASON_INTERNAL_SERVER_ERROR = "Internal Server Error";
const std::string HTTPResponse::HTTP_REASON_NOT_IMPLEMENTED = "Not Implemented";
const std::string HTTPResponse::HTTP_REASON_BAD_GATEWAY = "Bad Gateway";
const std::string HTTPResponse::HTTP_REASON_SERVICE_UNAVAILABLE = "Service Unavailable";
const std::string HTTPResponse::HTTP_REASON_GATEWAY_TIMEOUT = "Gateway Time-out";
const std::string HTTPResponse::HTTP_REASON_VERSION_NOT_SUPPORTED = "HTTP Version not supported";
const std::string HTTPResponse::HTTP_REASON_GATEWAY_TIMEOUT = "Gateway Time-Out";
const std::string HTTPResponse::HTTP_REASON_VERSION_NOT_SUPPORTED = "HTTP Version Not Supported";
const std::string HTTPResponse::HTTP_REASON_VARIANT_ALSO_NEGOTIATES = "Variant Also Negotiates";
const std::string HTTPResponse::HTTP_REASON_INSUFFICIENT_STORAGE = "Insufficient Storage";
const std::string HTTPResponse::HTTP_REASON_LOOP_DETECTED = "Loop Detected";
const std::string HTTPResponse::HTTP_REASON_NOT_EXTENDED = "Not Extended";
const std::string HTTPResponse::HTTP_REASON_NETWORK_AUTHENTICATION_REQUIRED = "Network Authentication Required";
const std::string HTTPResponse::HTTP_REASON_UNKNOWN = "???";
const std::string HTTPResponse::DATE = "Date";
const std::string HTTPResponse::SET_COOKIE = "Set-Cookie";
@ -239,6 +260,8 @@ const std::string& HTTPResponse::getReasonForStatus(HTTPStatus status)
return HTTP_REASON_CONTINUE;
case HTTP_SWITCHING_PROTOCOLS:
return HTTP_REASON_SWITCHING_PROTOCOLS;
case HTTP_PROCESSING:
return HTTP_REASON_PROCESSING;
case HTTP_OK:
return HTTP_REASON_OK;
case HTTP_CREATED:
@ -253,6 +276,12 @@ const std::string& HTTPResponse::getReasonForStatus(HTTPStatus status)
return HTTP_REASON_RESET_CONTENT;
case HTTP_PARTIAL_CONTENT:
return HTTP_REASON_PARTIAL_CONTENT;
case HTTP_MULTI_STATUS:
return HTTP_REASON_MULTI_STATUS;
case HTTP_ALREADY_REPORTED:
return HTTP_REASON_ALREADY_REPORTED;
case HTTP_IM_USED:
return HTTP_REASON_IM_USED;
case HTTP_MULTIPLE_CHOICES:
return HTTP_REASON_MULTIPLE_CHOICES;
case HTTP_MOVED_PERMANENTLY:
@ -263,8 +292,8 @@ const std::string& HTTPResponse::getReasonForStatus(HTTPStatus status)
return HTTP_REASON_SEE_OTHER;
case HTTP_NOT_MODIFIED:
return HTTP_REASON_NOT_MODIFIED;
case HTTP_USEPROXY:
return HTTP_REASON_USEPROXY;
case HTTP_USE_PROXY:
return HTTP_REASON_USE_PROXY;
case HTTP_TEMPORARY_REDIRECT:
return HTTP_REASON_TEMPORARY_REDIRECT;
case HTTP_BAD_REQUEST:
@ -293,16 +322,38 @@ const std::string& HTTPResponse::getReasonForStatus(HTTPStatus status)
return HTTP_REASON_LENGTH_REQUIRED;
case HTTP_PRECONDITION_FAILED:
return HTTP_REASON_PRECONDITION_FAILED;
case HTTP_REQUESTENTITYTOOLARGE:
return HTTP_REASON_REQUESTENTITYTOOLARGE;
case HTTP_REQUESTURITOOLONG:
return HTTP_REASON_REQUESTURITOOLONG;
case HTTP_UNSUPPORTEDMEDIATYPE:
return HTTP_REASON_UNSUPPORTEDMEDIATYPE;
case HTTP_REQUEST_ENTITY_TOO_LARGE:
return HTTP_REASON_REQUEST_ENTITY_TOO_LARGE;
case HTTP_REQUEST_URI_TOO_LONG:
return HTTP_REASON_REQUEST_URI_TOO_LONG;
case HTTP_UNSUPPORTED_MEDIA_TYPE:
return HTTP_REASON_UNSUPPORTED_MEDIA_TYPE;
case HTTP_REQUESTED_RANGE_NOT_SATISFIABLE:
return HTTP_REASON_REQUESTED_RANGE_NOT_SATISFIABLE;
case HTTP_EXPECTATION_FAILED:
return HTTP_REASON_EXPECTATION_FAILED;
case HTTP_IM_A_TEAPOT:
return HTTP_REASON_IM_A_TEAPOT;
case HTTP_ENCHANCE_YOUR_CALM:
return HTTP_REASON_ENCHANCE_YOUR_CALM;
case HTTP_MISDIRECTED_REQUEST:
return HTTP_REASON_MISDIRECTED_REQUEST;
case HTTP_UNPROCESSABLE_ENTITY:
return HTTP_REASON_UNPROCESSABLE_ENTITY;
case HTTP_LOCKED:
return HTTP_REASON_LOCKED;
case HTTP_FAILED_DEPENDENCY:
return HTTP_REASON_FAILED_DEPENDENCY;
case HTTP_UPGRADE_REQUIRED:
return HTTP_REASON_UPGRADE_REQUIRED;
case HTTP_PRECONDITION_REQUIRED:
return HTTP_REASON_PRECONDITION_REQUIRED;
case HTTP_TOO_MANY_REQUESTS:
return HTTP_REASON_TOO_MANY_REQUESTS;
case HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE:
return HTTP_REASON_REQUEST_HEADER_FIELDS_TOO_LARGE;
case HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
return HTTP_REASON_UNAVAILABLE_FOR_LEGAL_REASONS;
case HTTP_INTERNAL_SERVER_ERROR:
return HTTP_REASON_INTERNAL_SERVER_ERROR;
case HTTP_NOT_IMPLEMENTED:
@ -315,6 +366,16 @@ const std::string& HTTPResponse::getReasonForStatus(HTTPStatus status)
return HTTP_REASON_GATEWAY_TIMEOUT;
case HTTP_VERSION_NOT_SUPPORTED:
return HTTP_REASON_VERSION_NOT_SUPPORTED;
case HTTP_VARIANT_ALSO_NEGOTIATES:
return HTTP_REASON_VARIANT_ALSO_NEGOTIATES;
case HTTP_INSUFFICIENT_STORAGE:
return HTTP_REASON_INSUFFICIENT_STORAGE;
case HTTP_LOOP_DETECTED:
return HTTP_REASON_LOOP_DETECTED;
case HTTP_NOT_EXTENDED:
return HTTP_REASON_NOT_EXTENDED;
case HTTP_NETWORK_AUTHENTICATION_REQUIRED:
return HTTP_REASON_NETWORK_AUTHENTICATION_REQUIRED;
default:
return HTTP_REASON_UNKNOWN;
}

View File

@ -134,7 +134,7 @@ std::istream* HTTPStreamFactory::open(const URI& uri)
{
return new HTTPResponseStream(rs, pSession);
}
else if (res.getStatus() == HTTPResponse::HTTP_USEPROXY && !retry)
else if (res.getStatus() == HTTPResponse::HTTP_USE_PROXY && !retry)
{
// The requested resource MUST be accessed through the proxy
// given by the Location field. The Location field gives the