Skip to content

Commit fb529a0

Browse files
committed
http-parser: use our bundled http-parser by default
Our bundled http-parser includes bugfixes, therefore we should prefer our http-parser until such time as we can identify that the system http-parser has these bugfixes (using a version check). Since these bugs are - at present - minor, retain the ability for users to force that they want to use the system http-parser anyway. This does change the cmake specification so that people _must_ opt-in to the new behavior knowingly.
1 parent 1bbdec6 commit fb529a0

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
6060
OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
6161
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
6262
OPTION(VALGRIND "Configure build for valgrind" OFF)
63-
OPTION(USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
6463
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
6564
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
6665
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
66+
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
6767
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
6868
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
6969

docs/changelog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
v0.28 + 1
2+
---------
3+
4+
### Breaking CMake configuration changes
5+
6+
* The CMake option to use a system http-parser library, instead of the
7+
bundled dependency, has changed. This is due to a deficiency in
8+
http-parser that we have fixed in our implementation. The bundled
9+
library is now the default, but if you wish to force the use of the
10+
system http-parser implementation despite incompatibilities, you can
11+
specify `-DUSE_HTTP_PARSER=system` to CMake.
12+
13+
### Changes or improvements
14+
15+
* libgit2 can now correctly cope with URLs where the host contains a colon
16+
but a port is not specified. (eg `http://example.com:/repo.git`).
17+
118
v0.28
219
-----
320

src/CMakeLists.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,17 @@ ELSE()
340340
ENDIF()
341341

342342
# Optional external dependency: http-parser
343-
FIND_PACKAGE(HTTP_Parser)
344-
IF (USE_EXT_HTTP_PARSER AND HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
345-
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
346-
LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
347-
LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
348-
ADD_FEATURE_INFO(http-parser ON "http-parser support")
343+
IF(USE_HTTP_PARSER STREQUAL "system")
344+
FIND_PACKAGE(HTTP_Parser)
345+
346+
IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
347+
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
348+
LIST(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
349+
LIST(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
350+
ADD_FEATURE_INFO(http-parser ON "http-parser support (system)")
351+
ELSE()
352+
MESSAGE(FATAL_ERROR "http-parser support was requested but not found")
353+
ENDIF()
349354
ELSE()
350355
MESSAGE(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
351356
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")

0 commit comments

Comments
 (0)