HTTP Client
Providing a custom HTTP implementation for the Vertices SDK
Our header, your implementation
We provide functions signatures in vertices_http.h .
The SDK will call those functions when needed.
Client Init/DeInit
The http_init function is called on Vertices SDK initialization.
/// Init HTTP client
/// \param provider Remote API URL, port, specific header and certificate if needed by the client
/// \param response_payload_cb Function callback to call when data is ready to be parsed
/// \return \c VTC_SUCCESS on success, otherwise error depends on implementation
ret_code_t
http_init(const provider_info_t *provider,
size_t (*response_payload_cb)(char *chunk,
size_t chunk_size));
/// Close/deinit the client
void
http_close(void);The init function is simple: all you have to do is to init the HTTP client using the parameters. The URL, port, specific headers, and certificates are passed with the provider parameter.
The callback function reponse_payload_cb must be kept locally as we will need to call it whenever a response is received after a GET or a POST method call.
The callback
The callback function will be called whenever an HTTP response body is ready to be parsed: a pointer to the received bytes chunk and the size chunk_size will be provided to the Vertices SDK when calling the callback. The buffer can be a pointer allocated by the underlying HTTP client.