First of all, apologies if I completely misunderstood this problem, the documentation and online samples are rather thin.
I am doing a fire-and-forget POST webhook call. I am calling the Postman echo server for testing. When request goes through, Postman reports content length 0 and null json in the response. Sometimes I also get a Poco::Exception occurred. [scheme=https, host=postman-echo.com] message=[Not a valid integer: 18446744073309551616] for content length header or a segfault. Due to this weird behaviour, I suspect that executeAsync tries to use some data that has already been deallocated once the method returns from scope.
If I add a sleep or pResponseCb->waitForCompletion(); before returning from method everything works as expected.
Code is almost line by line from async sample, except it is POST instead of GET.
void post(string body) {
//init client and stuff...
easyhttpcpp::MediaType::Ptr pMediaType(new easyhttpcpp::MediaType("application/json; charset=utf-8"));
easyhttpcpp::RequestBody::Ptr pRequestBody = easyhttpcpp::RequestBody::create(pMediaType, body);
easyhttpcpp::Request::Builder requestBuilder;
easyhttpcpp::Request::Ptr pRequest = requestBuilder.setUrl("https://postman-echo.com/post")
.httpPost(pRequestBody)
.build();
easyhttpcpp::Call::Ptr pCall = pHttpClient->newCall(pRequest);
HttpClientCallback::Ptr pResponseCb = new HttpClientCallback();
pCall->executeAsync(pResponseCb);
//pResponseCb->waitForCompletion(); //this makes it work
}
Expected behavior
executeAsync should make a copy of all the data it needs before returning?
Actual behavior
executeAsync seems to rely on the passed data to be valid after returning.
Steps to reproduce
The code sample above should be enough.
Specifications like the version of the project, operating system, or hardware etc.
Windows 10, VS2019, conan package shared build v2.1.0
Brief overview
First of all, apologies if I completely misunderstood this problem, the documentation and online samples are rather thin.
I am doing a fire-and-forget POST webhook call. I am calling the Postman echo server for testing. When request goes through, Postman reports content length 0 and null json in the response. Sometimes I also get a
Poco::Exception occurred. [scheme=https, host=postman-echo.com] message=[Not a valid integer: 18446744073309551616]
for content length header or a segfault. Due to this weird behaviour, I suspect that executeAsync tries to use some data that has already been deallocated once the method returns from scope.If I add a sleep or
pResponseCb->waitForCompletion();
before returning from method everything works as expected.Code is almost line by line from async sample, except it is POST instead of GET.
Expected behavior
executeAsync should make a copy of all the data it needs before returning?
Actual behavior
executeAsync seems to rely on the passed data to be valid after returning.
Steps to reproduce
The code sample above should be enough.
Specifications like the version of the project, operating system, or hardware etc.
Windows 10, VS2019, conan package shared build v2.1.0