Blame SOURCES/http-parser-0001-parser-HTTP_STATUS_MAP-XX-and-enum-http_status.patch

63cc65
From 335850f6b868d3411968cbf5a4d59fe619dee36f Mon Sep 17 00:00:00 2001
63cc65
From: Nathaniel McCallum <npmccallum@redhat.com>
63cc65
Date: Thu, 6 Oct 2016 02:03:36 -0400
63cc65
Subject: [PATCH] parser: HTTP_STATUS_MAP(XX) and enum http_status
63cc65
63cc65
This patch provides an enum for the standardized HTTP status codes.
63cc65
Additionally, the HTTP_STATUS_MAP(XX) can be used for other purposes as
63cc65
well, such as code-to-name lookups and code-based switch statements.
63cc65
63cc65
PR-URL: https://github.com/nodejs/http-parser/pull/337
63cc65
Reviewed-By: Fedor Indutny <fedor@indutny.com>
63cc65
Reviewed-By: Brian White <mscdex@mscdex.net>
63cc65
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
63cc65
---
63cc65
 http_parser.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
63cc65
 1 file changed, 70 insertions(+)
63cc65
63cc65
diff --git a/http_parser.h b/http_parser.h
63cc65
index ea26394..45c72a0 100644
63cc65
--- a/http_parser.h
63cc65
+++ b/http_parser.h
63cc65
@@ -90,6 +90,76 @@ typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
63cc65
 typedef int (*http_cb) (http_parser*);
63cc65
 
63cc65
 
63cc65
+/* Status Codes */
63cc65
+#define HTTP_STATUS_MAP(XX)                                                 \
63cc65
+  XX(100, CONTINUE,                        Continue)                        \
63cc65
+  XX(101, SWITCHING_PROTOCOLS,             Switching Protocols)             \
63cc65
+  XX(102, PROCESSING,                      Processing)                      \
63cc65
+  XX(200, OK,                              OK)                              \
63cc65
+  XX(201, CREATED,                         Created)                         \
63cc65
+  XX(202, ACCEPTED,                        Accepted)                        \
63cc65
+  XX(203, NON_AUTHORITATIVE_INFORMATION,   Non-Authoritative Information)   \
63cc65
+  XX(204, NO_CONTENT,                      No Content)                      \
63cc65
+  XX(205, RESET_CONTENT,                   Reset Content)                   \
63cc65
+  XX(206, PARTIAL_CONTENT,                 Partial Content)                 \
63cc65
+  XX(207, MULTI_STATUS,                    Multi-Status)                    \
63cc65
+  XX(208, ALREADY_REPORTED,                Already Reported)                \
63cc65
+  XX(226, IM_USED,                         IM Used)                         \
63cc65
+  XX(300, MULTIPLE_CHOICES,                Multiple Choices)                \
63cc65
+  XX(301, MOVED_PERMANENTLY,               Moved Permanently)               \
63cc65
+  XX(302, FOUND,                           Found)                           \
63cc65
+  XX(303, SEE_OTHER,                       See Other)                       \
63cc65
+  XX(304, NOT_MODIFIED,                    Not Modified)                    \
63cc65
+  XX(305, USE_PROXY,                       Use Proxy)                       \
63cc65
+  XX(307, TEMPORARY_REDIRECT,              Temporary Redirect)              \
63cc65
+  XX(308, PERMANENT_REDIRECT,              Permanent Redirect)              \
63cc65
+  XX(400, BAD_REQUEST,                     Bad Request)                     \
63cc65
+  XX(401, UNAUTHORIZED,                    Unauthorized)                    \
63cc65
+  XX(402, PAYMENT_REQUIRED,                Payment Required)                \
63cc65
+  XX(403, FORBIDDEN,                       Forbidden)                       \
63cc65
+  XX(404, NOT_FOUND,                       Not Found)                       \
63cc65
+  XX(405, METHOD_NOT_ALLOWED,              Method Not Allowed)              \
63cc65
+  XX(406, NOT_ACCEPTABLE,                  Not Acceptable)                  \
63cc65
+  XX(407, PROXY_AUTHENTICATION_REQUIRED,   Proxy Authentication Required)   \
63cc65
+  XX(408, REQUEST_TIMEOUT,                 Request Timeout)                 \
63cc65
+  XX(409, CONFLICT,                        Conflict)                        \
63cc65
+  XX(410, GONE,                            Gone)                            \
63cc65
+  XX(411, LENGTH_REQUIRED,                 Length Required)                 \
63cc65
+  XX(412, PRECONDITION_FAILED,             Precondition Failed)             \
63cc65
+  XX(413, PAYLOAD_TOO_LARGE,               Payload Too Large)               \
63cc65
+  XX(414, URI_TOO_LONG,                    URI Too Long)                    \
63cc65
+  XX(415, UNSUPPORTED_MEDIA_TYPE,          Unsupported Media Type)          \
63cc65
+  XX(416, RANGE_NOT_SATISFIABLE,           Range Not Satisfiable)           \
63cc65
+  XX(417, EXPECTATION_FAILED,              Expectation Failed)              \
63cc65
+  XX(421, MISDIRECTED_REQUEST,             Misdirected Request)             \
63cc65
+  XX(422, UNPROCESSABLE_ENTITY,            Unprocessable Entity)            \
63cc65
+  XX(423, LOCKED,                          Locked)                          \
63cc65
+  XX(424, FAILED_DEPENDENCY,               Failed Dependency)               \
63cc65
+  XX(426, UPGRADE_REQUIRED,                Upgrade Required)                \
63cc65
+  XX(428, PRECONDITION_REQUIRED,           Precondition Required)           \
63cc65
+  XX(429, TOO_MANY_REQUESTS,               Too Many Requests)               \
63cc65
+  XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \
63cc65
+  XX(451, UNAVAILABLE_FOR_LEGAL_REASONS,   Unavailable For Legal Reasons)   \
63cc65
+  XX(500, INTERNAL_SERVER_ERROR,           Internal Server Error)           \
63cc65
+  XX(501, NOT_IMPLEMENTED,                 Not Implemented)                 \
63cc65
+  XX(502, BAD_GATEWAY,                     Bad Gateway)                     \
63cc65
+  XX(503, SERVICE_UNAVAILABLE,             Service Unavailable)             \
63cc65
+  XX(504, GATEWAY_TIMEOUT,                 Gateway Timeout)                 \
63cc65
+  XX(505, HTTP_VERSION_NOT_SUPPORTED,      HTTP Version Not Supported)      \
63cc65
+  XX(506, VARIANT_ALSO_NEGOTIATES,         Variant Also Negotiates)         \
63cc65
+  XX(507, INSUFFICIENT_STORAGE,            Insufficient Storage)            \
63cc65
+  XX(508, LOOP_DETECTED,                   Loop Detected)                   \
63cc65
+  XX(510, NOT_EXTENDED,                    Not Extended)                    \
63cc65
+  XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \
63cc65
+
63cc65
+enum http_status
63cc65
+  {
63cc65
+#define XX(num, name, string) HTTP_STATUS_##name = num,
63cc65
+  HTTP_STATUS_MAP(XX)
63cc65
+#undef XX
63cc65
+  };
63cc65
+
63cc65
+
63cc65
 /* Request Methods */
63cc65
 #define HTTP_METHOD_MAP(XX)         \
63cc65
   XX(0,  DELETE,      DELETE)       \
63cc65
-- 
63cc65
2.10.2
63cc65