Title: executeAsyc relies on passed request data to be valid after returning? · Issue #19 · sony/easyhttpcpp · GitHub
Open Graph Title: executeAsyc relies on passed request data to be valid after returning? · Issue #19 · sony/easyhttpcpp
X Title: executeAsyc relies on passed request data to be valid after returning? · Issue #19 · sony/easyhttpcpp
Description: 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. Wh...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/sony/easyhttpcpp/issues/19
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"executeAsyc relies on passed request data to be valid after returning?","articleBody":"### Brief overview\r\nFirst of all, apologies if I completely misunderstood this problem, the documentation and online samples are rather thin.\r\n\r\nI 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.\r\n\r\nIf I add a sleep or `pResponseCb-\u003ewaitForCompletion();` before returning from method everything works as expected.\r\n\r\nCode is almost line by line from async sample, except it is POST instead of GET.\r\n```c++\r\nvoid post(string body) {\r\n //init client and stuff...\r\n easyhttpcpp::MediaType::Ptr pMediaType(new easyhttpcpp::MediaType(\"application/json; charset=utf-8\"));\r\n easyhttpcpp::RequestBody::Ptr pRequestBody = easyhttpcpp::RequestBody::create(pMediaType, body);\r\n\r\n easyhttpcpp::Request::Builder requestBuilder;\r\n\r\n easyhttpcpp::Request::Ptr pRequest = requestBuilder.setUrl(\"https://postman-echo.com/post\")\r\n .httpPost(pRequestBody)\r\n .build();\r\n easyhttpcpp::Call::Ptr pCall = pHttpClient-\u003enewCall(pRequest);\r\n\r\n HttpClientCallback::Ptr pResponseCb = new HttpClientCallback();\r\n\r\n pCall-\u003eexecuteAsync(pResponseCb);\r\n //pResponseCb-\u003ewaitForCompletion(); //this makes it work\r\n}\r\n```\r\n### Expected behavior\r\nexecuteAsync should make a copy of all the data it needs before returning?\r\n### Actual behavior\r\nexecuteAsync seems to rely on the passed data to be valid after returning.\r\n### Steps to reproduce\r\nThe code sample above should be enough.\r\n### Specifications like the version of the project, operating system, or hardware etc.\r\nWindows 10, VS2019, conan package shared build v2.1.0","author":{"url":"https://github.com/cen1","@type":"Person","name":"cen1"},"datePublished":"2020-09-22T21:08:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/19/easyhttpcpp/issues/19"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7537ffd9-e662-4593-fe04-05fd73651612 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ACB0:1BB557:9E2A38:D3AD9B:6A4C4AFB |
| html-safe-nonce | c52e5ac9421adfbfa189f8e5a02652d434b062675001621c29b4d9e56f906318 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0IwOjFCQjU1Nzo5RTJBMzg6RDNBRDlCOjZBNEM0QUZCIiwidmlzaXRvcl9pZCI6IjM3NzA5Mjk4ODEyMDc4MTkwMDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 410563d34f51a117441c4787f1c942185ed09e75cd4c018c6d294a6825e49d21 |
| hovercard-subject-tag | issue:706694554 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sony/easyhttpcpp/19/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8dc57b07a20d28e212992da4a45b67b829b08116b6b3fc2e9ea30e85b426501a/sony/easyhttpcpp/issues/19 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8dc57b07a20d28e212992da4a45b67b829b08116b6b3fc2e9ea30e85b426501a/sony/easyhttpcpp/issues/19 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cen1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/sony/easyhttpcpp git https://github.com/sony/easyhttpcpp.git |
| octolytics-dimension-user_id | 8435219 |
| octolytics-dimension-user_login | sony |
| octolytics-dimension-repository_id | 99770680 |
| octolytics-dimension-repository_nwo | sony/easyhttpcpp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 99770680 |
| octolytics-dimension-repository_network_root_nwo | sony/easyhttpcpp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 65d78903193f110d7a9d1f8587c6dc3cb911aae0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width