From e072079faf53995f7ccb791dc738744b19dcd207 Mon Sep 17 00:00:00 2001 From: asantiagode Date: Thu, 23 Sep 2021 09:58:00 -0500 Subject: [PATCH 1/2] chore: add HTTP response status codes This codes were taken from the HTTPClient library (the arduino library for the ESP32) --- src/HttpClient.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/HttpClient.h b/src/HttpClient.h index 6a7aa1d..1f21df2 100644 --- a/src/HttpClient.h +++ b/src/HttpClient.h @@ -38,6 +38,69 @@ static const int HTTP_ERROR_INVALID_RESPONSE =-4; #define HTTP_HEADER_USER_AGENT "User-Agent" #define HTTP_HEADER_VALUE_CHUNKED "chunked" +/// HTTP codes see RFC7231 +enum +{ + HTTP_CODE_CONTINUE = 100, + HTTP_CODE_SWITCHING_PROTOCOLS = 101, + HTTP_CODE_PROCESSING = 102, + HTTP_CODE_OK = 200, + HTTP_CODE_CREATED = 201, + HTTP_CODE_ACCEPTED = 202, + HTTP_CODE_NON_AUTHORITATIVE_INFORMATION = 203, + HTTP_CODE_NO_CONTENT = 204, + HTTP_CODE_RESET_CONTENT = 205, + HTTP_CODE_PARTIAL_CONTENT = 206, + HTTP_CODE_MULTI_STATUS = 207, + HTTP_CODE_ALREADY_REPORTED = 208, + HTTP_CODE_IM_USED = 226, + HTTP_CODE_MULTIPLE_CHOICES = 300, + HTTP_CODE_MOVED_PERMANENTLY = 301, + HTTP_CODE_FOUND = 302, + HTTP_CODE_SEE_OTHER = 303, + HTTP_CODE_NOT_MODIFIED = 304, + HTTP_CODE_USE_PROXY = 305, + HTTP_CODE_TEMPORARY_REDIRECT = 307, + HTTP_CODE_PERMANENT_REDIRECT = 308, + HTTP_CODE_BAD_REQUEST = 400, + HTTP_CODE_UNAUTHORIZED = 401, + HTTP_CODE_PAYMENT_REQUIRED = 402, + HTTP_CODE_FORBIDDEN = 403, + HTTP_CODE_NOT_FOUND = 404, + HTTP_CODE_METHOD_NOT_ALLOWED = 405, + HTTP_CODE_NOT_ACCEPTABLE = 406, + HTTP_CODE_PROXY_AUTHENTICATION_REQUIRED = 407, + HTTP_CODE_REQUEST_TIMEOUT = 408, + HTTP_CODE_CONFLICT = 409, + HTTP_CODE_GONE = 410, + HTTP_CODE_LENGTH_REQUIRED = 411, + HTTP_CODE_PRECONDITION_FAILED = 412, + HTTP_CODE_PAYLOAD_TOO_LARGE = 413, + HTTP_CODE_URI_TOO_LONG = 414, + HTTP_CODE_UNSUPPORTED_MEDIA_TYPE = 415, + HTTP_CODE_RANGE_NOT_SATISFIABLE = 416, + HTTP_CODE_EXPECTATION_FAILED = 417, + HTTP_CODE_MISDIRECTED_REQUEST = 421, + HTTP_CODE_UNPROCESSABLE_ENTITY = 422, + HTTP_CODE_LOCKED = 423, + HTTP_CODE_FAILED_DEPENDENCY = 424, + HTTP_CODE_UPGRADE_REQUIRED = 426, + HTTP_CODE_PRECONDITION_REQUIRED = 428, + HTTP_CODE_TOO_MANY_REQUESTS = 429, + HTTP_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE = 431, + HTTP_CODE_INTERNAL_SERVER_ERROR = 500, + HTTP_CODE_NOT_IMPLEMENTED = 501, + HTTP_CODE_BAD_GATEWAY = 502, + HTTP_CODE_SERVICE_UNAVAILABLE = 503, + HTTP_CODE_GATEWAY_TIMEOUT = 504, + HTTP_CODE_HTTP_VERSION_NOT_SUPPORTED = 505, + HTTP_CODE_VARIANT_ALSO_NEGOTIATES = 506, + HTTP_CODE_INSUFFICIENT_STORAGE = 507, + HTTP_CODE_LOOP_DETECTED = 508, + HTTP_CODE_NOT_EXTENDED = 510, + HTTP_CODE_NETWORK_AUTHENTICATION_REQUIRED = 511 +}; + class HttpClient : public Client { public: From 5a6e926a6367ac475837a72e333d04be378f2110 Mon Sep 17 00:00:00 2001 From: asantiagode Date: Thu, 23 Sep 2021 10:30:06 -0500 Subject: [PATCH 2/2] chore: Change prefix "HTTP_CODE" to "HTTP_STATUS_CODE" --- src/HttpClient.h | 116 +++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/src/HttpClient.h b/src/HttpClient.h index 1f21df2..d356014 100644 --- a/src/HttpClient.h +++ b/src/HttpClient.h @@ -41,64 +41,64 @@ static const int HTTP_ERROR_INVALID_RESPONSE =-4; /// HTTP codes see RFC7231 enum { - HTTP_CODE_CONTINUE = 100, - HTTP_CODE_SWITCHING_PROTOCOLS = 101, - HTTP_CODE_PROCESSING = 102, - HTTP_CODE_OK = 200, - HTTP_CODE_CREATED = 201, - HTTP_CODE_ACCEPTED = 202, - HTTP_CODE_NON_AUTHORITATIVE_INFORMATION = 203, - HTTP_CODE_NO_CONTENT = 204, - HTTP_CODE_RESET_CONTENT = 205, - HTTP_CODE_PARTIAL_CONTENT = 206, - HTTP_CODE_MULTI_STATUS = 207, - HTTP_CODE_ALREADY_REPORTED = 208, - HTTP_CODE_IM_USED = 226, - HTTP_CODE_MULTIPLE_CHOICES = 300, - HTTP_CODE_MOVED_PERMANENTLY = 301, - HTTP_CODE_FOUND = 302, - HTTP_CODE_SEE_OTHER = 303, - HTTP_CODE_NOT_MODIFIED = 304, - HTTP_CODE_USE_PROXY = 305, - HTTP_CODE_TEMPORARY_REDIRECT = 307, - HTTP_CODE_PERMANENT_REDIRECT = 308, - HTTP_CODE_BAD_REQUEST = 400, - HTTP_CODE_UNAUTHORIZED = 401, - HTTP_CODE_PAYMENT_REQUIRED = 402, - HTTP_CODE_FORBIDDEN = 403, - HTTP_CODE_NOT_FOUND = 404, - HTTP_CODE_METHOD_NOT_ALLOWED = 405, - HTTP_CODE_NOT_ACCEPTABLE = 406, - HTTP_CODE_PROXY_AUTHENTICATION_REQUIRED = 407, - HTTP_CODE_REQUEST_TIMEOUT = 408, - HTTP_CODE_CONFLICT = 409, - HTTP_CODE_GONE = 410, - HTTP_CODE_LENGTH_REQUIRED = 411, - HTTP_CODE_PRECONDITION_FAILED = 412, - HTTP_CODE_PAYLOAD_TOO_LARGE = 413, - HTTP_CODE_URI_TOO_LONG = 414, - HTTP_CODE_UNSUPPORTED_MEDIA_TYPE = 415, - HTTP_CODE_RANGE_NOT_SATISFIABLE = 416, - HTTP_CODE_EXPECTATION_FAILED = 417, - HTTP_CODE_MISDIRECTED_REQUEST = 421, - HTTP_CODE_UNPROCESSABLE_ENTITY = 422, - HTTP_CODE_LOCKED = 423, - HTTP_CODE_FAILED_DEPENDENCY = 424, - HTTP_CODE_UPGRADE_REQUIRED = 426, - HTTP_CODE_PRECONDITION_REQUIRED = 428, - HTTP_CODE_TOO_MANY_REQUESTS = 429, - HTTP_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE = 431, - HTTP_CODE_INTERNAL_SERVER_ERROR = 500, - HTTP_CODE_NOT_IMPLEMENTED = 501, - HTTP_CODE_BAD_GATEWAY = 502, - HTTP_CODE_SERVICE_UNAVAILABLE = 503, - HTTP_CODE_GATEWAY_TIMEOUT = 504, - HTTP_CODE_HTTP_VERSION_NOT_SUPPORTED = 505, - HTTP_CODE_VARIANT_ALSO_NEGOTIATES = 506, - HTTP_CODE_INSUFFICIENT_STORAGE = 507, - HTTP_CODE_LOOP_DETECTED = 508, - HTTP_CODE_NOT_EXTENDED = 510, - HTTP_CODE_NETWORK_AUTHENTICATION_REQUIRED = 511 + HTTP_STATUS_CODE_CONTINUE = 100, + HTTP_STATUS_CODE_SWITCHING_PROTOCOLS = 101, + HTTP_STATUS_CODE_PROCESSING = 102, + HTTP_STATUS_CODE_OK = 200, + HTTP_STATUS_CODE_CREATED = 201, + HTTP_STATUS_CODE_ACCEPTED = 202, + HTTP_STATUS_CODE_NON_AUTHORITATIVE_INFORMATION = 203, + HTTP_STATUS_CODE_NO_CONTENT = 204, + HTTP_STATUS_CODE_RESET_CONTENT = 205, + HTTP_STATUS_CODE_PARTIAL_CONTENT = 206, + HTTP_STATUS_CODE_MULTI_STATUS = 207, + HTTP_STATUS_CODE_ALREADY_REPORTED = 208, + HTTP_STATUS_CODE_IM_USED = 226, + HTTP_STATUS_CODE_MULTIPLE_CHOICES = 300, + HTTP_STATUS_CODE_MOVED_PERMANENTLY = 301, + HTTP_STATUS_CODE_FOUND = 302, + HTTP_STATUS_CODE_SEE_OTHER = 303, + HTTP_STATUS_CODE_NOT_MODIFIED = 304, + HTTP_STATUS_CODE_USE_PROXY = 305, + HTTP_STATUS_CODE_TEMPORARY_REDIRECT = 307, + HTTP_STATUS_CODE_PERMANENT_REDIRECT = 308, + HTTP_STATUS_CODE_BAD_REQUEST = 400, + HTTP_STATUS_CODE_UNAUTHORIZED = 401, + HTTP_STATUS_CODE_PAYMENT_REQUIRED = 402, + HTTP_STATUS_CODE_FORBIDDEN = 403, + HTTP_STATUS_CODE_NOT_FOUND = 404, + HTTP_STATUS_CODE_METHOD_NOT_ALLOWED = 405, + HTTP_STATUS_CODE_NOT_ACCEPTABLE = 406, + HTTP_STATUS_CODE_PROXY_AUTHENTICATION_REQUIRED = 407, + HTTP_STATUS_CODE_REQUEST_TIMEOUT = 408, + HTTP_STATUS_CODE_CONFLICT = 409, + HTTP_STATUS_CODE_GONE = 410, + HTTP_STATUS_CODE_LENGTH_REQUIRED = 411, + HTTP_STATUS_CODE_PRECONDITION_FAILED = 412, + HTTP_STATUS_CODE_PAYLOAD_TOO_LARGE = 413, + HTTP_STATUS_CODE_URI_TOO_LONG = 414, + HTTP_STATUS_CODE_UNSUPPORTED_MEDIA_TYPE = 415, + HTTP_STATUS_CODE_RANGE_NOT_SATISFIABLE = 416, + HTTP_STATUS_CODE_EXPECTATION_FAILED = 417, + HTTP_STATUS_CODE_MISDIRECTED_REQUEST = 421, + HTTP_STATUS_CODE_UNPROCESSABLE_ENTITY = 422, + HTTP_STATUS_CODE_LOCKED = 423, + HTTP_STATUS_CODE_FAILED_DEPENDENCY = 424, + HTTP_STATUS_CODE_UPGRADE_REQUIRED = 426, + HTTP_STATUS_CODE_PRECONDITION_REQUIRED = 428, + HTTP_STATUS_CODE_TOO_MANY_REQUESTS = 429, + HTTP_STATUS_CODE_REQUEST_HEADER_FIELDS_TOO_LARGE = 431, + HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR = 500, + HTTP_STATUS_CODE_NOT_IMPLEMENTED = 501, + HTTP_STATUS_CODE_BAD_GATEWAY = 502, + HTTP_STATUS_CODE_SERVICE_UNAVAILABLE = 503, + HTTP_STATUS_CODE_GATEWAY_TIMEOUT = 504, + HTTP_STATUS_CODE_HTTP_VERSION_NOT_SUPPORTED = 505, + HTTP_STATUS_CODE_VARIANT_ALSO_NEGOTIATES = 506, + HTTP_STATUS_CODE_INSUFFICIENT_STORAGE = 507, + HTTP_STATUS_CODE_LOOP_DETECTED = 508, + HTTP_STATUS_CODE_NOT_EXTENDED = 510, + HTTP_STATUS_CODE_NETWORK_AUTHENTICATION_REQUIRED = 511 }; class HttpClient : public Client