From: James Turner Date: Sat, 27 Feb 2016 04:35:41 +0000 (+0200) Subject: HTTP repository testing tool. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=43dacf5951e19f4fb4ac89052a019e86ccf3fb4d;p=simgear.git HTTP repository testing tool. --- diff --git a/simgear/io/CMakeLists.txt b/simgear/io/CMakeLists.txt index cfe6c7fd..3e877565 100644 --- a/simgear/io/CMakeLists.txt +++ b/simgear/io/CMakeLists.txt @@ -73,6 +73,9 @@ add_test(http ${EXECUTABLE_OUTPUT_PATH}/test_http) add_executable(httpget httpget.cxx) target_link_libraries(httpget ${TEST_LIBS}) +add_executable(http_repo_sync http_repo_sync.cxx) +target_link_libraries(http_repo_sync ${TEST_LIBS}) + add_executable(decode_binobj decode_binobj.cxx) target_link_libraries(decode_binobj ${TEST_LIBS}) diff --git a/simgear/io/http_repo_sync.cxx b/simgear/io/http_repo_sync.cxx new file mode 100644 index 00000000..f8186b4f --- /dev/null +++ b/simgear/io/http_repo_sync.cxx @@ -0,0 +1,82 @@ + +#include +#include +#include + +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + +using namespace simgear; +using std::cout; +using std::endl; +using std::cerr; +using std::string; + +int main(int argc, char* argv[]) +{ + HTTP::Client cl; + string proxy, proxyAuth; + string_list headers; + string url; + + sglog().setLogLevels( SG_ALL, SG_INFO ); + + for (int a=0; a= 0) { + proxyHost = proxy.substr(0, colonPos); + proxyPort = strutils::to_int(proxy.substr(colonPos + 1)); + } + + cl.setProxy(proxyHost, proxyPort, proxyAuth); + } + +#ifndef WIN32 + signal(SIGPIPE, SIG_IGN); +#endif + + if (url.empty()) { + cerr << "no URL argument specificed" << endl; + return EXIT_FAILURE; + } + + SGPath rootPath = simgear::Dir::current().path(); + HTTPRepository* repo = new HTTPRepository(rootPath, &cl); + repo->setBaseUrl(url); + repo->update(); + + while (repo->isDoingSync()) { + cl.update(); + SGTimeStamp::sleepForMSec(100); + } + + if (repo->failure() != AbstractRepository::REPO_NO_ERROR) { + cerr << "got response:" << repo->failure() << endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}