Question:
I want to do a HTTP request asynchronously by using the CkHttp_SynchronousRequestAsync
function (C API), but I'm not seeing any way of getting the HTTP response once the async call finishes. How can I do that?
The CkHttp_SynchronousRequest
function returns a HCkHttpResponse
, which I can process, but how can I do it asynchronously?
After the async call has completed, you can get the result by calling the CkHttpResponse_LoadTaskResult function.
BOOL CkHttpResponse_LoadTaskResult(HCkHttpResponse cHandle, HCkTask task);Introduced in version 9.5.0.52 Loads the HTTP response from a completed asynchronous task. Returns TRUE for success, FALSE for failure.
You would instantiate a new/empty HTTP response object, then load it with the task result, like this:
HCkHttpResponse response = CkHttpResponse_Create(); BOOL success = CkHttpResponse_LoadTaskResult(response, task);
For any asynchronous Chilkat method that returns a Chilkat object (of type T), there will be a corresponding T::LoadTaskResult method. Given that "C" is not object-oriented, it is a function using object handles.