Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into http_client_asio-re…
Browse files Browse the repository at this point in the history
…direct
  • Loading branch information
BillyONeal committed Feb 20, 2020
2 parents e0ed090 + 40dad5c commit a598c39
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 165 deletions.
26 changes: 14 additions & 12 deletions Build_android/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DO_OPENSSL=1
DO_CMAKE=1
DO_CPPRESTSDK=1

BOOSTVER=1.69.0
BOOSTVER=1.70.0
OPENSSLVER=1.1.0j
CMAKEVER=3.14.0

Expand Down Expand Up @@ -54,8 +54,8 @@ do
DO_OPENSSL=0
;;
"--skip-cmake")
DO_CMAKE=0
;;
DO_CMAKE=0
;;
"--skip-cpprestsdk")
DO_CPPRESTSDK=0
;;
Expand Down Expand Up @@ -104,10 +104,10 @@ NDK_DIR=`cd "${ANDROID_NDK}" && pwd`
SRC_DIR=`pwd`

if [ -z "$NCPU" ]; then
NCPU=4
if uname -s | grep -i "linux" > /dev/null ; then
NCPU=`cat /proc/cpuinfo | grep -c -i processor`
fi
NCPU=4
if uname -s | grep -i "linux" > /dev/null ; then
NCPU=`cat /proc/cpuinfo | grep -c -i processor`
fi
fi

# -----------------------
Expand Down Expand Up @@ -151,11 +151,12 @@ if [ "${DO_OPENSSL}" == "1" ]; then (
# -----
# Uses the build script from Moritz Wundke (formerly MysticTreeGames)
# https://github.com/moritz-wundke/Boost-for-Android
# (plus the patch https://github.com/o01eg/Boost-for-Android/tree/ndk-bump-21)

if [ "${DO_BOOST}" == "1" ]; then (
if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi
if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/o01eg/Boost-for-Android/; fi
cd Boost-for-Android
git checkout 245ea53385a55742a9ab08a8bd32c6a2dc0bbea4
git checkout 7626dd6f7cab7866dce20e685d4a1b11194366a7
PATH="$PATH:$NDK_DIR" \
CXXFLAGS="-std=gnu++11" \
./build-android.sh \
Expand Down Expand Up @@ -186,16 +187,17 @@ if [ "${DO_CMAKE}" == "1" ]; then (
if [ "${DO_CPPRESTSDK}" == "1" ]; then
# Use the builtin CMake toolchain configuration that comes with the NDK
function build_cpprestsdk { (
rm -rf $1
rm -rf $1
./cmake-${CMAKEVER}/bin/cmake \
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
-DANDROID_NDK="${ANDROID_NDK}" \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=$2 \
-DBOOST_VERSION="${BOOSTVER}" \
-DCPPREST_EXCLUDE_WEBSOCKETS=ON \
-DCMAKE_BUILD_TYPE=$3 \
-S "${DIR}/.." \
-B $1
-S "${DIR}/.." \
-B $1
make -j $NCPU -C $1
) }

Expand Down
71 changes: 0 additions & 71 deletions Release/tests/functional/http/client/outside_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,77 +285,6 @@ SUITE(outside_tests)
});
}
#endif // !defined(__cplusplus_winrt)

TEST_FIXTURE(uri_address, outside_ssl_json)
{
// Create URI for:
// https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUF1hMUVwlrvlVMjUGOZExgg&key=AIzaSyAviHxf_y0SzNoAq3iKqvWVE4KQ0yylsnk
uri_builder playlistUri(U("https://www.googleapis.com/youtube/v3/playlistItems?"));
playlistUri.append_query(U("part"), U("snippet"));
playlistUri.append_query(U("playlistId"), U("UUF1hMUVwlrvlVMjUGOZExgg"));
playlistUri.append_query(U("key"), U("AIzaSyAviHxf_y0SzNoAq3iKqvWVE4KQ0yylsnk"));

// Send request
web::http::client::http_client playlistClient(playlistUri.to_uri());

handle_timeout([&] {
// Retry up to 4 times.
for (int i = 0; i < 4; ++i)
{
try
{
playlistClient.request(methods::GET)
.then([=](http_response playlistResponse) -> pplx::task<json::value> {
return playlistResponse.extract_json();
})
.then([=](json::value v) {
int count = 0;
auto& obj = v.as_object();

VERIFY_ARE_NOT_EQUAL(obj.find(U("pageInfo")), obj.end());
VERIFY_ARE_NOT_EQUAL(obj.find(U("items")), obj.end());

auto& items = obj[U("items")];

for (auto iter = items.as_array().cbegin(); iter != items.as_array().cend(); ++iter)
{
const auto& item = *iter;
auto iSnippet = item.as_object().find(U("snippet"));
if (iSnippet == item.as_object().end())
{
throw std::runtime_error("snippet key not found");
}
auto iTitle = iSnippet->second.as_object().find(U("title"));
if (iTitle == iSnippet->second.as_object().end())
{
throw std::runtime_error("title key not found");
}
auto name = iTitle->second.serialize();
count++;
}
VERIFY_ARE_EQUAL(3, count); // Update this accordingly, if the number of items changes
})
.wait();
break;
}
catch (web::http::http_exception const& e)
{
#if defined(_MSC_VER) && !defined(__cplusplus_winrt)
if (e.error_code().value() != API_QUERY_DATA_AVAILABLE || i == 3)
{
// If we didn't get a "connection broken" error (or we are on the last retry), rethrow it
throw;
}
#else
(void)e;
throw;
#endif
os_utilities::sleep(1000);
}
}
});
}

} // SUITE(outside_tests)

} // namespace client
Expand Down
2 changes: 0 additions & 2 deletions Release/tests/functional/json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ if(UNIX AND NOT APPLE)
cpprest_find_boost()
target_link_libraries(json_test PRIVATE cpprestsdk_boost_internal)
endif()

configure_pch(json_test stdafx.h stdafx.cpp)
3 changes: 2 additions & 1 deletion Release/tests/functional/json/construction_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/

#include "stdafx.h"
#include "cpprest/json.h"
#include "unittestpp.h"

using namespace web;
using namespace utility;
Expand Down
4 changes: 2 additions & 2 deletions Release/tests/functional/json/fuzz_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/

#include "stdafx.h"

#include "cpprest/json.h"
#include "cpprest/containerstream.h"
#include "cpprest/filestream.h"
#include "unittestpp.h"

using namespace web;

Expand Down
4 changes: 2 additions & 2 deletions Release/tests/functional/json/iterator_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/

#include "stdafx.h"

#include "cpprest/json.h"
#include "unittestpp.h"
#include <algorithm>

using namespace web;
Expand Down
4 changes: 2 additions & 2 deletions Release/tests/functional/json/json_numbers_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/

#include "stdafx.h"

#include "cpprest/json.h"
#include "unittestpp.h"
#include <clocale>
#include <iomanip>

Expand Down
25 changes: 0 additions & 25 deletions Release/tests/functional/json/json_tests.h

This file was deleted.

3 changes: 2 additions & 1 deletion Release/tests/functional/json/negative_parsing_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
****/

#include "stdafx.h"
#include "cpprest/json.h"
#include "unittestpp.h"

using namespace web;
using namespace utility;
Expand Down

0 comments on commit a598c39

Please sign in to comment.