Create method_strings array with HTTP_METHOD_MAP macro.

v0.10
Ben Noordhuis 13 years ago
parent a3373d7627
commit 8bec3ea459

@ -123,32 +123,10 @@ do { \
static const char *method_strings[] = static const char *method_strings[] =
{ "DELETE" {
, "GET" #define XX(num, name, string) #string,
, "HEAD" HTTP_METHOD_MAP(XX)
, "POST" #undef XX
, "PUT"
, "CONNECT"
, "OPTIONS"
, "TRACE"
, "COPY"
, "LOCK"
, "MKCOL"
, "MOVE"
, "PROPFIND"
, "PROPPATCH"
, "SEARCH"
, "UNLOCK"
, "REPORT"
, "MKACTIVITY"
, "CHECKOUT"
, "MERGE"
, "M-SEARCH"
, "NOTIFY"
, "SUBSCRIBE"
, "UNSUBSCRIBE"
, "PATCH"
, "PURGE"
}; };

@ -85,44 +85,44 @@ typedef int (*http_cb) (http_parser*);
/* Request Methods */ /* Request Methods */
#define HTTP_METHOD_MAP(XX) \ #define HTTP_METHOD_MAP(XX) \
XX(0, DELETE) \ XX(0, DELETE, DELETE) \
XX(1, GET) \ XX(1, GET, GET) \
XX(2, HEAD) \ XX(2, HEAD, HEAD) \
XX(3, POST) \ XX(3, POST, POST) \
XX(4, PUT) \ XX(4, PUT, PUT) \
/* pathological */ \ /* pathological */ \
XX(5, CONNECT) \ XX(5, CONNECT, CONNECT) \
XX(6, OPTIONS) \ XX(6, OPTIONS, OPTIONS) \
XX(7, TRACE) \ XX(7, TRACE, TRACE) \
/* webdav */ \ /* webdav */ \
XX(8, COPY) \ XX(8, COPY, COPY) \
XX(9, LOCK) \ XX(9, LOCK, LOCK) \
XX(10, MKCOL) \ XX(10, MKCOL, MKCOL) \
XX(11, MOVE) \ XX(11, MOVE, MOVE) \
XX(12, PROPFIND) \ XX(12, PROPFIND, PROPFIND) \
XX(13, PROPPATCH) \ XX(13, PROPPATCH, PROPPATCH) \
XX(14, SEARCH) \ XX(14, SEARCH, SEARCH) \
XX(15, UNLOCK) \ XX(15, UNLOCK, UNLOCK) \
/* subversion */ \ /* subversion */ \
XX(16, REPORT) \ XX(16, REPORT, REPORT) \
XX(17, MKACTIVITY) \ XX(17, MKACTIVITY, MKACTIVITY) \
XX(18, CHECKOUT) \ XX(18, CHECKOUT, CHECKOUT) \
XX(19, MERGE) \ XX(19, MERGE, MERGE) \
/* upnp */ \ /* upnp */ \
XX(20, MSEARCH) \ XX(20, MSEARCH, M-SEARCH) \
XX(21, NOTIFY) \ XX(21, NOTIFY, NOTIFY) \
XX(22, SUBSCRIBE) \ XX(22, SUBSCRIBE, SUBSCRIBE) \
XX(23, UNSUBSCRIBE) \ XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \
/* RFC-5789 */ \ /* RFC-5789 */ \
XX(24, PATCH) \ XX(24, PATCH, PATCH) \
XX(25, PURGE) \ XX(25, PURGE, PURGE) \
enum http_method enum http_method
{ {
#define XX(num, name) HTTP_##name = num, #define XX(num, name, string) HTTP_##name = num,
HTTP_METHOD_MAP(XX) HTTP_METHOD_MAP(XX)
#undef X #undef XX
}; };

Loading…
Cancel
Save