Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all 4845 articles
Browse latest View live

Updated Release: C++ Rest SDK 2.3.0

$
0
0
http_client
  • Implemented server certificate verification on Android. #242
  • Added usage of Boost ssl::context::default_workarounds for compatibility with somewhat broken servers.
  • Fixed issue with server certification verification if multiple requests are made on iOS, OS X, and Android.
  • Remove unnecessary setting of Content-Length header to zero.
  • Updated documentation for http_request default constructor and made default to HTTP GET method to avoid ambiguity. #273
  • For sending request bodies added overloads on Windows for directly working with UTF-8 strings. This saves copies and moves on all platforms.
  • Fixed several issues around timeouts and cancellation with the cross platform implementation. Also addressed several places timeouts weren't being handle properly. #280
  • Improved error messages with WinHttp based implementation to include error code and message in the what() string.
websocket_client
  • Poco is no longer used as test server for WinRT tests, Websocketpp is used in all cases. #221
  • HTTP headers for initial HTTP request can be specified now on the non-winrt implementation as well. #251
  • Added subprotocol API support. New APIs exist on websocket_client_config class. 206
  • Added an overload for set_data() which allows the user to not specify stream length. #152
  • Improved parameter passing in many locations, adding r-value references for string message data.
  • Improved error messages with websocketpp implementation.
  • Implemented 'wss' support for Android/iOS/OSX/Linux/Windows desktop. #255
  • Updated websocketpp library to 0.3.0 version.
http_listener
  • Initiating multiple close() calls on an http_listener no longer results in a race condition. Note: ~http_listener does invoke close(), even though the user should close it before destruction. #192
streams
  • Writing to output streams with read_to_end() will now throw an exception if it fails. #244
  • Fixed reading files larger than 4GB on Windows, if on 64bit. #161
  • Including streams.h no longer injects a specialization into std::. #125
json
  • Fixed issues around JSON library assuming the current local is "C". #118
  • Added overload when constructing json string values to indicated whether or not the string contains any characters that need to be escaped. If it is known to not, then the performance is better.
  • Fixed issue with Unicode escaping for code points over 127. #252
misc
  • run_tests.sh has been removed. The tests can be run by invoking the testrunner directly. #182
  • Reference documentation improvements.
  • Visual Studio 14 support for desktop applications. #278
  • Updated .gitignore to account for NuGet packages directory. #282
  • Added support for Windows Phone 8.1 Silverlight. #227
  • Visual Studio project files have there packages.config separated out, only pulling in the exact NuGet packages necessary for that project now. #285
  • Passwords are now stored in memory encrypted. The API web::credentials::password() has been deprecated.
  • Updated iOS build script to use a patch to fix the Boost version used to be 1.56.

Updated Wiki: Setup and Build on iOS

$
0
0

How to build and setup on iOS

First, follow all the instructions on Setup and Build on OSX. While some steps could be skipped if you only want to build for iOS, it is useful to diagnose problems during the initial iOS project setup by replicating it on OSX.

Casablanca depends on Boost and OpenSSL when used on iOS. It is a non-trivial task to cross-compile libraries for iOS, however there are scripts available online with nonrestrictive licenses to compile many popular libraries -- among these libraries are Boost and OpenSSL.

This document will walk through the steps to build Casablanca and its dependencies into a form suitable for use with iOS applications.

For this walkthrough, we assume you are working within the Build_iOS directory of the casablanca project.
git clone https://git01.codeplex.com/casablanca
pushd casablanca/Build_iOS

Building OpenSSL

To build OpenSSL, use the script provided by the OpenSSL-for-iPhone project.
git clone --depth=1 https://github.com/x2on/OpenSSL-for-iPhone.git
pushd OpenSSL-for-iPhone
./build-libssl.sh
popd


After building the library, move the include files and libraries to Build_iOS/openssl/include and Build_iOS/openssl/lib respectively.
mkdir openssl
mv OpenSSL-for-iPhone/include openssl
mv OpenSSL-for-iPhone/lib openssl

This completes building OpenSSL.

project link: https://github.com/x2on/OpenSSL-for-iPhone

Building Boost

To build Boost, use the script provided by the boostoniphone project. The main project author seems to have not continued maintaining the project, however there are a few actively maintained forks. We recommend using the fork by Joseph Galbraith.
git clone https://git.gitorious.org/boostoniphone/galbraithjosephs-boostoniphone.git boostoniphone
pushd boostoniphone

The script `boost.sh` provided by the boostoniphone project has a variable at the top of the file to specify which parts of boost need be compiled. This variable must be changed to include the parts needed for Casablanca: thread, chrono, filesystem, regex, locale, system, and random. This can easily be done by applying our patch which sets the IPhone SDK version to 8.0 and Boost version to 1.56.
git apply ../fix_boost_version.patch
./boost.sh

The headers need to be moved to allow inclusion via `"boost/foo.h"`.
pushd ios/framework/boost.framework/Versions/A
mkdir Headers2
mv Headers Headers2/boost
mv Headers2 Headers
popd

Finally, the product framework must be moved into place.
popd
mv boostoniphone/ios/framework/boost.framework .

This completes building Boost.

project link: https://gitorious.org/boostoniphone
fork link: https://gitorious.org/boostoniphone/galbraithjosephs-boostoniphone

Preparing the Casablanca build

Casablanca uses CMake for cross-platform compatibility. To build on iOS, we specifically use the toolchain file provided by the ios-cmake project. This is hosted in a Mercurial repository, which can be installed via Homebrew with brew install hg.
hg clone https://code.google.com/p/ios-cmake/

This completes the preparation for building Casablanca.

project link: http://code.google.com/p/ios-cmake/
source link: http://ios-cmake.googlecode.com/files/ios-cmake.tar.gz

Building Casablanca

Now we are ready to build Casablanca for iOS. Invoke the ios-buildscripts subproject in the usual CMake fashion:
mkdir build.ios
pushd build.ios
cmake .. -DCMAKE_BUILD_TYPE=Release
make
popd

This will produce a universal static library called "libcpprest.a" inside the 'build.ios' directory for the i386 simulator and armv7.

Using Casablanca

You will need to link against the following from your project:
  • build.ios/libcpprest.a
  • boost.framework
  • openssl/lib/libcrypto.a
  • openssl/lib/libssl.a
  • libiconv.dylib (Available within the default list of libraries to link)

You will also need to add the following paths as additional include directories:
  • ../Release/include
  • boost.framework/Headers
  • openssl/include

This should allow you to reference and use casablanca from your C++ and Objective-C++ source files. Note: you should change all .m files in your project to .mm files, because even if the source file itself does not use Casablanca, it is possible that some C++ code will be pulled in via header includes. To avoid errors later, it is easiest to simply rename all your project sources to use '.mm'.

New Post: Instructions for Building on iOS seem to use a beta version of boost

$
0
0
Hi Leslie,

Ok I've updated the development branch with a patch that fixes the IPhone SDK to 8.0 and the Boost version to 1.56. It is under the Build_iOS folder:
 git apply ../fix_boost_version.patch
Steve

Commented Unassigned: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




Comments: Note if I use CreateThread() API to launch the task everything works as expected on windows server

Closed Issue: dev14 - broken build due to mismatched noexcept [300]

$
0
0
f:\projects\dev_tools\cpprest\dev\release\include\cpprest\asyncrt_utils.h(253): error C2694: 'const char *utility::details::windows_category_impl::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'

Reported from the following discussion:
https://casablanca.codeplex.com/discussions/569569#post1312474

New Post: OpenSSL in Windows?

$
0
0
We don't have explicit support for that, however looking at the OpenSSL NuGet package you should be able to add the following section into Release\src\build\vs120\casablanca120.vcxproj:
<PropertyGroup>
<Linkage-openssl>static</Linkage-openssl>
</PropertyGroup>
roschuma

Commented Unassigned: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




Comments: Hi rovechkin, I bet what is happening is you are running on a single core machine in Azure. The Concurrency Runtime under the covers it only going to execute one task per core and your task is permanently running. I think this is the same problem as this issue on CodePlex: https://casablanca.codeplex.com/workitem/106 I haven't investigated it yet, but it has to do with something about running on a single core machine. Steve

Commented Unassigned: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




Comments: in my case this is A2 (dual core 3.5 GB) machine

Commented Unassigned: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




Comments: just tried with the workaround, it didn't help

Commented Unassigned: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




Comments: Ok perhaps this is a different issue then. Thanks for reporting. Steve

New Post: VS 2010 upload Code nested Loop issue ?

$
0
0
Hi Oliver,

Could you let us know what version of the C++REST SDK you're using, what compiler you're using, and what OS you're using?

Thanks,
roschuma

New Post: Segmentation fault on compile without makefile

$
0
0
Does this also crash when you link against the debug version?

roschuma

Created Unassigned: 5 [307]

$
0
0
hi i have this error is vs2010.
IntelliSense: no suitable user-defined conversion from "pplx::task<pplx::details::_BadContinuationParamType>" to "pplx::task<void>" exists

I installed c++ rest sdk also.

It would be nice if anyone has a suggestion.




#include <cpprest/http_client.h>
#include <iostream>
#include <cpprest/json.h>


using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;

pplx::task<void> RequestJSONValueAsync()
{
http_client client (L"http://ip.jsontest.com/");
return client.request(methods::POST).then([](http_response response) -> pplx::task<json::value>
{
if(response.status_code() == status_codes::OK)
{
return response.extract_json();
}

// Handle error cases, for now return empty json value...
return pplx::task_from_result(json::value());
})
.then([](pplx::task<json::value> previousTask)
{
try
{
const json::value& v = previousTask.get();
// Perform actions here to process the JSON value...
}
catch (const http_exception& e)
{
// Print error.
wostringstream ss;
ss << e.what() << endl;
wcout << ss.str();
}
});

}

int wmain()
{
wcout << L"Calling RequestJSONValueAsync..." << endl;
RequestJSONValueAsync().wait();



}

New Post: v2.3: CppRestSDKVersionFileSuffix is 2.2

$
0
0
I downloaded the brand new drop of C++ Rest SDK v2.3 source code. When I build v2.3, project property of CppRestSDKVersionFileSuffix has a value of 2.2. I'm expecting it to be 2.3.

New Post: v2.3: Dependency on Boost 1.56

$
0
0
FWIW, I notice that http_client_impl.h uses:

include <boost/system/error_code.hpp>

which does not exist in Boost 1.55. Updating to nuget package Boost 1.56 resolves the issue.

New Post: Segmentation fault on compile without makefile

$
0
0
Hmm... Under debug version i have no crash... I change "build.release" to "build.debug".
Why "release" don't work?

New Post: v2.3: CppRestSDKVersionFileSuffix is 2.2

$
0
0
Hi BSalita,

We haven't released or finished version 2.3.0 yet. It is a still a work in progress in the development branch. The work hasn't been done yet to bump the version number from 2.2.0 to 2.3.0.

Steve

New Post: v2.3: Dependency on Boost 1.56

$
0
0
Hi BSalita,

Hmm that seems strange, I'm actually still using Boost 1.55 for my development and it contains error_code.hpp. I'm using the Boost NuGet package 1.55.0.16 and the file is located under packages\boost.1.55.0.16\lib\native\include\boost\system. Perhaps there is something wrong with your setup?

We probably will update to 1.56 for the 2.3.0 release regardless.

Thanks,
Steve

Commented Unassigned: 5 [307]

$
0
0
hi i have this error is vs2010.
IntelliSense: no suitable user-defined conversion from "pplx::task<pplx::details::_BadContinuationParamType>" to "pplx::task<void>" exists

I installed c++ rest sdk also.

It would be nice if anyone has a suggestion.




#include <cpprest/http_client.h>
#include <iostream>
#include <cpprest/json.h>


using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;

pplx::task<void> RequestJSONValueAsync()
{
http_client client (L"http://ip.jsontest.com/");
return client.request(methods::POST).then([](http_response response) -> pplx::task<json::value>
{
if(response.status_code() == status_codes::OK)
{
return response.extract_json();
}

// Handle error cases, for now return empty json value...
return pplx::task_from_result(json::value());
})
.then([](pplx::task<json::value> previousTask)
{
try
{
const json::value& v = previousTask.get();
// Perform actions here to process the JSON value...
}
catch (const http_exception& e)
{
// Print error.
wostringstream ss;
ss << e.what() << endl;
wcout << ss.str();
}
});

}

int wmain()
{
wcout << L"Calling RequestJSONValueAsync..." << endl;
RequestJSONValueAsync().wait();



}

Comments: Hi velmurugandeva, What version of the C++ Rest SDK are you using? The last one that officially supported Visual Studio 2010 was [1.2.0](https://casablanca.codeplex.com/releases/view/111094). Is this just a problem with Intellisense and can you compile and run successfully? In the future please try to put in a title for the issue that more accurately describes what the problem is. Using '5' doesn't provide any information to others reading. Thanks, Steve

Edited Unassigned: Intellisense errors with VS2010 [307]

$
0
0
hi i have this error is vs2010.
IntelliSense: no suitable user-defined conversion from "pplx::task<pplx::details::_BadContinuationParamType>" to "pplx::task<void>" exists

I installed c++ rest sdk also.

It would be nice if anyone has a suggestion.




#include <cpprest/http_client.h>
#include <iostream>
#include <cpprest/json.h>


using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;

pplx::task<void> RequestJSONValueAsync()
{
http_client client (L"http://ip.jsontest.com/");
return client.request(methods::POST).then([](http_response response) -> pplx::task<json::value>
{
if(response.status_code() == status_codes::OK)
{
return response.extract_json();
}

// Handle error cases, for now return empty json value...
return pplx::task_from_result(json::value());
})
.then([](pplx::task<json::value> previousTask)
{
try
{
const json::value& v = previousTask.get();
// Perform actions here to process the JSON value...
}
catch (const http_exception& e)
{
// Print error.
wostringstream ss;
ss << e.what() << endl;
wcout << ss.str();
}
});

}

int wmain()
{
wcout << L"Calling RequestJSONValueAsync..." << endl;
RequestJSONValueAsync().wait();



}

Viewing all 4845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>