Restbed HTTP Client Empty Body
<p>I tied to implement a REST Client with C++ and the Restbed Library</p>

<p>I tried to copy the code from the example but seem to be missing something.</p>

<p>The Example shows a body but my code does not.</p>

<p>I tried playing with the Headers but no luck.</p>

<p>Can anybody with some knowledge of the library point me in the right direction?</p>

<p>Or suggest me a easy to use C++ REST Library that runs on Solaris?</p>

<p>The Example:</p>

<pre><code>/*
 * Example illustrating a HTTP client.
 *
 * Usage:
 *    ./distribution/example/http_client
 */

#include &lt;memory&gt;
#include &lt;future&gt;
#include &lt;cstdio&gt;
#include &lt;cstdlib&gt;
#include &lt;restbed&gt;

using namespace std;
using namespace restbed;

void print( const shared_ptr&lt; Response &gt;&amp; response )
{
    fprintf( stderr, "*** Response ***\n" );
    fprintf( stderr, "Status Code:    %i\n", response-&gt;get_status_code( ) );
    fprintf( stderr, "Status Message: %s\n", response-&gt;get_status_message( ).data( ) );
    fprintf( stderr, "HTTP Version:   %.1f\n", response-&gt;get_version( ) );
    fprintf( stderr, "HTTP Protocol:  %s\n", response-&gt;get_protocol( ).data( ) );

    for ( const auto header : response-&gt;get_headers( ) )
    {
        fprintf( stderr, "Header '%s' &gt; '%s'\n", header.first.data( ), header.second.data( ) );
    }

    auto length = 0;
    response-&gt;get_header( "Content-Length", length );

    Http::fetch( length, response );

    fprintf( stderr, "Body:           %.*s...\n\n", 25, response-&gt;get_body( ).data( ) );
}

int main( const int, const char** )
{
    auto request = make_shared&lt; Request &gt;( Uri( "http://www.corvusoft.co.uk:80/?query=search%20term" ) );
    request-&gt;set_header( "Accept", "*/*" );
    request-&gt;set_header( "Host", "www.corvusoft.co.uk" );

    auto response = Http::sync( request );
    print( response );

    auto future = Http::async( request, [ ]( const shared_ptr&lt; Request &gt;, const shared_ptr&lt; Response &gt; response )
    {
        fprintf( stderr, "Printing async response\n" );
        print( response );
    } );

    future.wait( );

    return EXIT_SUCCESS;
}
</code></pre>

<p>My current Implementation</p>

<pre><code>#include "HttpClient.h"
#include "HTTPException.h"
#include &lt;restbed&gt;
#include &lt;iostream&gt;

using namespace std;
using namespace restbed;

void HttpClient::getVersion_0() {
    auto request = make_shared&lt; Request &gt;( Uri( "http://www.golem.de/" ) );
    request-&gt;set_header( "Accept", "*/*" );
    request-&gt;set_header( "Cache-Control", "no-cache" );
    request-&gt;set_header("Accept-Encoding", "gzip,deflate");
    request-&gt;set_header("User-Agent", "PKG6/0.0.1");
    request-&gt;set_header("Host", "www.golem.de");
    request-&gt;set_header("Connection", "Keep-Alive");
    request-&gt;set_method("GET");

    auto response = Http::sync( request );

    int code = response-&gt;get_status_code();
/*
    if(code != 200){
        throw pkg::exception::HTTPBadResponseException(code);
    }
*/
    print(response);

    /*
    auto future = Http::async( request, [ ]( const shared_ptr&lt; Request &gt;, const shared_ptr&lt; Response &gt; response )
    {

    } );

    future.wait( );

    */
}


void HttpClient::print(const std::shared_ptr&lt;restbed::Response&gt; &amp;response) {
    fprintf( stderr, "\n*** Response ***\n" );
    fprintf( stderr, "Status Code:    %i\n", response-&gt;get_status_code( ) );
    fprintf( stderr, "Status Message: %s\n", response-&gt;get_status_message( ).data( ) );
    fprintf( stderr, "HTTP Version:   %.1f\n", response-&gt;get_version( ) );
    fprintf( stderr, "HTTP Protocol:  %s\n", response-&gt;get_protocol( ).data( ) );

    for ( const auto header : response-&gt;get_headers( ) )
    {
        fprintf( stderr, "Header '%s' &gt; '%s'\n", header.first.data( ), header.second.data( ) );
    }

    auto length = 0;
    response-&gt;get_header( "Content-Length", length );

    Http::fetch( length, response );

    fprintf( stderr, "Body:           %.*s...\n\n", 25, response-&gt;get_body( ).data( ) );
}
</code></pre>