From 3ee1635decda400be826ac32110beb0ecdad2439 Mon Sep 17 00:00:00 2001 From: Sasha Rahlin Date: Wed, 21 Feb 2024 14:53:56 -0500 Subject: [PATCH 1/2] Various compatibility fixes --- CMakeLists.txt | 2 +- src/server.cpp | 7 ++++--- tests/test_module.cpp | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0441155..b510d98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ find_package(pybind11 REQUIRED) include(CTest) add_executable(tuberd src/server.cpp) -target_link_libraries(tuberd PRIVATE boost_program_options fmt::fmt httpserver pybind11::embed) +target_link_libraries(tuberd PRIVATE Boost::program_options fmt::fmt ${LIBHTTPSERVER_LIBRARIES} pybind11::embed) pybind11_add_module(test_module MODULE tests/test_module.cpp) target_include_directories(test_module PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/src/server.cpp b/src/server.cpp index 6be5033..63e5d17 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -222,7 +222,7 @@ class DLL_LOCAL tuber_resource : public http_resource { json_loads(json_loads), json_dumps(json_dumps) {}; - const std::shared_ptr render(const http_request& req) { + std::shared_ptr render(const http_request& req) { /* Acquire the GIL. This makes us thread-safe - * but any methods we invoke should release the * GIL (especially if they do their own @@ -235,7 +235,8 @@ class DLL_LOCAL tuber_resource : public http_resource { fmt::print(stderr, "Request: {}\n", req.get_content()); /* Parse JSON */ - py::object request_obj = json_loads(req.get_content()); + std::string content(req.get_content()); + py::object request_obj = json_loads(content); if(py::isinstance(request_obj)) { /* Simple JSON object - invoke it and return the results. */ @@ -313,7 +314,7 @@ class DLL_LOCAL file_resource : public http_resource { public: file_resource(fs::path webroot, int max_age) : webroot(webroot), max_age(max_age) {}; - const std::shared_ptr render_GET(const http_request& req) { + std::shared_ptr render_GET(const http_request& req) { /* Start with webroot and append path segments from * HTTP request. * diff --git a/tests/test_module.cpp b/tests/test_module.cpp index 215d09b..fdc7c94 100644 --- a/tests/test_module.cpp +++ b/tests/test_module.cpp @@ -18,7 +18,8 @@ class Wrapper { bool is_y(Kind const& k) const { return k == Kind::Y; } std::vector increment(std::vector x) { - std::ranges::for_each(x, [](int &n) { n++; }); + for (auto &i : x) + i++; return x; }; }; From 95e0ec10a4d9e8e13761e84b18129d87ea3a85d0 Mon Sep 17 00:00:00 2001 From: Sasha Rahlin Date: Wed, 21 Feb 2024 16:53:40 -0500 Subject: [PATCH 2/2] update libhttpserver version in github workflow --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 375fa4e..dafa309 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v4 with: repository: etr/libhttpserver - ref: 0.18.2 + ref: 0.19.0 path: libhttpserver - name: Install Python dependencies