Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/dependencies/cryptopp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ elseif(APPLE)
elseif(UNIX)
pkg_check_modules(cryptopp IMPORTED_TARGET libcrypto++)
if ("${cryptopp_FOUND}" STREQUAL "1")
target_link_libraries(roar-cryptopp INTERFACE PkgConfig::cryptopp)
else()
pkg_check_modules(cryptopp IMPORTED_TARGET libcryptopp)
endif()
target_link_libraries(roar-cryptopp INTERFACE PkgConfig::cryptopp)
endif()
9 changes: 4 additions & 5 deletions include/roar/curl/response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "instance.hpp"

#include <curl/curl.h>
#include <boost/beast/http/status.hpp>

#include <string>

Expand Down Expand Up @@ -50,15 +49,15 @@ namespace Roar::Curl

/**
* @brief Response code.
* @return boost::beast::http::status
* @return int
*/
boost::beast::http::status code() const;
long code() const;

/**
* @brief Response code of the proxy if there was one inbetween.
* @return boost::beast::http::status
* @return int
*/
boost::beast::http::status proxyCode() const;
long proxyCode() const;

/**
* @brief Was there a response to the request?
Expand Down
102 changes: 69 additions & 33 deletions src/roar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,87 @@
add_library(
roar STATIC
server.cpp
client.cpp
mime_type.cpp
mechanics/ranges.cpp
mechanics/cookie.cpp
authorization/authorization.cpp
authorization/basic_auth.cpp
authorization/digest_auth.cpp
filesystem/jail.cpp
filesystem/special_paths.cpp
routing/route.cpp
routing/router.cpp
session/factory.cpp
session/session.cpp
ssl/make_ssl_context.cpp
websocket/websocket_session.cpp
websocket/websocket_client.cpp
websocket/websocket_base.cpp
curl/sources/file_source.cpp
curl/sources/string_source.cpp
curl/global_curl_context.cpp
curl/request.cpp
curl/response.cpp
url/ipv4.cpp
url/ipv6.cpp
url/url.cpp
url/encode.cpp
utility/base64.cpp
utility/shutdown_barrier.cpp
utility/sha.cpp
utility/date.cpp)
server.cpp
client.cpp
mechanics/ranges.cpp
mechanics/cookie.cpp
authorization/authorization.cpp
authorization/basic_auth.cpp
authorization/digest_auth.cpp
routing/route.cpp
routing/router.cpp
session/factory.cpp
session/session.cpp
ssl/make_ssl_context.cpp
websocket/websocket_session.cpp
websocket/websocket_client.cpp
websocket/websocket_base.cpp
utility/shutdown_barrier.cpp
utility/sha.cpp
utility/date.cpp
)

add_library(
roar-curl STATIC
curl/sources/file_source.cpp
curl/sources/string_source.cpp
curl/global_curl_context.cpp
curl/request.cpp
curl/response.cpp
url/encode.cpp
url/ipv4.cpp
url/ipv6.cpp
url/url.cpp
)

add_library(
roar-no-net STATIC
mime_type.cpp
filesystem/special_paths.cpp
utility/base64.cpp
filesystem/jail.cpp
)

include(../../cmake/warnings.cmake)

target_compile_features(roar PUBLIC cxx_std_20)
target_compile_features(roar-no-net PRIVATE cxx_std_20)
target_include_directories(roar-no-net PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
target_link_libraries(
roar-no-net
PUBLIC Boost::boost
)

target_compile_features(roar-curl PRIVATE cxx_std_20)
target_include_directories(roar-curl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
target_link_libraries(
roar-curl
PUBLIC CURL::libcurl roar-no-net
)

target_compile_features(roar PRIVATE cxx_std_20)
target_include_directories(roar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include
${CURL_INCLUDE_DIR})
target_link_libraries(
roar
PUBLIC Boost::boost
promise
roar-cryptopp
CURL::libcurl
OpenSSL::SSL
OpenSSL::Crypto
roar-no-net
roar-curl
)

add_library(roar::roar ALIAS roar)
add_library(roar::no-net ALIAS roar-no-net)
add_library(roar::curl ALIAS roar-curl)

set_target_warnings(roar)
set_target_warnings(roar-no-net)
set_target_warnings(roar-curl)

if(${ROAR_ENABLE_NLOHMANN_JSON})
target_link_libraries(roar-curl PUBLIC nlohmann_json::nlohmann_json)
target_compile_definitions(roar-curl PUBLIC ROAR_ENABLE_NLOHMANN_JSON=1)
target_link_libraries(roar PUBLIC nlohmann_json::nlohmann_json)
target_compile_definitions(roar PUBLIC ROAR_ENABLE_NLOHMANN_JSON=1)
endif()
Expand All @@ -62,14 +94,18 @@ endif()
if(WIN32)
# MS SOCK
target_link_libraries(roar PUBLIC -lws2_32 -lmswsock -lbcrypt)
target_link_libraries(roar-curl PUBLIC -lbcrypt)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# target_compile_definitions(roar PUBLIC BOOST_USE_WINDOWS_H=1)
else()
target_link_libraries(roar PUBLIC -latomic)
target_link_libraries(roar-curl PUBLIC -latomic)
endif()
else()

endif()

set_target_outputs(roar)
set_target_outputs(roar-no-net)
set_target_outputs(roar-curl)
19 changes: 9 additions & 10 deletions src/roar/curl/response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <roar/curl/response.hpp>
#include <roar/curl/instance.hpp>

#include <boost/beast/http/status.hpp>
#include <curl/system.h>

namespace Roar::Curl
Expand Down Expand Up @@ -40,24 +39,24 @@ namespace Roar::Curl
return static_cast<long long>(ul);
return 0;
}
boost::beast::http::status Response::code() const
long Response::code() const
{
long code = 0;
auto res = curl_easy_getinfo(instance_.get(), CURLINFO_RESPONSE_CODE, &code);
if (res == CURLE_OK)
return boost::beast::http::int_to_status(static_cast<unsigned int>(code));
return boost::beast::http::status::unknown;
if (res != CURLE_OK)
return 0;
return code;
}
boost::beast::http::status Response::proxyCode() const
long Response::proxyCode() const
{
long code = 0;
auto res = curl_easy_getinfo(instance_.get(), CURLINFO_HTTP_CONNECTCODE, &code);
if (res == CURLE_OK)
return boost::beast::http::int_to_status(static_cast<unsigned int>(code));
return boost::beast::http::status::unknown;
if (res != CURLE_OK)
return 0;
return code;
}
Response::operator bool() const
{
return code() != boost::beast::http::status::unknown;
return code() != 0;
}
}
Loading