Quantcast
Channel: casablanca Discussions Rss Feed
Viewing all 2679 articles
Browse latest View live

New Post: Error C2679 in asyncrt_utils.h file while building C++ REST project

$
0
0
Thanks Steve,

Using std::wstring instead of std::string solved my problem.

New Post: Adding the Two Numbers Using C++ REST SDK

$
0
0
Thank You Very Much.. Lot of thanks..

Thanks,
Pari

New Post: Adding the Two Numbers Using C++ REST SDK

$
0
0
Hi steve and Bsalita,
I have one more Question :

How to get a input value in command line prompt.

For Example:

Output:

Enter the Number1: 10
Enter the Number2: 10

Total value is = 20

that one is not working...
help me.. steve and Bsalita..

New Post: Adding the Two Numbers Using C++ REST SDK

$
0
0
In my rewritten example above, I had removed instances of std::cin. You can't use cin inside lamdas that are on another thread. I substituted time() to provide a somewhat unique value. If you are asking about retrieving values from the command line, use main's argc and args.

New Post: Simple Listener Program Faulting on Linux

$
0
0
Oh, oh. Identical hang on Windows v2.1. Didn't happen on Windows v2.01. Happens using curl too. This is a weird twist. I'll look into this further after a night's sleep.

New Post: v2.1 Breaks http_request Queuing

$
0
0
I implemented a request queuing scheme that worked prior to v2.1. No longer works with v2.1. Is it a bug in C++ Rest SDK? What is the workaround?

The idea is to defer reply() processing by queuing incoming requests inside listener.support() lamda. Some brief time later the queued request is popped in the main() thread and a reply() is issued. The issue is that wait() after close() always hangs. This issue looks similar to Simple Listener Program Faulting on Linux.

What's the correct way of deferring/queuing incoming requests? Isn't there an issue if a request comes in a split second before close(), before listener.support reply is executed, thus causing wait() to hang forever?
#include "cpprest/http_client.h"
#include "cpprest/http_listener.h"
#include "concurrent_queue.h"

Concurrency::concurrent_queue<web::http::http_request> cq;

int main()
{
    try
    {
        web::http::experimental::listener::http_listener listener(U("http://192.168.1.104:3901"));
        listener.support([=](web::http::http_request request) { cq.push(request); /*request.reply(web::http::status_codes::OK, U("Hello, World!"));*/ });
        listener.open().wait();
        std::string line;
        std::cout << "listening. hit enter to initiate shutdown." << std::endl;
        std::getchar();
        std::cout << "popping requests" << std::endl;
        web::http::http_request request;
        while (cq.try_pop(request))
            request.reply(web::http::status_codes::ServiceUnavailable);
        std::cout << "closing" << std::endl;
        Concurrency::task<void> task = listener.close();
        std::cout << "waiting" << std::endl;
        task.wait();
        std::cout << "ending" << std::endl;
    }
    catch (...)
    {
        std::cout << "caught error" << std::endl;
    }
    return(0);
}

New Post: Adding the Two Numbers Using C++ REST SDK

$
0
0
Thank You.. Bsalita..


Thanks,
Pari

New Post: what is application/x-json?

$
0
0
client.request(methods::POST, L"", L"arsId=09286", L"application/x-www-form-urlencoded")

error is caught like below
Content-Type must be JSON to extract (is : application/x-json)

I don't know why this error occur.

New Post: iOS directions don't work for 64 bit simulator

New Post: iOS directions don't work for 64 bit simulator

$
0
0
Hi Les,

Thanks for bringing this to our attention.

After comparing the scripts, it seems that the best short-term workaround is to add -arch x86_64 to line 140 of boost.sh:
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch i386 -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
becomes
: $XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/$COMPILER -arch i386 -arch x86_64 -fvisibility-inlines-hidden $EXTRA_CPPFLAGS
I've copied this into a work item for tracking: https://casablanca.codeplex.com/workitem/196

Thanks,
roschuma

New Post: what is application/x-json?

$
0
0
Hi bongdragon,

application/x-json is a MIME type (see http://en.wikipedia.org/wiki/MIME for more details on that). Casablanca expects that JSON payloads will have a MIME type of either application/json (the official MIME type for JSON), text/json, text/x-json, text/javascript, text/x-javascript, application/javascript, or application/x-javascript.

If you control the website you're connecting to, you should change the returned MIME type to application/json. If you do not control the website, you can work around this by using extract_string instead of extract_json and then passing it to
json::value obj = json::value::parse(extracted_string);
Sincerely,
roschuma

New Post: what is application/x-json?

$
0
0
thank you for reply

I try to change extract_string, but I encounter another problem
error code is like below
Content-type must be textual to extract a string

I want to get this data.
Image
Image

New Post: How to learn the C++ REST SDK.. and Please give me a Sample 10 questions for c++ Rest SDK..

$
0
0
How to Learn the C++ REST SDK for any books or websites available?? Please tell me..
Please give me a 10 sample Problems for c++ Rest SDK.. because, i practice it..
Thanks,
Bharathij

New Post: CPP Rest SDK, Build errors while building my project

$
0
0
Hi Kavya,

Yes these steps work, I have to check my other project's configuration, there has to be a problem that causes these errors in streams.h

Thanks
Mohamed

New Post: Casablanca Concurrency Error

$
0
0
Hello,

I have the this code:
    http_client client(LOGIN_SERVICE_URL);
    uri_builder builder(OAUTH2_CONTEXT_PATH);
    
builder.append_query(L"grant_type", L"password");
builder.append_query(L"username", username);
    builder.append_query(L"password", password);
    builder.append_query(L"scope", L"send_hybrid");

    http_request request(methods::POST);
    request.headers().add(L"Authorization", AUTH_STRING);
    request.headers().add(L"content-type", L"application/x-www-form-urlencoded");
    request.set_request_uri(builder.to_uri());

    client.request(request);
and get this unobserved exception:
cpprest120d_xp_2_1.dll!Concurrency::details::_ExceptionHolder::~_ExceptionHolder(void)  Unknown
cpprest120d_xp_2_1.dll!Concurrency::details::_ExceptionHolder::`scalar deleting destructor'(unsigned int)   Unknown
cpprest120d_xp_2_1.dll!std::_Ref_count_obj<struct Concurrency::details::_ExceptionHolder>::_Destroy(void)   Unknown
cpprest120d_xp_2_1.dll!std::_Ref_count_base::_Decref(void)  Unknown
cpprest120d_xp_2_1.dll!std::_Ptr_base<struct Concurrency::details::_ExceptionHolder>::_Decref(void) Unknown
cpprest120d_xp_2_1.dll!std::shared_ptr<struct Concurrency::details::_ExceptionHolder>::~shared_ptr<struct Concurrency::details::_ExceptionHolder>(void) Unknown
cpprest120d_xp_2_1.dll!Concurrency::details::_Task_completion_event_impl<class web::http::http_response>::~_Task_completion_event_impl<class web::http::http_response>(void)    Unknown
cpprest120d_xp_2_1.dll!Concurrency::details::_Task_completion_event_impl<class web::http::http_response>::`scalar deleting destructor'(unsigned int)    Unknown
cpprest120d_xp_2_1.dll!std::_Ref_count_obj<struct Concurrency::details::_Task_completion_event_impl<class web::http::http_response> >::_Destroy(void)   Unknown
cpprest120d_xp_2_1.dll!std::_Ref_count_base::_Decref(void)  Unknown
cpprest120d_xp_2_1.dll!std::_Ptr_base<struct Concurrency::details::_Task_completion_event_impl<class web::http::http_response> >::_Decref(void) Unknown
cpprest120d_xp_2_1.dll!std::shared_ptr<struct Concurrency::details::_Task_completion_event_impl<class web::http::http_response> >::~shared_ptr<struct Concurrency::details::_Task_completion_event_impl<class web::http::http_response> >(void) Unknown
cpprest120d_xp_2_1.dll!Concurrency::task_completion_event<class web::http::http_response>::~task_completion_event<class web::http::http_response>(void) Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::request_context::~request_context(void)  Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::winhttp_request_context::~winhttp_request_context(void)  Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::winhttp_request_context::`vector deleting destructor'(unsigned int)  Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::winhttp_request_context::finish(void)    Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::request_context::report_exception(class std::exception_ptr)  Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::request_context::report_exception<class web::http::http_exception>(class web::http::http_exception)  Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::request_context::report_error(unsigned long,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)    Unknown
cpprest120d_xp_2_1.dll!web::http::client::details::winhttp_client::completion_callback(void *,unsigned long,unsigned long,void *,unsigned long) Unknown
winhttp.dll!73f34b87()  Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for winhttp.dll]   
[External Code] 
The lib was installed as NuGet Package.
Visual Studio 2013 v. 12.021005.1
Windows 8.1 Pro

What I am doing wrong?

New Post: How to extract some info from the http_client response via XmlLite?

$
0
0
Hi Steve,

I have actually tried the CreateStreamOnHGlobal as seen in the code above. I did not find anything appropriate in the samples and I could not make the code work (too black box). I have finally implemented a slopy data extractor that works fine for the purpose.

Thanks for your help and have a nice day,

Petr

New Post: CPP Rest SDK, Build errors while building my project

$
0
0
Do let us know if you narrow down what settings result in the compile error. We can then investigate if it is a Casablanca bug or not.

Thanks
Kavya

New Post: HTTP API Help

$
0
0
Hi All,

I'm using Casablanca to help me use my C++ code to make HTTP requests for an API for a video editing software (vMix). The way that API is set up, I need to make a separate request for each function I want to perform in the vMix software. Does anyone have any suggestions for a simple way to code multiple requests in a single script?

Thanks

New Post: Windows: v2.1 Breaks http_request Queuing

$
0
0
Hi BSalita,

Let me explain first about how the close semantics work with our http_listener. Most uses of our http_listener follow the typical pattern of responding to requests directly in the support handler callback. When doing so you don't need to really know any more. If you are going to start saving requests off for responding to later then you need to be careful.

The way to think about it is for each http_request a reference count is incremented on the listener. Once the request has been responded to and there are no other references to the http_request object the reference count is decremented. If close is called we wait for the reference count to go to zero before signaling the returned task. This is what is causing the hang you are seeing. Close isn't being completed because there are still some http_request objects alive. So if you are saving requests to respond later, the task from close won't be completed until you respond to each request AND destroy the http_request objects.

I'm not sure who is still holding onto an http_request object in your code, but one thing I noticed is in the support lambda you are capturing the concurrent_queue by value with is going to copy the queue. I don't think you want this. As a starting point try out the following code, which works fine for me using a std::queue:
    web::http::experimental::listener::http_listener listener(U("http://localhost:3901"));

    std::queue<::web::http::http_request> requests;
    listener.support([&](::web::http::http_request request) mutable
    {
        requests.push(request);
    });
    listener.open().wait();
    std::cout << "listening. hit enter to initiate shutdown." << std::endl;
    std::getchar();
    std::cout << "popping requests" << std::endl;
    while (!requests.empty())
    {
        requests.front().reply(web::http::status_codes::ServiceUnavailable).wait();
        requests.pop();
    }

    std::cout << "closing" << std::endl;
    Concurrency::task<void> task = listener.close();
    std::cout << "waiting" << std::endl;
    task.wait();
    std::cout << "ending" << std::endl;
Thanks,
Steve

New Post: How to learn the C++ REST SDK.. and Please give me a Sample 10 questions for c++ Rest SDK..

$
0
0
Hi Bharathji,

My best recommendation would be for you to peruse our documentation page. Specifically the page for each major feature area, like for example the http_client.

You can also look at some of the samples located in the repository under the Release\samples directory. Another are of information are some of the blog posts that have been written about the C++ Rest SDK, keep in mind older ones might be somewhat outdated as changes have occurred.

Thanks,
Steve
Viewing all 2679 articles
Browse latest View live


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