Skip to content

Commit 3051152

Browse files
authored
Fix #1102 (#1108)
1 parent 06026bb commit 3051152

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

CMakeLists.txt

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,11 @@
6060
]]
6161
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
6262

63-
# On systems without Git installed, there were errors since execute_process seemed to not throw an error without it?
64-
find_package(Git QUIET)
65-
if(Git_FOUND)
66-
# Gets the latest tag as a string like "v0.6.6"
67-
# Can silently fail if git isn't on the system
68-
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
69-
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
70-
OUTPUT_VARIABLE _raw_version_string
71-
ERROR_VARIABLE _git_tag_error
72-
)
73-
endif()
63+
# Get the user agent and use it as a version
64+
# This gets the string with the user agent from the header.
65+
# This is so the maintainer doesn't actually need to update this manually.
66+
file(STRINGS httplib.h _raw_version_string REGEX "User\-Agent.*cpp\-httplib/([0-9]+\.?)+")
7467

75-
# execute_process can fail silenty, so check for an error
76-
# if there was an error, just use the user agent as a version
77-
if(_git_tag_error OR NOT Git_FOUND)
78-
message(WARNING "cpp-httplib failed to find the latest Git tag, falling back to using user agent as the version.")
79-
# Get the user agent and use it as a version
80-
# This gets the string with the user agent from the header.
81-
# This is so the maintainer doesn't actually need to update this manually.
82-
file(STRINGS httplib.h _raw_version_string REGEX "User\-Agent.*cpp\-httplib/([0-9]+\.?)+")
83-
endif()
8468
# Needed since git tags have "v" prefixing them.
8569
# Also used if the fallback to user agent string is being used.
8670
string(REGEX MATCH "([0-9]+\\.?)+" _httplib_version "${_raw_version_string}")

httplib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5978,7 +5978,7 @@ inline bool ClientImpl::write_request(Stream &strm, Request &req,
59785978
if (!req.has_header("Accept")) { req.headers.emplace("Accept", "*/*"); }
59795979

59805980
if (!req.has_header("User-Agent")) {
5981-
req.headers.emplace("User-Agent", "cpp-httplib/0.9");
5981+
req.headers.emplace("User-Agent", "cpp-httplib/0.9.8");
59825982
}
59835983

59845984
if (req.body.empty()) {

0 commit comments

Comments
 (0)