diff --git a/.gitignore b/.gitignore index c3e8ebe..fa8cf92 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /joyent-http-parser-v2.0-7-gcd01361.tar.gz /v2.6.0.tar.gz /v2.7.1.tar.gz +/http-parser-2.7.1.tar.gz diff --git a/http-parser-0001-parser-HTTP_STATUS_MAP-XX-and-enum-http_status.patch b/http-parser-0001-parser-HTTP_STATUS_MAP-XX-and-enum-http_status.patch new file mode 100644 index 0000000..c4f691a --- /dev/null +++ b/http-parser-0001-parser-HTTP_STATUS_MAP-XX-and-enum-http_status.patch @@ -0,0 +1,101 @@ +From 335850f6b868d3411968cbf5a4d59fe619dee36f Mon Sep 17 00:00:00 2001 +From: Nathaniel McCallum +Date: Thu, 6 Oct 2016 02:03:36 -0400 +Subject: [PATCH] parser: HTTP_STATUS_MAP(XX) and enum http_status + +This patch provides an enum for the standardized HTTP status codes. +Additionally, the HTTP_STATUS_MAP(XX) can be used for other purposes as +well, such as code-to-name lookups and code-based switch statements. + +PR-URL: https://github.com/nodejs/http-parser/pull/337 +Reviewed-By: Fedor Indutny +Reviewed-By: Brian White +Reviewed-By: Ben Noordhuis +--- + http_parser.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 70 insertions(+) + +diff --git a/http_parser.h b/http_parser.h +index ea26394..45c72a0 100644 +--- a/http_parser.h ++++ b/http_parser.h +@@ -90,6 +90,76 @@ typedef int (*http_data_cb) (http_parser*, const char *at, size_t length); + typedef int (*http_cb) (http_parser*); + + ++/* Status Codes */ ++#define HTTP_STATUS_MAP(XX) \ ++ XX(100, CONTINUE, Continue) \ ++ XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \ ++ XX(102, PROCESSING, Processing) \ ++ XX(200, OK, OK) \ ++ XX(201, CREATED, Created) \ ++ XX(202, ACCEPTED, Accepted) \ ++ XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \ ++ XX(204, NO_CONTENT, No Content) \ ++ XX(205, RESET_CONTENT, Reset Content) \ ++ XX(206, PARTIAL_CONTENT, Partial Content) \ ++ XX(207, MULTI_STATUS, Multi-Status) \ ++ XX(208, ALREADY_REPORTED, Already Reported) \ ++ XX(226, IM_USED, IM Used) \ ++ XX(300, MULTIPLE_CHOICES, Multiple Choices) \ ++ XX(301, MOVED_PERMANENTLY, Moved Permanently) \ ++ XX(302, FOUND, Found) \ ++ XX(303, SEE_OTHER, See Other) \ ++ XX(304, NOT_MODIFIED, Not Modified) \ ++ XX(305, USE_PROXY, Use Proxy) \ ++ XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \ ++ XX(308, PERMANENT_REDIRECT, Permanent Redirect) \ ++ XX(400, BAD_REQUEST, Bad Request) \ ++ XX(401, UNAUTHORIZED, Unauthorized) \ ++ XX(402, PAYMENT_REQUIRED, Payment Required) \ ++ XX(403, FORBIDDEN, Forbidden) \ ++ XX(404, NOT_FOUND, Not Found) \ ++ XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \ ++ XX(406, NOT_ACCEPTABLE, Not Acceptable) \ ++ XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \ ++ XX(408, REQUEST_TIMEOUT, Request Timeout) \ ++ XX(409, CONFLICT, Conflict) \ ++ XX(410, GONE, Gone) \ ++ XX(411, LENGTH_REQUIRED, Length Required) \ ++ XX(412, PRECONDITION_FAILED, Precondition Failed) \ ++ XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \ ++ XX(414, URI_TOO_LONG, URI Too Long) \ ++ XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \ ++ XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \ ++ XX(417, EXPECTATION_FAILED, Expectation Failed) \ ++ XX(421, MISDIRECTED_REQUEST, Misdirected Request) \ ++ XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \ ++ XX(423, LOCKED, Locked) \ ++ XX(424, FAILED_DEPENDENCY, Failed Dependency) \ ++ XX(426, UPGRADE_REQUIRED, Upgrade Required) \ ++ XX(428, PRECONDITION_REQUIRED, Precondition Required) \ ++ XX(429, TOO_MANY_REQUESTS, Too Many Requests) \ ++ XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \ ++ XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \ ++ XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \ ++ XX(501, NOT_IMPLEMENTED, Not Implemented) \ ++ XX(502, BAD_GATEWAY, Bad Gateway) \ ++ XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \ ++ XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \ ++ XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \ ++ XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \ ++ XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \ ++ XX(508, LOOP_DETECTED, Loop Detected) \ ++ XX(510, NOT_EXTENDED, Not Extended) \ ++ XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \ ++ ++enum http_status ++ { ++#define XX(num, name, string) HTTP_STATUS_##name = num, ++ HTTP_STATUS_MAP(XX) ++#undef XX ++ }; ++ ++ + /* Request Methods */ + #define HTTP_METHOD_MAP(XX) \ + XX(0, DELETE, DELETE) \ +-- +2.10.2 + diff --git a/http-parser-gyp-sharedlib.patch b/http-parser-gyp-sharedlib.patch deleted file mode 100644 index 3687b67..0000000 --- a/http-parser-gyp-sharedlib.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- http_parser.gyp~ 2012-11-27 15:40:11.721398004 -0700 -+++ http_parser.gyp 2012-11-27 15:40:11.721398004 -0700 -@@ -12,7 +12,7 @@ - # RuntimeLibrary MUST MATCH across the entire project - 'Debug': { - 'defines': [ 'DEBUG', '_DEBUG' ], -- 'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ], -+ 'cflags': [ '-Wall', '-Wextra', '-g', '-ftrapv' ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'RuntimeLibrary': 1, # static debug -@@ -21,7 +21,7 @@ - }, - 'Release': { - 'defines': [ 'NDEBUG' ], -- 'cflags': [ '-Wall', '-Wextra', '-O3' ], -+ 'cflags': [ '-Wall', '-Wextra' ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'RuntimeLibrary': 0, # static release -@@ -50,7 +50,8 @@ - 'targets': [ - { - 'target_name': 'http_parser', -- 'type': 'static_library', -+ 'type': 'shared_library', -+ 'product_extension': 'so.2', - 'include_dirs': [ '.' ], - 'direct_dependent_settings': { - 'defines': [ 'HTTP_PARSER_STRICT=0' ], -@@ -73,7 +74,8 @@ - - { - 'target_name': 'http_parser_strict', -- 'type': 'static_library', -+ 'type': 'shared_library', -+ 'product_extension': 'so.2', - 'include_dirs': [ '.' ], - 'direct_dependent_settings': { - 'defines': [ 'HTTP_PARSER_STRICT=1' ], diff --git a/http-parser-status.patch b/http-parser-status.patch deleted file mode 100644 index 451104c..0000000 --- a/http-parser-status.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 335850f6b868d3411968cbf5a4d59fe619dee36f Mon Sep 17 00:00:00 2001 -From: Nathaniel McCallum -Date: Thu, 6 Oct 2016 02:03:36 -0400 -Subject: [PATCH] parser: HTTP_STATUS_MAP(XX) and enum http_status - -This patch provides an enum for the standardized HTTP status codes. -Additionally, the HTTP_STATUS_MAP(XX) can be used for other purposes as -well, such as code-to-name lookups and code-based switch statements. - -PR-URL: https://github.com/nodejs/http-parser/pull/337 -Reviewed-By: Fedor Indutny -Reviewed-By: Brian White -Reviewed-By: Ben Noordhuis ---- - http_parser.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 70 insertions(+) - -diff --git a/http_parser.h b/http_parser.h -index ea26394..45c72a0 100644 ---- a/http_parser.h -+++ b/http_parser.h -@@ -90,6 +90,76 @@ typedef int (*http_data_cb) (http_parser*, const char *at, size_t length); - typedef int (*http_cb) (http_parser*); - - -+/* Status Codes */ -+#define HTTP_STATUS_MAP(XX) \ -+ XX(100, CONTINUE, Continue) \ -+ XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \ -+ XX(102, PROCESSING, Processing) \ -+ XX(200, OK, OK) \ -+ XX(201, CREATED, Created) \ -+ XX(202, ACCEPTED, Accepted) \ -+ XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \ -+ XX(204, NO_CONTENT, No Content) \ -+ XX(205, RESET_CONTENT, Reset Content) \ -+ XX(206, PARTIAL_CONTENT, Partial Content) \ -+ XX(207, MULTI_STATUS, Multi-Status) \ -+ XX(208, ALREADY_REPORTED, Already Reported) \ -+ XX(226, IM_USED, IM Used) \ -+ XX(300, MULTIPLE_CHOICES, Multiple Choices) \ -+ XX(301, MOVED_PERMANENTLY, Moved Permanently) \ -+ XX(302, FOUND, Found) \ -+ XX(303, SEE_OTHER, See Other) \ -+ XX(304, NOT_MODIFIED, Not Modified) \ -+ XX(305, USE_PROXY, Use Proxy) \ -+ XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \ -+ XX(308, PERMANENT_REDIRECT, Permanent Redirect) \ -+ XX(400, BAD_REQUEST, Bad Request) \ -+ XX(401, UNAUTHORIZED, Unauthorized) \ -+ XX(402, PAYMENT_REQUIRED, Payment Required) \ -+ XX(403, FORBIDDEN, Forbidden) \ -+ XX(404, NOT_FOUND, Not Found) \ -+ XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \ -+ XX(406, NOT_ACCEPTABLE, Not Acceptable) \ -+ XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \ -+ XX(408, REQUEST_TIMEOUT, Request Timeout) \ -+ XX(409, CONFLICT, Conflict) \ -+ XX(410, GONE, Gone) \ -+ XX(411, LENGTH_REQUIRED, Length Required) \ -+ XX(412, PRECONDITION_FAILED, Precondition Failed) \ -+ XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \ -+ XX(414, URI_TOO_LONG, URI Too Long) \ -+ XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \ -+ XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \ -+ XX(417, EXPECTATION_FAILED, Expectation Failed) \ -+ XX(421, MISDIRECTED_REQUEST, Misdirected Request) \ -+ XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \ -+ XX(423, LOCKED, Locked) \ -+ XX(424, FAILED_DEPENDENCY, Failed Dependency) \ -+ XX(426, UPGRADE_REQUIRED, Upgrade Required) \ -+ XX(428, PRECONDITION_REQUIRED, Precondition Required) \ -+ XX(429, TOO_MANY_REQUESTS, Too Many Requests) \ -+ XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \ -+ XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \ -+ XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \ -+ XX(501, NOT_IMPLEMENTED, Not Implemented) \ -+ XX(502, BAD_GATEWAY, Bad Gateway) \ -+ XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \ -+ XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \ -+ XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \ -+ XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \ -+ XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \ -+ XX(508, LOOP_DETECTED, Loop Detected) \ -+ XX(510, NOT_EXTENDED, Not Extended) \ -+ XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \ -+ -+enum http_status -+ { -+#define XX(num, name, string) HTTP_STATUS_##name = num, -+ HTTP_STATUS_MAP(XX) -+#undef XX -+ }; -+ -+ - /* Request Methods */ - #define HTTP_METHOD_MAP(XX) \ - XX(0, DELETE, DELETE) \ diff --git a/http-parser.spec b/http-parser.spec index 549dfa3..10fb86f 100644 --- a/http-parser.spec +++ b/http-parser.spec @@ -5,23 +5,18 @@ Name: http-parser Version: %{somajor}.%{sominor}.%{sopoint} -Release: 3%{?dist} +Release: 4%{?dist} Summary: HTTP request/response parser for C -Group: System Environment/Libraries License: MIT -URL: http://github.com/joyent/http-parser +URL: https://github.com/nodejs/http-parser +Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz -Source0: https://github.com/nodejs/http-parser/archive/v%{version}.tar.gz -BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +# https://github.com/nodejs/http-parser/commit/335850f6b868d3411968cbf5a4d59fe619dee36f +Patch0001: %{name}-0001-parser-HTTP_STATUS_MAP-XX-and-enum-http_status.patch -# Build shared library with SONAME using gyp and remove -O flags so optflags take over -# TODO: do this nicely upstream -Patch1: http-parser-gyp-sharedlib.patch -Patch2: http-parser-status.patch - -BuildRequires: gyp -BuildRequires: util-linux +BuildRequires: gcc +BuildRequires: cmake %description This is a parser for HTTP messages written in C. It parses both requests and @@ -31,76 +26,84 @@ be interrupted at anytime. Depending on your architecture, it only requires about 40 bytes of data per message stream (in a web server that is per connection). - %package devel -Group: Development/Libraries Summary: Development headers and libraries for http-parser -Requires: %{name} = %{version}-%{release} +Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} %description devel Development headers and libraries for http-parser. - %prep -%autosetup -n http-parser-%{version} - +%autosetup -p1 +# TODO: try to send upstream? +cat > CMakeLists.txt << EOF +cmake_minimum_required (VERSION 2.8.5) +project (http-parser C) +include (GNUInstallDirs) + +set (SRCS http_parser.c) +set (HDRS http_parser.h) +set (TEST_SRCS test.c) + +# Non-Strict version +add_library (http_parser \${SRCS}) +target_compile_definitions (http_parser + PUBLIC -DHTTP_PARSER_STRICT=0) +add_executable (test-nonstrict \${TEST_SRCS}) +target_link_libraries (test-nonstrict http_parser) +# Strict version +add_library (http_parser_strict \${SRCS}) +target_compile_definitions (http_parser_strict + PUBLIC -DHTTP_PARSER_STRICT=1) +add_executable (test-strict \${TEST_SRCS}) +target_link_libraries (test-strict http_parser_strict) + +set_target_properties (http_parser http_parser_strict + PROPERTIES + SOVERSION %{somajor} + VERSION %{version}) + +install (TARGETS http_parser http_parser_strict + LIBRARY DESTINATION \${CMAKE_INSTALL_LIBDIR}) +install (FILES \${HDRS} + DESTINATION \${CMAKE_INSTALL_INCLUDEDIR}) + +enable_testing () +add_test (NAME test-nonstrict COMMAND test-nonstrict) +add_test (NAME test-strict COMMAND test-strict) +EOF %build -# TODO: fix -fPIC upstream -export CFLAGS='%{optflags} -fPIC' -gyp -f make --depth=`pwd` http_parser.gyp -make %{?_smp_mflags} BUILDTYPE=Release - +mkdir %{_target_platform} +pushd %{_target_platform} + %cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo +popd +%make_build -C %{_target_platform} %install -rm -rf %{buildroot} - -install -d %{buildroot}%{_includedir} -install -d %{buildroot}%{_libdir} - -install -pm644 http_parser.h %{buildroot}%{_includedir} - -#install regular variant -install out/Release/lib.target/libhttp_parser.so.%{somajor} %{buildroot}%{_libdir}/libhttp_parser.so.%{somajor}.%{sominor} -ln -sf libhttp_parser.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser.so.%{somajor} -ln -sf libhttp_parser.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser.so - -#install strict variant -install out/Release/lib.target/libhttp_parser_strict.so.%{somajor} %{buildroot}%{_libdir}/libhttp_parser_strict.so.%{somajor}.%{sominor} -ln -sf libhttp_parser_strict.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser_strict.so.%{somajor} -ln -sf libhttp_parser_strict.so.%{somajor}.%{sominor} %{buildroot}%{_libdir}/libhttp_parser_strict.so - +%make_install -C %{_target_platform} %check -export LD_LIBRARY_PATH='./out/Release/lib.target' -./out/Release/test-nonstrict -./out/Release/test-strict - - -%clean -rm -rf %{buildroot} - +make test -C %{_target_platform} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig - %files -%defattr(-,root,root,-) %{_libdir}/libhttp_parser.so.* %{_libdir}/libhttp_parser_strict.so.* %doc AUTHORS README.md %license LICENSE-MIT - %files devel -%defattr(-,root,root,-) -%{_includedir}/* +%{_includedir}/http_parser.h %{_libdir}/libhttp_parser.so %{_libdir}/libhttp_parser_strict.so - %changelog +* Mon Nov 21 2016 Igor Gnatenko - 2.7.1-4 +- Use CMake buildsystem + * Tue Oct 25 2016 Nathaniel McCallum - 2.7.1-3 - Add (upstreamed) status code patch diff --git a/sources b/sources index b9c40b2..29124e7 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -31c6fefb6208b16d19b3f990e71cb04a v2.7.1.tar.gz +31c6fefb6208b16d19b3f990e71cb04a http-parser-2.7.1.tar.gz