Skip to content

Commit

Permalink
Replace http-parser with llhttp
Browse files Browse the repository at this point in the history
llhttp does not include URL parser.  We extracted URL parser code from
http-parser and put it under third-party/url-parser.

llhttp bd3d224eb8cdc92c6fc8f508d7bbe0ba266e8e92
  • Loading branch information
tatsuhiro-t committed Apr 20, 2019
1 parent f028cc4 commit c64d257
Show file tree
Hide file tree
Showing 51 changed files with 8,059 additions and 8,407 deletions.
21 changes: 16 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if(ENABLE_EXAMPLES)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
"${CMAKE_CURRENT_SOURCE_DIR}/../third-party"
"${CMAKE_CURRENT_SOURCE_DIR}/../third-party/llhttp/include"

${LIBEVENT_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIRS}
Expand All @@ -21,14 +22,24 @@ if(ENABLE_EXAMPLES)
${APP_LIBRARIES}
)

add_executable(client client.c $<TARGET_OBJECTS:http-parser>)
add_executable(libevent-client libevent-client.c $<TARGET_OBJECTS:http-parser>)
add_executable(libevent-server libevent-server.c $<TARGET_OBJECTS:http-parser>)
add_executable(deflate deflate.c $<TARGET_OBJECTS:http-parser>)
add_executable(client client.c $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
add_executable(libevent-client libevent-client.c $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
add_executable(libevent-server libevent-server.c $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
add_executable(deflate deflate.c $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)

if(ENABLE_ASIO_LIB)
foreach(name asio-sv asio-sv2 asio-cl asio-cl2)
add_executable(${name} ${name}.cc $<TARGET_OBJECTS:http-parser>)
add_executable(${name} ${name}.cc $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
target_include_directories(${name} PRIVATE
${OPENSSL_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
Expand Down
4 changes: 2 additions & 2 deletions examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AM_CPPFLAGS = \
@OPENSSL_CFLAGS@ \
@DEFS@
LDADD = $(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la \
$(top_builddir)/third-party/liburl-parser.la \
@LIBEVENT_OPENSSL_LIBS@ \
@OPENSSL_LIBS@ \
@APPLDFLAGS@
Expand All @@ -61,7 +61,7 @@ noinst_PROGRAMS += asio-sv asio-sv2 asio-cl asio-cl2
ASIOCPPFLAGS = ${AM_CPPFLAGS} ${BOOST_CPPFLAGS}
ASIOLDADD = $(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/src/libnghttp2_asio.la @JEMALLOC_LIBS@ \
$(top_builddir)/third-party/libhttp-parser.la \
$(top_builddir)/third-party/liburl-parser.la \
@OPENSSL_LIBS@ \
${BOOST_LDFLAGS} \
${BOOST_ASIO_LIB} \
Expand Down
2 changes: 1 addition & 1 deletion examples/libevent-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ char *strndup(const char *s, size_t size);

#include <nghttp2/nghttp2.h>

#include "http-parser/http_parser.h"
#include "url-parser/url_parser.h"

#define ARRLEN(x) (sizeof(x) / sizeof(x[0]))

Expand Down
70 changes: 35 additions & 35 deletions genmethodfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@

from gentokenlookup import gentokenlookup

# copied from http-parser/http_parser.h, and stripped trailing spaces
# and backslashes.
# copied from llhttp.h, and stripped trailing spaces and backslashes.
SRC = '''
XX(0, DELETE, DELETE)
XX(1, GET, GET)
XX(2, HEAD, HEAD)
XX(3, POST, POST)
XX(4, PUT, PUT)
/* pathological */
XX(5, CONNECT, CONNECT)
XX(6, OPTIONS, OPTIONS)
XX(7, TRACE, TRACE)
/* webdav */
XX(8, COPY, COPY)
XX(9, LOCK, LOCK)
XX(10, MKCOL, MKCOL)
XX(11, MOVE, MOVE)
XX(12, PROPFIND, PROPFIND)
XX(13, PROPPATCH, PROPPATCH)
XX(14, SEARCH, SEARCH)
XX(15, UNLOCK, UNLOCK)
/* subversion */
XX(16, REPORT, REPORT)
XX(17, MKACTIVITY, MKACTIVITY)
XX(18, CHECKOUT, CHECKOUT)
XX(19, MERGE, MERGE)
/* upnp */
XX(20, MSEARCH, M-SEARCH)
XX(21, NOTIFY, NOTIFY)
XX(22, SUBSCRIBE, SUBSCRIBE)
XX(23, UNSUBSCRIBE, UNSUBSCRIBE)
/* RFC-5789 */
XX(24, PATCH, PATCH)
XX(25, PURGE, PURGE)
/* CalDAV */
XX(26, MKCALENDAR, MKCALENDAR)
XX(0, DELETE, DELETE)
XX(1, GET, GET)
XX(2, HEAD, HEAD)
XX(3, POST, POST)
XX(4, PUT, PUT)
XX(5, CONNECT, CONNECT)
XX(6, OPTIONS, OPTIONS)
XX(7, TRACE, TRACE)
XX(8, COPY, COPY)
XX(9, LOCK, LOCK)
XX(10, MKCOL, MKCOL)
XX(11, MOVE, MOVE)
XX(12, PROPFIND, PROPFIND)
XX(13, PROPPATCH, PROPPATCH)
XX(14, SEARCH, SEARCH)
XX(15, UNLOCK, UNLOCK)
XX(16, BIND, BIND)
XX(17, REBIND, REBIND)
XX(18, UNBIND, UNBIND)
XX(19, ACL, ACL)
XX(20, REPORT, REPORT)
XX(21, MKACTIVITY, MKACTIVITY)
XX(22, CHECKOUT, CHECKOUT)
XX(23, MERGE, MERGE)
XX(24, MSEARCH, M-SEARCH)
XX(25, NOTIFY, NOTIFY)
XX(26, SUBSCRIBE, SUBSCRIBE)
XX(27, UNSUBSCRIBE, UNSUBSCRIBE)
XX(28, PATCH, PATCH)
XX(29, PURGE, PURGE)
XX(30, MKCALENDAR, MKCALENDAR)
XX(31, LINK, LINK)
XX(32, UNLINK, UNLINK)
XX(33, SOURCE, SOURCE)
'''

if __name__ == '__main__':
Expand Down
23 changes: 17 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set_source_files_properties(${cxx_sources} PROPERTIES
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
"${CMAKE_CURRENT_SOURCE_DIR}/../third-party"
"${CMAKE_CURRENT_SOURCE_DIR}/../third-party/llhttp/include"

${JEMALLOC_INCLUDE_DIRS}
${SPDYLAY_INCLUDE_DIRS}
Expand Down Expand Up @@ -166,7 +167,8 @@ if(ENABLE_APP)
)
add_executable(nghttpx-unittest EXCLUDE_FROM_ALL
${NGHTTPX_UNITTEST_SOURCES}
$<TARGET_OBJECTS:http-parser>
$<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
target_include_directories(nghttpx-unittest PRIVATE ${CUNIT_INCLUDE_DIRS})
target_compile_definitions(nghttpx-unittest
Expand All @@ -184,12 +186,20 @@ if(ENABLE_APP)
add_dependencies(check nghttpx-unittest)
endif()

add_executable(nghttp ${NGHTTP_SOURCES} $<TARGET_OBJECTS:http-parser>)
add_executable(nghttpd ${NGHTTPD_SOURCES} $<TARGET_OBJECTS:http-parser>)
add_executable(nghttpx ${NGHTTPX-bin_SOURCES} $<TARGET_OBJECTS:http-parser>)
add_executable(nghttp ${NGHTTP_SOURCES} $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
add_executable(nghttpd ${NGHTTPD_SOURCES} $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
add_executable(nghttpx ${NGHTTPX-bin_SOURCES} $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
target_compile_definitions(nghttpx PRIVATE "-DPKGDATADIR=\"${PKGDATADIR}\"")
target_link_libraries(nghttpx nghttpx_static)
add_executable(h2load ${H2LOAD_SOURCES} $<TARGET_OBJECTS:http-parser>)
add_executable(h2load ${H2LOAD_SOURCES} $<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)

install(TARGETS nghttp nghttpd nghttpx h2load
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
Expand Down Expand Up @@ -243,7 +253,8 @@ if(ENABLE_ASIO_LIB)

add_library(nghttp2_asio SHARED
${NGHTTP2_ASIO_SOURCES}
$<TARGET_OBJECTS:http-parser>
$<TARGET_OBJECTS:llhttp>
$<TARGET_OBJECTS:url-parser>
)
target_include_directories(nghttp2_asio PRIVATE
${OPENSSL_INCLUDE_DIRS}
Expand Down
7 changes: 5 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/src/includes \
-I$(top_srcdir)/third-party \
-I$(top_srcdir)/third-party/llhttp/include \
@LIBXML2_CFLAGS@ \
@LIBEV_CFLAGS@ \
@OPENSSL_CFLAGS@ \
Expand All @@ -49,7 +50,8 @@ AM_CPPFLAGS = \
@DEFS@

LDADD = $(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la \
$(top_builddir)/third-party/liburl-parser.la \
$(top_builddir)/third-party/libllhttp.la \
@JEMALLOC_LIBS@ \
@LIBXML2_LIBS@ \
@LIBEV_LIBS@ \
Expand Down Expand Up @@ -263,7 +265,8 @@ libnghttp2_asio_la_CPPFLAGS = ${AM_CPPFLAGS} ${BOOST_CPPFLAGS}
libnghttp2_asio_la_LDFLAGS = -no-undefined -version-info 1:0:0
libnghttp2_asio_la_LIBADD = \
$(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la \
$(top_builddir)/third-party/liburl-parser.la \
$(top_builddir)/third-party/libllhttp.la \
@OPENSSL_LIBS@ \
${BOOST_LDFLAGS} \
${BOOST_ASIO_LIB} \
Expand Down
2 changes: 1 addition & 1 deletion src/h2load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#include <openssl/err.h>

#include "http-parser/http_parser.h"
#include "url-parser/url_parser.h"

#include "h2load_http1_session.h"
#include "h2load_http2_session.h"
Expand Down
Loading

0 comments on commit c64d257

Please sign in to comment.