jgaa / restc-cpp Goto Github PK
View Code? Open in Web Editor NEWModern C++ REST Client library
License: MIT License
Modern C++ REST Client library
License: MIT License
Connections are not being released to the pool once all data is read.
I am using this library to test my REST server.
I want to create a test that will fail on purpose and the server response code must be 4xx
(or 401
Unauthorized).
I don't know how to achieve that because any server response that is not 200 is considered fail and this library throws an exception. The exception has only the error message e.what()
without details about the fail (in my case I need server response code)
auto restClient = RestClient::Create();
std::unique_ptr<Reply> reply;
restClient->Process([&reply](Context& ctx){
try {
reply = ctx.Get("http://localhost/");
} catch (const std::exception& e) {
// I need server response code here
}
});
restClient->CloseWhenReady(true);
Fails under Windows and Linux
The current implementation works only on the root-level of the serialization. We need to map the mapping to a class, so that it works also for recursive properties.
One potential implementation is to use traits, where the mapping is pinned to a class at compile-time trough templates. Another option is to make the mapping configurable during runtime, by assigning it to classid's, and provide a list of such mappings to the serializer.
I followed this: https://github.com/jgaa/restc-cpp/wiki/Building-under-Linux
But it fails to build with error:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
Thanks for providing this interesting library. I would like to use it for mobile plateforms.
Before starting I have some questions.
Regards
Make a conan build in the CI environment if I can get it to work.
vcpkg is the package manager from Microsoft for Visual Studio. Please consider adding restc-cpp to vcpkg.
Its dependencies (boost, openssl, rapidjson, zlib) are already there. Also restc-cpp build is CMake based. It should be straightforward to add it.
I am running into multiple problems:
a) My depencies (boost, OpenSSL, zlib, etc.) are not installed under C:\devel...
I install my dependencies using the conan package manager. I changed the paths in the CMake files you provided with the source code.
I also included the conanbuildinfo.cmake file which is generated by conan.
That way I could create a solution for Visual Studio 2015 using CMake.
But I cannot build it. It complains about the libs from boost being missing: LNK1104 cannot open file 'libboost_log-vc140-mt-1_63.lib'
In the Windows ecosystem, the boost libraries are build with these names following this file name pattern: "boost_log-vc140-mt-1_63.lib"
I want to try your lib. Can you please help me getting my workspace to build?
The conan build has some problems under Windows:
Trying to use this library as part of a c++17 project.
Getting: restc-cpp/helper.h(23): error C2039: 'binary_function': is not a member of 'std'
it's deprecated. According to the stackoverflow link in the file, it can just be removed:
struct ciLessLibC //: public std::binary_function<std::string, std::string, bool>
When deserialising a nested JSON array, i.e. an array containing arrays, an assertion in the restc-cpp code fails (in Debug) or a ParseException is thrown (in Release).
Example JSON string: [ [1,2,3],[4,5,6],[7,8,9]]
Deserialisation target
std:vector<std::vector<int>>
In Debug, results in a failed assertion:
restc_cpp::RapidJsonDeserializer<std::vector<std::vector<int,std::allocator<int> >,std::allocator<std::vector<int,std::allocator<int> > > > >::DoStartArray() Line 1074
In release the following exception will be thrown:
Assign_value: Invalid data conversion from class std::vector<int,class std::allocator > to unsigned int
Is there a workaround for this?
Rick
Hi, I am trying to fetch movie information from a Movie API. However, I get
libc++abi.dylib: terminating with uncaught exception of type restc_cpp::HttpNotFoundException: Request failed with HTTP error: 404 Not Found
trying to do so and wish to know how do I change the struct to fit the API.
#include <iostream>
#include <boost/lexical_cast.hpp>
#include <boost/fusion/adapted.hpp>
#include "restc-cpp/restc-cpp.h"
#include "restc-cpp/RequestBuilder.h"
using namespace std;
using namespace restc_cpp;
struct Movie {
int page = 0;
int total_results = 0;
int total_pages = 0;
};
BOOST_FUSION_ADAPT_STRUCT(
Movie,
(int, page)
(int, total_results)
(int, total_pages)
)
int main() {
auto rest_client = RestClient::Create();
Movie found_movies = rest_client->ProcessWithPromiseT<Movie>([&](Context& ctx) {
Movie movie;
SerializeFromJson(movie,
RequestBuilder(ctx)
.Get("https://api.themoviedb.org/3/search/movie?api_key=30ac911b5a4841e65d905a53b31396ae&query=Jack+Reacher")
.Header("X-Client", "RESTC_CPP")
.Header("X-Client-Purpose", "Testing")
.Execute());
return movie;
}).get();
cout << "Number of Results " << found_movies.total_results << ", Page: " << found_movies.page << endl;
}
See if we can get an confirmation from the server before sending potentially expensive payloads. That means that we can handle server errors and redirects before sending any payload.
Hello
I use CLion as my IDE. I've been trying to run some of the tests (basic_tests, crud_tests) as well as some of the examples, just trying to get familiar with the code, but I keep getting the same error all the time:
Undefined symbols for architecture x86_64:
"_SSL_COMP_free_compression_methods", referenced from:
boost::asio::ssl::detail::openssl_init_base::do_init::~do_init() in librestc-cppD.a(ConnectionPoolImpl.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do I need to change some of the CMakeList.txt to add some -l... options?
Thanks
Javier
Lines 24 to 26 in 5fafdbd
If possible at the current implementation status, I would like to have a stable release (not a pre release) available.
I think it makes sense to have a stable release as I want to have this package available via the conan package manager.
But before I make a request to create a conan package from this library, it would help to have a stable version so the acceptance (by both the package creator and the users of the package) might be increased
Hello
Firstable thanks for a lot for all your work on this, I'm really looking forward to use it and play with it. I've been trying to build the project using instructions on:
https://github.com/jgaa/restc-cpp/wiki/Building-under-macOS
but when running make I'm getting a lot of errors.
I wonder if you could point me out in what the problem could be? I'm doing this in my Mac running High Sierra and with this compiler version:
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
Thanks a lot
Javier
..... errors from this point onward, before this is all building ok ...
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:23:
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/helper.h:39:19: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for(const auto& it : *src) {
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/helper.h:39:28: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for(const auto& it : *src) {
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/helper.h:54:5: error: expected member name or ';' after declaration specifiers
{
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/helper.h:53:11: error: expected '('
: buf_{stream.str()}
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/helper.h:53:24: error: expected ';' after expression
: buf_{stream.str()}
^
;
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/tests/unit/AsyncSleepTests.cpp:13:
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:24:
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/Connection.h:15:19: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using ptr_t = std::shared_ptr;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/Connection.h:17:10: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class Type {
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/Connection.h:22:29: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
virtual ~Connection() = default;
^
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/tests/unit/AsyncSleepTests.cpp:13:
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:64:25: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using write_buffers_t = std::vectorboost::asio::const_buffer;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:70:17: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Arg() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:71:27: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Arg(const Arg&) = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:74:25: error: expected member name or ';' after declaration specifiers
: name{use_name}, value{use_value} {}
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:84:18: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Auth() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:85:29: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Auth(const Auth&) = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:86:18: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Auth(Auth&&) = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:86:24: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Auth(Auth&&) = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:88:25: error: expected member name or ';' after declaration specifiers
: name{authName}, passwd{authPasswd} {}
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:96:31: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
Auth& operator = (Auth&&) = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:96:37: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
Auth& operator = (Auth&&) = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:103:14: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class Type { NONE, HTTP };
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:104:19: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
Type type = Type::NONE;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:108:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using headers_t = std::map<std::string, std::string, ciLessLibC>;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:109:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using args_t = std::deque;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:110:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using auth_t = Auth;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:112:10: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class Type {
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:121:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using ptr_t = std::shared_ptr;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:123:26: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int maxRedirects = 3;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:124:30: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int connectTimeoutMs = (1000 * 12);
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:125:27: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int sendTimeoutMs = (1000 * 12); // For each IO operation
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:126:28: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int replyTimeoutMs = (1000 * 21); // For the reply header
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:127:25: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int recvTimeout = (1000 * 21); // For each IO operation
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:128:52: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
std::size_t cacheMaxConnectionsPerEndpoint = 16;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:129:41: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
std::size_t cacheMaxConnections = 128;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:130:29: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int cacheTtlSeconds = 60;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:131:41: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int cacheCleanupIntervalSeconds = 3;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:163:26: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
virtual ~Request() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:169:48: error: expected expression
std::unique_ptr body = {},
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:170:50: error: expected expression
const boost::optional<args_t>& args = {},
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:171:56: error: expected expression
const boost::optional<headers_t>& headers = {},
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:172:50: error: expected expression
const boost::optional<auth_t>& auth = {});
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:104:21: warning: use of enumeration in a nested name specifier is a C++11 extension
[-Wc++11-extensions]
Type type = Type::NONE;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:74:15: error: expected '('
: name{use_name}, value{use_value} {}
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:74:24: error: expected ';' after expression
: name{use_name}, value{use_value} {}
^
;
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:74:16: warning: expression result unused [-Wunused-value]
: name{use_name}, value{use_value} {}
^~~~~~~~
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:88:15: error: expected '('
: name{authName}, passwd{authPasswd} {}
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:88:24: error: expected ';' after expression
: name{authName}, passwd{authPasswd} {}
^
;
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:88:16: warning: expression result unused [-Wunused-value]
: name{authName}, passwd{authPasswd} {}
^~~~~~~~
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:179:14: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class HttpVersion {
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:182:34: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
HttpVersion http_version = HttpVersion::HTTP_1_1;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:183:25: warning: in-class initialization of non-static data member is a C++11 extension
[-Wc++11-extensions]
int status_code = 0;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:187:24: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
virtual ~Reply() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:182:36: warning: use of enumeration in a nested name specifier is a C++11 extension
[-Wc++11-extensions]
HttpVersion http_version = HttpVersion::HTTP_1_1;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:267:15: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
const auto microseconds =
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:292:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using prc_fn_t = std::function<void (Context& ctx)>;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:296:25: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
DoneHandler() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:297:34: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
virtual ~DoneHandler() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:303:29: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
virtual RestClient() = default;
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:328:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto prom = std::make_shared<std::promise>();
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:328:52: error: a space is required between consecutive right angle brackets (use '> >')
auto prom = std::make_shared<std::promise>();
^
> >
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:329:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto future = prom->get_future();
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/restc-cpp.h:332:28: error: expected expression
[prom,fn,this](boost::asio::yield_context yield) {
^
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/tests/unit/AsyncSleepTests.cpp:14:
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/error.h:22:5: error: expected member name or ';' after declaration specifiers
{
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/error.h:21:20: error: expected '('
, http_response{response}
^
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/error.h:21:29: error: expected ';' after expression
, http_response{response}
^
;
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/error.h:21:21: warning: expression result unused [-Wunused-value]
, http_response{response}
^~~~~~~~
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/tests/unit/AsyncSleepTests.cpp:15:
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/RequestBuilder.h:12:
In file included from /Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/SerializeJson.h:29:
/Users/jdiaz/Development/cplusplus/restc-cpp/include/restc-cpp/RapidJsonReader.h:24:5: error: expected member name or ';' after declaration specifiers
{
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
47 warnings and 20 errors generated.
make[2]: *** [tests/unit/CMakeFiles/async_sleep_tests.dir/AsyncSleepTests.cpp.o] Error 1
make[1]: *** [tests/unit/CMakeFiles/async_sleep_tests.dir/all] Error 2
make: *** [all] Error 2
Currently we only decompress incoming payloads.
I am using restc-cpp api. and facing below issue
my rest API is giving below response
[
{
"id": 1,
"MeterNo": "100101",
"Status": 0,
"Services": ["service1","service2","service3"]
},
{
"id": 2,
"MeterNo": "100102",
"Status": 0,
"Services": "Services": ["service1","service2","service3"]
}
]
I am using these structures to Serialize
struct Schedule
{
int id;
string MeterNo;
int Status;
vector<string> Services;
};
BOOST_FUSION_ADAPT_STRUCT
(
Schedule,
(int, id)
(string, MeterNo)
(int, Status)
(vector<string>, Services)
)
it gives very big compilation error where using Function SerializeFromJson().
can you help?
Thanks in Advance.
Hi I get following errors while compiling in Ubuntu 16.04 LTS. Any idea how these can be fixed?
[ 45%] Linking CXX executable ../bin/simplewriter
[ 45%] Built target simplewriter
Scanning dependencies of target examples
[ 45%] Built target examples
Scanning dependencies of target archivertest
[ 46%] Building CXX object example/CMakeFiles/archivertest.dir/archiver/archiver.cpp.o
In file included from /root/restc-cpp/dbuild/external-projects/src/externalRapidJson/example/archiver/archiver.cpp:1:0:
/root/restc-cpp/dbuild/external-projects/src/externalRapidJson/example/archiver/archiver.h:56:7: error: 'class JsonReader' has pointer data members [-Werror=effc++]
class JsonReader {
^
/root/restc-cpp/dbuild/external-projects/src/externalRapidJson/example/archiver/archiver.h:56:7: error: but does not override 'JsonReader(const JsonReader&)' [-Werror=effc++]
/root/restc-cpp/dbuild/external-projects/src/externalRapidJson/example/archiver/archiver.h:56:7: error: or 'operator=(const JsonReader&)' [-Werror=effc++]
/root/restc-cpp/dbuild/external-projects/src/externalRapidJson/example/archiver/archiver.h:100:7: error: 'class JsonWriter' has pointer data members [-Werror=effc++]
class JsonWriter {
^
external project dependencies does add some extra time each time you run make.
2616792#diff-f1f2ba7e3d111c581a8491b50429ad82R5
Here I made the minimal possible cmake config to be easier to understand the code. While working with cmake external projects I've found one trick to improve the cmake reload and build speed.
Instead of making the project dependent on external project thus building the external project on each project build
add_dependencies(${PROJECT_NAME} externalRestcCpp)
you can create a virtual target and add all external project dependencies on it
add_custom_target(externalAll)
ExternalProject_Add(externalRestcCpp
PREFIX "${EXTERNAL_PROJECTS_PREFIX}"
GIT_REPOSITORY "https://github.com/jgaa/restc-cpp.git"
GIT_TAG "master"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_INSTALL_PREFIX}
)
add_dependencies(externalAll externalRestcCpp)
Now the target ${PROJECT_NAME}
is standalone, the build is fast and library linking still works. When you wan to (re)build all external projects, you build the externalAll
target.
Hi, @jgaa.
On my Windows computer, my development environment is based on MSYS2 and MinGW-w64.
CMake (mingw-w64-x86_64-cmake
) and Boost (mingw-w64-x86_64-boost
) are installed. I even installed rapidjson (mingw-w64-x86_64-rapidjson
), just in case.
I also have tried to set CMAKE_CXX_FLAGS to -std=c++14
, but nothing changed.
CMake's log:
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using C:/msys64/mingw64/bin/c++.exe
-- Found ZLIB: C:/msys64/mingw64/lib/libz.dll.a (found version "1.2.11")
-- Found OpenSSL: C:/msys64/mingw64/lib/libssl.dll.a (found version "1.0.2l")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Boost version: 1.64.0
-- Found the following Boost libraries:
-- system
-- program_options
-- filesystem
-- date_time
-- context
-- coroutine
-- chrono
-- log
-- thread
-- log_setup
-- regex
-- atomic
-- Writing the current configuration to C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/config.h
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/home/gjacquemin/restc-cpp/dbuild
make
's log:
Scanning dependencies of target restc-cpp
[ 1%] Building CXX object src/CMakeFiles/restc-cpp.dir/ChunkedReaderImpl.cpp.obj
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/minwindef.h:163:0,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/windef.h:8,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:69,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23,
from C:/msys64/mingw64/include/boost/asio/detail/socket_types.hpp:33,
from C:/msys64/mingw64/include/boost/asio/detail/win_tss_ptr.hpp:23,
from C:/msys64/mingw64/include/boost/asio/detail/tss_ptr.hpp:25,
from C:/msys64/mingw64/include/boost/asio/detail/call_stack.hpp:20,
from C:/msys64/mingw64/include/boost/asio/impl/handler_alloc_hook.ipp:19,
from C:/msys64/mingw64/include/boost/asio/handler_alloc_hook.hpp:80,
from C:/msys64/mingw64/include/boost/asio/detail/handler_alloc_helpers.hpp:21,
from C:/msys64/mingw64/include/boost/asio/detail/bind_handler.hpp:19,
from C:/msys64/mingw64/include/boost/asio/detail/wrapped_handler.hpp:18,
from C:/msys64/mingw64/include/boost/asio/io_service.hpp:24,
from C:/msys64/mingw64/include/boost/asio/basic_io_object.hpp:19,
from C:/msys64/mingw64/include/boost/asio/basic_socket.hpp:20,
from C:/msys64/mingw64/include/boost/asio/basic_datagram_socket.hpp:20,
from C:/msys64/mingw64/include/boost/asio.hpp:21,
from C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:16,
from C:/msys64/home/gjacquemin/restc-cpp/src/ChunkedReaderImpl.cpp:3:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:116:9: error: expected identifier before '(' token
DELETE
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:116:9: error: expected '}' before '(' token
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h:12:0,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:10,
from C:/msys64/mingw64/x86_64-w64-mingw32/include/assert.h:15,
from C:/msys64/home/gjacquemin/restc-cpp/src/ChunkedReaderImpl.cpp:1:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:116:9: error: expected unqualified-id before numeric constant
DELETE
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:116:9: error: expected ')' before numeric constant
In file included from C:/msys64/home/gjacquemin/restc-cpp/src/ChunkedReaderImpl.cpp:3:0:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:131:9: error: 'headers_t' does not name a type
headers_t headers;
^~~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:132:9: error: 'args_t' does not name a type
args_t args;
^~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:133:9: error: 'Proxy' does not name a type
Proxy proxy;
^~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:136:5: error: 'virtual' outside class declaration
virtual const Properties& GetProperties() const = 0;
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:136:47: error: non-member function 'const restc_cpp::Properties& restc_cpp::GetProperties( ' cannot have cv-qualifier
virtual const Properties& GetProperties() const = 0;
^~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:136:55: error: function 'const restc_cpp::Properties& restc_cpp::GetProperties()' is initialized like a variable
virtual const Properties& GetProperties() const = 0;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:137:5: error: 'virtual' outside class declaration
virtual void SetProperties(Properties::ptr_t propreties) = 0;
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:137:64: error: function 'void restc_cpp::SetProperties(restc_cpp::Properties::ptr_t)' is initialized like a variable
virtual void SetProperties(Properties::ptr_t propreties) = 0;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:140:5: error: 'virtual' outside class declaration
virtual DataWriter& SendRequest(Context& ctx) = 0;
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:140:53: error: function 'restc_cpp::DataWriter& restc_cpp::SendRequest(restc_cpp::Context& ' is initialized like a variable
virtual DataWriter& SendRequest(Context& ctx) = 0;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:152:5: error: 'virtual' outside class declaration
virtual std::unique_ptr<Reply> GetReply(Context& ctx) = 0;
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:152:61: error: function 'std::unique_ptr<restc_cpp::Reply> restc_cpp::GetReply(restc_cpp::Context&)' is initialized like a variable
virtual std::unique_ptr<Reply> GetReply(Context& ctx) = 0;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:160:5: error: 'virtual' outside class declaration
virtual std::unique_ptr<Reply> Execute(Context& ctx) = 0;
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:160:60: error: function 'std::unique_ptr<restc_cpp::Reply> restc_cpp::Execute(restc_cpp::Context&)' is initialized like a variable
virtual std::unique_ptr<Reply> Execute(Context& ctx) = 0;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:162:22: error: declaration of '~restc_cpp::Request' as non-member
virtual ~Request() = default;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:166:18: error: 'Type' does not name a type
const Type requestType,
^~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:169:34: error: 'args_t' was not declared in this scope
const boost::optional<args_t>& args = {},
^~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:169:40: error: template argument 1 is invalid
const boost::optional<args_t>& args = {},
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:170:34: error: 'headers_t' was not declared in this scope
const boost::optional<headers_t>& headers = {},
^~~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:170:43: error: template argument 1 is invalid
const boost::optional<headers_t>& headers = {},
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:171:34: error: 'auth_t' was not declared in this scope
const boost::optional<auth_t>& auth = {});
^~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:171:40: error: template argument 1 is invalid
const boost::optional<auth_t>& auth = {});
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:241:13: error: 'RestClient' does not name a type
virtual RestClient& GetClient() = 0;
^~~~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:261:44: error: 'Request' has not been declared
virtual std::unique_ptr<Reply> Request(Request& req) = 0;
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:278:16: error: 'RestClient' has not been declared
RestClient& rc);
^~~~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:300:19: error: 'Request' does not name a type
virtual const Request::Properties::ptr_t
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:346:29: error: 'ConnectionPool' was not declared in this scope
virtual std::shared_ptr<ConnectionPool> GetConnectionPool() = 0;
^~~~~~~~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:346:29: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:57:7: note: 'restc_cpp::ConnectionPool'
class ConnectionPool;
^~~~~~~~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:346:43: error: template argument 1 is invalid
virtual std::shared_ptr<ConnectionPool> GetConnectionPool() = 0;
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:32: error: 'Request' was not declared in this scope
Create(boost::optional<Request::Properties> properties);
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:32: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:51: error: template argument 1 is invalid
Create(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:32: error: 'Request' was not declared in this scope
Create(boost::optional<Request::Properties> properties);
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:32: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:51: error: template argument 1 is invalid
Create(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:32: error: 'Request' was not declared in this scope
Create(boost::optional<Request::Properties> properties);
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:32: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:51: error: template argument 1 is invalid
Create(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:23: error: 'boost::optional' is not a type
Create(boost::optional<Request::Properties> properties);
^~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:31: error: expected ',' or '...' before '<' token
Create(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:44: error: 'Request' was not declared in this scope
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:44: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:63: error: template argument 1 is invalid
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:44: error: 'Request' was not declared in this scope
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:44: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:63: error: template argument 1 is invalid
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:44: error: 'Request' was not declared in this scope
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:44: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:63: error: template argument 1 is invalid
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:35: error: 'boost::optional' is not a type
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:365:43: error: expected ',' or '...' before '<' token
CreateUseOwnThread(boost::optional<Request::Properties> properties);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:32: error: 'Request' was not declared in this scope
Create(boost::optional<Request::Properties> properties,
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:32: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:51: error: template argument 1 is invalid
Create(boost::optional<Request::Properties> properties,
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:32: error: 'Request' was not declared in this scope
Create(boost::optional<Request::Properties> properties,
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:32: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:51: error: template argument 1 is invalid
Create(boost::optional<Request::Properties> properties,
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:32: error: 'Request' was not declared in this scope
Create(boost::optional<Request::Properties> properties,
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:32: note: suggested alternative:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:66:7: note: 'restc_cpp::Request'
class Request {
^~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:51: error: template argument 1 is invalid
Create(boost::optional<Request::Properties> properties,
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:23: error: 'boost::optional' is not a type
Create(boost::optional<Request::Properties> properties,
^~~~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:31: error: expected ',' or '...' before '<' token
Create(boost::optional<Request::Properties> properties,
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:368:9: error: 'static std::unique_ptr<RestClient> RestClient::Create(int)' cannot be overloaded
Create(boost::optional<Request::Properties> properties,
^~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:360:9: error: with 'static std::unique_ptr<RestClient> RestClient::Create(int)'
Create(boost::optional<Request::Properties> properties);
^~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h: In lambda function:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:332:52: error: no matching function for call to 'Context::Create(boost::asio::yield_context&, RestClient&)'
auto ctx = Context::Create(yield, *this);
^
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:277:9: note: candidate: static std::unique_ptr<Context> Context::Create(boost::asio::yield_context&, int&)
Create(boost::asio::yield_context& yield,
^~~~~~
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:277:9: note: no known conversion for argument 2 from 'RestClient' to 'int&'
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h: At global scope:
C:/msys64/home/gjacquemin/restc-cpp/include/restc-cpp/restc-cpp.h:379:1: error: expected declaration before '}' token
} // restc_cpp
^
mingw32-make[2]: *** [src/CMakeFiles/restc-cpp.dir/build.make:64: src/CMakeFiles/restc-cpp.dir/ChunkedReaderImpl.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles/Makefile2:86: src/CMakeFiles/restc-cpp.dir/all] Error 2
mingw32-make: *** [Makefile:95: all] Error 2
Needed if we want to use the library with existing asio based code.
# MUST be called before any add_executable() # https://stackoverflow.com/a/40554704/8766845
link_directories(${CMAKE_BINARY_DIR}/external-projects/installed/lib)
include_directories(${PROJECT_NAME} ${CMAKE_BINARY_DIR}/external-projects/installed/include)
add_executable(${PROJECT_NAME} main.cpp)
include(ExternalProject)
ExternalProject_Add(external-restc-cpp
PREFIX "${CMAKE_BINARY_DIR}/external-projects"
GIT_REPOSITORY "https://github.com/jgaa/restc-cpp.git"
GIT_TAG "master"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external-projects/installed
)
add_dependencies(${PROJECT_NAME} external-restc-cpp)
target_link_libraries(${PROJECT_NAME} restc-cpp)
then build external-restc-cpp
and you will get this output
with error No rule to make target 'install'
/home/i/soft/clion/bin/cmake/bin/cmake --build /home/i/cpp/rest-client-test/cmake-build-debug --target external_restc-cpp -- -j 3
Scanning dependencies of target external_restc-cpp
[ 12%] Creating directories for 'external_restc-cpp'
[ 25%] Performing download step (git clone) for 'external_restc-cpp'
Cloning into 'external_restc-cpp'...
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Submodule 'externals/lest' (https://github.com/martinmoene/lest.git) registered for path 'externals/lest'
Submodule 'externals/rapidjson' (https://github.com/miloyip/rapidjson.git) registered for path 'externals/rapidjson'
Cloning into '/home/i/cpp/rest-client-test/cmake-build-debug/external/restc-cpp/src/external_restc-cpp/externals/lest'...
Cloning into '/home/i/cpp/rest-client-test/cmake-build-debug/external/restc-cpp/src/external_restc-cpp/externals/rapidjson'...
Submodule path 'externals/lest': checked out '24e586e36bd8dece875b3a105242036c3bb55a29'
Submodule path 'externals/rapidjson': checked out 'c34e3dfc72b6c90775aad132f27c29bbf1d79222'
Submodule 'thirdparty/gtest' (https://github.com/google/googletest.git) registered for path 'externals/rapidjson/thirdparty/gtest'
Cloning into '/home/i/cpp/rest-client-test/cmake-build-debug/external/restc-cpp/src/external_restc-cpp/externals/rapidjson/thirdparty/gtest'...
Submodule path 'externals/rapidjson/thirdparty/gtest': checked out '0a439623f75c029912728d80cb7f1b8b48739ca4'
[ 37%] No patch step for 'external_restc-cpp'
[ 50%] Performing update step for 'external_restc-cpp'
Current branch master is up to date.
[ 62%] Performing configure step for 'external_restc-cpp'
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using /usr/bin/c++
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.2g")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Boost version: 1.62.0
-- Found the following Boost libraries:
-- system
-- program_options
-- filesystem
-- date_time
-- context
-- coroutine
-- chrono
-- log
-- thread
-- log_setup
-- regex
-- atomic
-- Writing the current configuration to /home/i/cpp/rest-client-test/cmake-build-debug/external/restc-cpp/src/external_restc-cpp/include/restc-cpp/config.h
-- Configuring done
-- Generating done
-- Build files have been written to: /home/i/cpp/rest-client-test/cmake-build-debug/external/restc-cpp/src/external_restc-cpp-build
[ 75%] Performing build step for 'external_restc-cpp'
Scanning dependencies of target restc-cpp
[ 1%] Building CXX object src/CMakeFiles/restc-cpp.dir/ChunkedReaderImpl.cpp.o
[ 3%] Building CXX object src/CMakeFiles/restc-cpp.dir/ChunkedWriterImpl.cpp.o
[ 5%] Building CXX object src/CMakeFiles/restc-cpp.dir/IoReaderImpl.cpp.o
[ 7%] Building CXX object src/CMakeFiles/restc-cpp.dir/IoWriterImpl.cpp.o
[ 9%] Building CXX object src/CMakeFiles/restc-cpp.dir/PlainReaderImpl.cpp.o
[ 11%] Building CXX object src/CMakeFiles/restc-cpp.dir/PlainWriterImpl.cpp.o
[ 12%] Building CXX object src/CMakeFiles/restc-cpp.dir/NoBodyReaderImpl.cpp.o
[ 14%] Building CXX object src/CMakeFiles/restc-cpp.dir/DataReaderStream.cpp.o
[ 16%] Building CXX object src/CMakeFiles/restc-cpp.dir/RestClientImpl.cpp.o
[ 18%] Building CXX object src/CMakeFiles/restc-cpp.dir/RequestImpl.cpp.o
[ 20%] Building CXX object src/CMakeFiles/restc-cpp.dir/ReplyImpl.cpp.o
[ 22%] Building CXX object src/CMakeFiles/restc-cpp.dir/ConnectionPoolImpl.cpp.o
[ 24%] Building CXX object src/CMakeFiles/restc-cpp.dir/Url.cpp.o
[ 25%] Building CXX object src/CMakeFiles/restc-cpp.dir/RequestBodyStringImpl.cpp.o
[ 27%] Building CXX object src/CMakeFiles/restc-cpp.dir/RequestBodyFileImpl.cpp.o
[ 29%] Building CXX object src/CMakeFiles/restc-cpp.dir/url_encode.cpp.o
[ 31%] Building CXX object src/CMakeFiles/restc-cpp.dir/ZipReaderImpl.cpp.o
[ 33%] Linking CXX static library /home/i/cpp/rest-client-test/cmake-build-debug/external/restc-cpp/src/external_restc-cpp/lib/librestc-cpp.a
[ 33%] Built target restc-cpp
Scanning dependencies of target json_iostream_tests
Scanning dependencies of target async_sleep_tests
Scanning dependencies of target http_reply_tests
[ 35%] Building CXX object tests/unit/CMakeFiles/async_sleep_tests.dir/AsyncSleepTests.cpp.o
[ 37%] Building CXX object tests/unit/CMakeFiles/http_reply_tests.dir/HttpReplyTests.cpp.o
[ 38%] Building CXX object tests/unit/CMakeFiles/json_iostream_tests.dir/Iostream2JsonTests.cpp.o
[ 40%] Linking CXX executable async_sleep_tests
[ 40%] Built target async_sleep_tests
Scanning dependencies of target json_serialize_tests
[ 42%] Building CXX object tests/unit/CMakeFiles/json_serialize_tests.dir/JsonSerializeTests.cpp.o
[ 44%] Linking CXX executable json_iostream_tests
[ 44%] Built target json_iostream_tests
Scanning dependencies of target url_tests
[ 46%] Building CXX object tests/unit/CMakeFiles/url_tests.dir/UrlTests.cpp.o
[ 48%] Linking CXX executable http_reply_tests
[ 48%] Built target http_reply_tests
Scanning dependencies of target connection_pool_instances_test
[ 50%] Building CXX object tests/functional/CMakeFiles/connection_pool_instances_test.dir/ConnectionPoolInstancesTest.cpp.o
[ 51%] Linking CXX executable url_tests
[ 51%] Built target url_tests
Scanning dependencies of target own_ioservice_tests
[ 53%] Building CXX object tests/functional/CMakeFiles/own_ioservice_tests.dir/OwnIoserviceTests.cpp.o
[ 55%] Linking CXX executable connection_pool_instances_test
[ 55%] Built target connection_pool_instances_test
Scanning dependencies of target basic_tests
[ 57%] Building CXX object tests/functional/CMakeFiles/basic_tests.dir/BasicTests.cpp.o
[ 59%] Linking CXX executable json_serialize_tests
[ 59%] Built target json_serialize_tests
Scanning dependencies of target readme_tests
[ 61%] Building CXX object tests/functional/CMakeFiles/readme_tests.dir/ReadmeTests.cpp.o
[ 62%] Linking CXX executable own_ioservice_tests
[ 62%] Built target own_ioservice_tests
Scanning dependencies of target ccache_tests
[ 64%] Building CXX object tests/functional/CMakeFiles/ccache_tests.dir/ConnectionCacheTests.cpp.o
[ 66%] Linking CXX executable basic_tests
[ 66%] Built target basic_tests
Scanning dependencies of target upload_tests
[ 68%] Building CXX object tests/functional/CMakeFiles/upload_tests.dir/UploadTests.cpp.o
[ 70%] Linking CXX executable readme_tests
[ 70%] Built target readme_tests
Scanning dependencies of target crud_tests
[ 72%] Building CXX object tests/functional/CMakeFiles/crud_tests.dir/CRUD_test.cpp.o
[ 74%] Linking CXX executable ccache_tests
[ 74%] Built target ccache_tests
Scanning dependencies of target many_connections_tests
[ 75%] Building CXX object tests/functional/CMakeFiles/many_connections_tests.dir/ManyConnectionsTest.cpp.o
[ 77%] Linking CXX executable upload_tests
[ 77%] Built target upload_tests
Scanning dependencies of target auth_tests
[ 79%] Building CXX object tests/functional/CMakeFiles/auth_tests.dir/AuthTest.cpp.o
[ 81%] Linking CXX executable crud_tests
[ 81%] Built target crud_tests
Scanning dependencies of target inserter_serializer_tests
[ 83%] Building CXX object tests/functional/CMakeFiles/inserter_serializer_tests.dir/InsertSerializerTest.cpp.o
[ 85%] Linking CXX executable many_connections_tests
[ 85%] Built target many_connections_tests
Scanning dependencies of target https_tests
[ 87%] Linking CXX executable auth_tests
[ 88%] Building CXX object tests/functional/CMakeFiles/https_tests.dir/HttpsTest.cpp.o
[ 88%] Built target auth_tests
Scanning dependencies of target redirect_tests
[ 90%] Building CXX object tests/functional/CMakeFiles/redirect_tests.dir/RedirectTests.cpp.o
[ 92%] Linking CXX executable inserter_serializer_tests
[ 92%] Built target inserter_serializer_tests
Scanning dependencies of target logip
[ 94%] Building CXX object examples/CMakeFiles/logip.dir/logip.cpp.o
[ 96%] Linking CXX executable https_tests
[ 96%] Built target https_tests
[ 98%] Linking CXX executable redirect_tests
[ 98%] Built target redirect_tests
[100%] Linking CXX executable logip
[100%] Built target logip
[ 87%] Performing install step for 'external_restc-cpp'
make[4]: *** No rule to make target 'install'. Stop.
test/CMakeFiles/external_restc-cpp.dir/build.make:73: recipe for target 'external/restc-cpp/src/external_restc-cpp-stamp/external_restc-cpp-install' failed
make[3]: *** [external/restc-cpp/src/external_restc-cpp-stamp/external_restc-cpp-install] Error 2
CMakeFiles/Makefile2:232: recipe for target 'test/CMakeFiles/external_restc-cpp.dir/all' failed
make[2]: *** [test/CMakeFiles/external_restc-cpp.dir/all] Error 2
CMakeFiles/Makefile2:244: recipe for target 'test/CMakeFiles/external_restc-cpp.dir/rule' failed
make[1]: *** [test/CMakeFiles/external_restc-cpp.dir/rule] Error 2
Makefile:203: recipe for target 'external_restc-cpp' failed
make: *** [external_restc-cpp] Error 2
Do the TBD's.
Test with Twitter API
Currently, the deserializer will assert if an unknown property name is encountered in the json input stream. These should be ignored by default, with an option to enforce strict parsing (which will throw an exception, not assert on unknow names).
restc-cpp/include/restc-cpp/RequestBuilder.h
Lines 42 to 76 in 6398d70
I need to create an OPTIONS
request (Preflighted requests)
In response I have multiple cookies but Reply::GetHeader(name)
returns only the last header with the give name
restc-cpp/include/restc-cpp/restc-cpp.h
Lines 226 to 228 in 6398d70
Until this will be fixed, any workaround?
The current timers works only with the initial request / response.
Hi Jarle,
I'm getting access violations in ConnectionPoolImpl::OnCacheCleanup. These occur seemingly randomly (i.e. at random points while repeatedly running tests). See track trace below.
I'm running a Windows build, latest commit from 2017-05-19 (SHA 5e7ed3e).
It seems that the ConnectionPoolImpl instance has been deleted, but the OnCacheCleanup callback is still invoked by the timer. My app makes repeated calls using RestClient::Create()->ProcessWithPromiseT<>(...), so creating a new client and connection pool for each call repeatedly (right?).
Aside from that, I love the restc-cpp lib. Thank you for creating this!
Rick
Stack trace:
TestVisiLoginRestCpp.exe!restc_cpp::ConnectionPoolImpl::OnCacheCleanup(const boost::system::error_code & error) Line 176 C++
[External Code]
TestVisiLoginRestCpp.exe!boost::asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &>,boost::system::error_code>::operator()() Line 48 C++
TestVisiLoginRestCpp.exe!boost::asio::asio_handler_invoke<boost::asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &>,boost::system::error_code> >(boost::asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &>,boost::system::error_code> & function, ...) Line 70 C++
TestVisiLoginRestCpp.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &>,boost::system::error_code>,std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &> >(boost::asio::detail::binder1<std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &>,boost::system::error_code> & function, std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &> & context) Line 37 C++
TestVisiLoginRestCpp.exe!boost::asio::detail::wait_handler<std::_Binder<std::_Unforced,void (__thiscall restc_cpp::ConnectionPoolImpl::)(boost::system::error_code const &),restc_cpp::ConnectionPoolImpl * const,std::_Ph<1> const &> >::do_complete(boost::asio::detail::win_iocp_io_service * owner, boost::asio::detail::win_iocp_operation * base, const boost::system::error_code & __formal, unsigned int __formal) Line 70 C++
TestVisiLoginRestCpp.exe!boost::asio::detail::win_iocp_operation::complete(boost::asio::detail::win_iocp_io_service & owner, const boost::system::error_code & ec, unsigned int bytes_transferred) Line 46 C++
TestVisiLoginRestCpp.exe!boost::asio::detail::win_iocp_io_service::do_one(bool block, boost::system::error_code & ec) Line 406 C++
TestVisiLoginRestCpp.exe!boost::asio::detail::win_iocp_io_service::run(boost::system::error_code & ec) Line 164 C++
TestVisiLoginRestCpp.exe!boost::asio::io_service::run() Line 59 C++
TestVisiLoginRestCpp.exe!restc_cpp::RestClientImpl::Init::__l2::() Line 146 C++
[External Code]
[Frames below may be incorrect and/or missing, no symbols loaded for ucrtbased.dll]
The timers needs to use a wrapper that cancels the timers when the wrapper goes out of scope.
Currently, long lasting connections will be incorrectly killed by the connect timer.
Can we use it for mac as well?
Async from producer loop
Implement asynchronous iterators for outgoing data and integrate with json generator.
Add support for json property maps (std::map<std::string, T> in the json serializer/deserializer.
It should work. Just needs verification.
Implement standard RFC-2388 file upload
Using the example program
`#include
#include "restc-cpp/restc-cpp.h"
using namespace std;
using namespace restc_cpp;
void DoSomethingInteresting(Context& ctx) {
// Here we are in a co-routine, running in a worker-thread.
// Asynchronously connect to a server and fetch some data.
auto reply = ctx.Get("http://jsonplaceholder.typicode.com/posts/1");
// Asynchronously fetch the entire data-set and return it as a string.
auto json = reply->GetBodyAsString();
// Just dump the data.
cout << "Received data: " << json << endl;
}
int main() {
auto rest_client = RestClient::Create();
// Call DoSomethingInteresting as a co-routine in a worker-thread.
rest_client->Process(DoSomethingInteresting);
// Wait for the coroutine to finish, then close the client.
rest_client->CloseWhenReady(true);
}
`
VSCode shows #include errors detected. Please update your includePath. IntelliSense features for this translation unit (/home/kiran/dave/src/rest-client.cpp) will be provided by the Tag Parser.
cannot open source file "restc-cpp/restc-cpp.h"
I have followed the build instructions for ubuntu to the letter.
`sudo apt-get install zlib1g-dev g++ cmake doxygen graphviz libboost-all-dev libssl-dev
git clone https://github.com/jgaa/restc-cpp.git
cd restc-cpp/
mkdir dbuild
cd dbuild
cmake ..
make`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.