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

New Post: Problem with Casablanca SDK

$
0
0
This is the exception message
Unhandled exception at at 0x76A6C41F in Listener.exe: Microsoft C++ exception: web::http::http_exception at memory location 0x0038EEB0.
This is the string, where I replaced localhost with the IP Address.
uri_builder uri(L"http://192.168.15.63:2001/");
And this is where this exception happens.
listener.open().wait();

New Post: Problem with Casablanca SDK

$
0
0
Hi maverick786us,

Our listener throws exceptions of type http_listener. Try catching the exception and check what the actual error message and error code is.

Steve

Commented Feature: Client Side Certificates [41]

$
0
0
Please vote if this is an important scenario for you. If the lack of this feature is is blocking your adoption of the C++ REST SDK, please comment below.

Note: We cannot guarantee that this feature will be supported in upcoming releases. However by voting we will be able to better understand our customer's need and help us in prioritizing future work.
Comments: Hi Casablanca team, I'd like to use C++ REST API client-side certificate on Linux. What options do I have inside C++ REST API? thanks, Lwei

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, armv7, armv7s, and arm64.

Running Tests

If you want to run the tests in the iOS simulator you can simply execute 'make test'.
pushd build.ios
make test
popd

This will go and run all the tests in the iOS simulator, but the output of the tests won't be displayed. If you want to run the tests directly and see the full output you can manually execute the tests directly with xcodebuild.
pushd Release/tests/common/TestRunner/ios
xcodebuild test -project ios_runner.xcodeproj -configuration=Release -scheme ios_runner - destination "platform=iOS Simulator,name=iPhone 6"

Now you will see the output of each of the tests cases as they run.

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)
  • Security.framework (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: Problem with Casablanca SDK

$
0
0
When I added the try and catch block...
try
    {
        listener.open().wait();
        fgetc(stdin);
        listener.close().wait();
    }
    catch(std::exception const & exp)
    {
        //exp.
    }
This is what it shows in exception.
-       exp <No type information available in symbol file for cpprest110d_2_4.dll>{_Mywhat=0x00000000 <NULL> _Mydofree=...} const std::exception &
+       __vfptr 0x108445c0 {cpprest110d_2_4.dll!const web::http::http_exception::`vftable'} {cpprest110d_2_4.dll!0x1016f9b1, ...}   void * *
+       _Mywhat 0x00000000 <NULL>   const char *
        _Mydofree   false   bool
Does Casablanca has its own exception mechanism?

New Post: Problem with Casablanca SDK

$
0
0
Hi maverick786us,

What does the exception message say? You still are not checking it. By the way you also aren't catching the http_exception type that is being thrown. It could contain additional information.
    try
    {
        listener.open().wait();
        fgetc(stdin);
        listener.close().wait();
    }
    catch(const http_exception &e)
    {
        const auto &msg = e.what();
        const auto &error_code = e.error_code();
    }
Check these fields for more information.

Steve

Updated Release: C++ Rest SDK 2.5.0

$
0
0
Android
  • Fixed issue in CMakeLists.txt where parenthesis were incorrectly used instead of brackets.
  • Fixed issue in CMakeLists.txt where pplxlinux.cpp source file was missing.
  • Added Android TestRunner packing androidproj to build.

Windows
  • Fixed several code analysis warnings.
  • Updating NuGet package for missing OpenSSL license, also patched 2.4.0's NuGet package.
  • Fixed not working on XP issue because of crypto API. #331, #334
  • Fixed several functions missing an explicit calling convention. This caused problems if you changed the calling convention from the cdecl.
  • Added support for Windows on Devices/Galileo. #217
  • Added option to force using PPLX on Windows Threadpool instead of PPL on the Concurrency Runtime. Library can be rebuilt using CPPREST_FORCE_PPLX macro.
  • Updated all binaries to use whole program optimizations, slightly decreasing binary size and small potential performance improvements.

OSX
  • Merged a pull request to work around a FindOpenSSL.cmake issue, enabling it to find Homebrew's copy.

Websockets (non-WinRT)
  • Fixed a race condition during websocket client destructor which would sometimes result in an AV/Segfault.
  • Added proxy support for Websocket++ based implementation.

http_client
  • Make std::function parameter to http_client::add_handler passed by const reference.
  • Fixed invalid check in WinHTTP based implementation causing autologon security level to be high if credentials are not provided.
  • Added extract_utf8string and extract_utf16string to http_request and http_response classes. This allows uses either UTF-8 or UTF-16, instead of utility::string_t, more efficiently regardless of the platform.

Miscellaneous
  • Merged pull request adding http_constants.dat to be installed with 'make install'.

Tests
  • Fixed race conditions in close_callback_client_from_server
  • Added proper synchronization to test_websocket_server (preventing some race conditions). #305

Updated Release: C++ Rest SDK 2.5.0

$
0
0
Android
  • Fixed issue in CMakeLists.txt where parenthesis were incorrectly used instead of brackets.
  • Fixed issue in CMakeLists.txt where pplxlinux.cpp source file was missing.
  • Added Android TestRunner packing androidproj to build.

Windows
  • Fixed several code analysis warnings.
  • Updating NuGet package for missing OpenSSL license, also patched 2.4.0's NuGet package.
  • Fixed not working on XP issue because of crypto API. #331, #334
  • Fixed several functions missing an explicit calling convention. This caused problems if you changed the calling convention from the cdecl.
  • Added support for Windows on Devices/Galileo. #217
  • Added option to force using PPLX on Windows Threadpool instead of PPL on the Concurrency Runtime. Library can be rebuilt using CPPREST_FORCE_PPLX macro.
  • Updated all binaries to use whole program optimizations, slightly decreasing binary size and small potential performance improvements.

OSX
  • Merged a pull request to work around a FindOpenSSL.cmake issue, enabling it to find Homebrew's copy.

websocket_client
  • Fixed a race condition in Websocket++ based implementation during websocket client destructor which would sometimes result in an AV/Segfault.
  • Added proxy support for Websocket++ based implementation.

http_client
  • Make std::function parameter to http_client::add_handler passed by const reference.
  • Fixed invalid check in WinHTTP based implementation causing autologon security level to be high if credentials are not provided.
  • Added extract_utf8string and extract_utf16string to http_request and http_response classes. This allows uses either UTF-8 or UTF-16, instead of utility::string_t, more efficiently regardless of the platform.

Miscellaneous
  • Merged pull request adding http_constants.dat to be installed with 'make install'.

Tests
  • Fixed race conditions in close_callback_client_from_server
  • Added proper synchronization to test_websocket_server (preventing some race conditions). #305

New Post: localhost does not work but 127.0.0.1 does

$
0
0
Hi Steve,

Thanks for your reply. I have taken your advice and posted on the Windows forum. Hopefully anyone coming across this thread can find an answer here:

https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/1096f67a-6893-4554-9875-18e6d3b1d9bd/url-registration-reservation-and-casablanca-c-rest?forum=windowsgeneraldevelopmentissues

I have taken HttpSetServiceConfiguration out as I don't think I need it in the application as it is used for reservations. Instead it will be called in a dll as part of the installation: at least that's my understanding. HttpAddUrlToUrlGroup is what's needed for registration.

Andy

New Post: C++ Rest SDK 2.5.0

$
0
0
When C++ Rest SDK 2.5.0 will be going to release?

New Post: Error in SSL handshake for consecutive requests

$
0
0
Hi,

I'm getting "Error in SSL handshake" after requesting with my http_client instance twice on iOS/simulator (casablanca commit 219daed12e45). SSL certificate on my server is valid. I tried to pass to the client a custom http_client_config object with validate_certificates set to false but no dice. It doesn't want to work unless I recreate the client with exactly the same settings (well, basically the base_url) before the second request. Has anyone seen this behavior? Here's a code snippet:
http_client_config config;
config.set_validate_certificates(false);
http_client client(base_url, config);
client.request(methods::GET, build_org_context(org_name)).then([=] (http_response response) {
    return response.extract_json();
}).then([=] (value json) {
    return json[U("links")][U("token")].as_string();
}).then([=] (string_t token) mutable {
    http_request request(methods::POST);
    request.headers().add(U("Content-Type"), U("application/x-www-form-urlencoded"));
    request.set_body(build_auth_body(user, pass));
    request.set_request_uri(uri(uri(token).path()));

    // comment out to reproduce
    http_client client(base_url, config);
    return client.request(request);
}).then([=] (http_response response) {
    return response.extract_json();
});
Thanks,
Marcin

New Post: Problem with Casablanca SDK

$
0
0
Thanks steve for the help. The exception simply says "Error adding the URL to URL group"

New Post: localhost does not work but 127.0.0.1 does

$
0
0
Hi,

As an update to this thread, I have discovered that my client and server applications, when tested with a third-party software, are working well when set to localhost. When tested together though, the server returns a '400 Bad Request Host Name Invalid'.

I have no idea why this is.

I posted on MSDN and they told me to post here. Can you recommend a place to post a question to help solve my above issue?

Thanks,

Andy

BTW, here is the Wireshark (RawCap) capture of the 400 Bad Request:
GET /poll HTTP/1.1
Referer: app:/Scratch.swf
Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5, application/x-mpegURL
x-flash-version: 16,0,0,252
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows; U; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/16.0
Host: 127.0.0.1:1048
Connection: Keep-Alive

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 08 Feb 2015 23:41:10 GMT
Connection: close
Content-Length: 334

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML> 

New Post: Problem with Casablanca SDK

$
0
0
I have to send a POST request from a WCF web service form another PC, to this listener application, (just like the way we send a POST request in IIS Server.) thats why need to use the IP Address instead of local Host.

New Post: Problem with Casablanca SDK

$
0
0
Hi maverick786us,

What is the std::error_code? It will have the underlying error code encountered from the operating system, and can provide more details. Also instead of hardcoding in the IP address you could use '' for the host component: uri_builder uri(L"http://:2001/");

Steve

New Post: C++ Rest SDK 2.5.0

$
0
0
Hi poojabaraskar,

We haven't decided yet on an exact date. Basically we are waiting until we think we've amassed enough changes to make it worthwhile to put out a new release. Is there a particular feature/bug fix you are waiting for? Here is the list of changes so far for 2.5.0.

Thanks,
Steve

New Post: C++ Rest SDK 2.5.0

$
0
0
Hello Steve,

I am building project for galileo (ms-IoT), but unable to build the solution with Casablanca as described here . So I am waiting for the future release as you have mentioned about the support for Intel Galileo in that.

New Post: C++ Rest SDK 2.5.0

$
0
0
I see. To unblock yourself you in the 'development' branch we've added a Visual Studio project for Galileo that you can easily use to build the binaries yourself. The project file is included it in the Visual Studio solution file under the root folder in the repository.

Steve

New Post: C++ Rest SDK 2.5.0

$
0
0
Tried everything, but getting lots of errors.

New Post: C++ Rest SDK 2.5.0

$
0
0
Hi poojabaraskar,

Can you please explain in more detail? What are the exact steps you tried and the errors you are getting? If Galileo doesn't work in the 'development' branch right now then it currently won't work in the 2.5.0 release either.

Thanks,
Steve
Viewing all 4845 articles
Browse latest View live