Functions#

This section provides a reference to the HTTP API functions.

Functions#

sl_status_t
sl_http_client_init(const sl_http_client_configuration_t *configuration, sl_http_client_t *client)

Initialize an HTTP client.

sl_status_t
sl_http_client_deinit(sl_http_client_t *client)

Deinitialize an HTTP client and release resources used by HTTP client.

sl_status_t
sl_http_client_request_init(sl_http_client_request_t *request, sl_http_client_event_handler_t event_handler, void *request_context)

Initialize a callback function for the requested HTTP method.

sl_status_t
sl_http_client_add_header(sl_http_client_request_t *request, const char *key, const char *value)

Add extended header with key and value in client request.

sl_status_t
sl_http_client_delete_header(sl_http_client_request_t *request, const char *key)

Delete a specified header field from the extended header based on key of an HTTP client request.

sl_status_t
sl_http_client_delete_all_headers(sl_http_client_request_t *request)

Delete all the headers from the extended header of an HTTP client request.

sl_status_t
sl_http_client_send_request(const sl_http_client_t *client, const sl_http_client_request_t *request)

Send HTTP request.

sl_status_t
sl_http_client_write_chunked_data(const sl_http_client_t *client, uint8_t *data, uint32_t data_length, bool flush_now)

Send an HTTP POST and PUT chunked data.

Function Documentation#

sl_http_client_init#

sl_status_t sl_http_client_init (const sl_http_client_configuration_t * configuration, sl_http_client_t * client)

Initialize an HTTP client.

Parameters
[in]configuration

HTTP client configuration of type sl_http_client_configuration_t

[out]client

sl_http_client_t object which will be initialized with client handle.

Returns


Definition at line 210 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_deinit#

sl_status_t sl_http_client_deinit (sl_http_client_t * client)

Deinitialize an HTTP client and release resources used by HTTP client.

Parameters
[in]client

HTTP client's handle of type sl_http_client_t

Returns

Note

  • User must call this API to release the resources once the HTTP client is no longer needed. This function deletes extended headers if any exists during deinitialization.


Definition at line 226 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_request_init#

sl_status_t sl_http_client_request_init (sl_http_client_request_t * request, sl_http_client_event_handler_t event_handler, void * request_context)

Initialize a callback function for the requested HTTP method.

Parameters
[in]request

HTTP client request configuration of type sl_http_client_request_t

[in]event_handler

HTTP client callback event handler of type sl_http_client_event_handler_t

[in]request_context

User defined context pointer. Memory space for the user defined context must be valid till the response is received.

Returns


Definition at line 244 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_add_header#

sl_status_t sl_http_client_add_header (sl_http_client_request_t * request, const char * key, const char * value)

Add extended header with key and value in client request.

Parameters
[in]request

HTTP client request configuration of type sl_http_client_request_t

[in]key

Header key.

[in]value

Header value.

Returns

Note

  • If a request does not contain any extended header, this API allocates memory for it.


Definition at line 265 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_delete_header#

sl_status_t sl_http_client_delete_header (sl_http_client_request_t * request, const char * key)

Delete a specified header field from the extended header based on key of an HTTP client request.

Parameters
[in]request

HTTP client request configuration of type sl_http_client_request_t

[in]key

Header key.

Returns


Definition at line 280 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_delete_all_headers#

sl_status_t sl_http_client_delete_all_headers (sl_http_client_request_t * request)

Delete all the headers from the extended header of an HTTP client request.

Parameters
[in]request

HTTP client request configuration of type sl_http_client_request_t

Returns

Note

  • User must call this API to free the memory allocated to headers.


Definition at line 295 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_send_request#

sl_status_t sl_http_client_send_request (const sl_http_client_t * client, const sl_http_client_request_t * request)

Send HTTP request.

Parameters
[in]client

HTTP client handle of type sl_http_client_t

[in]request

HTTP client request configuration of type sl_http_client_request_t

Returns

Note

    1. HTTP HEAD and DELETE methods are not supported in Si91x specific chipsets.

    2. body_length header in request by default internally in Si91x specific chipsets.

    3. HTTP PUT does not support sending body through this API, it is mandatory to call sl_http_client_write_chunked_data() in Si91x specific chipsets.


Definition at line 314 of file components/service/http_client/inc/sl_http_client.h

sl_http_client_write_chunked_data#

sl_status_t sl_http_client_write_chunked_data (const sl_http_client_t * client, uint8_t * data, uint32_t data_length, bool flush_now)

Send an HTTP POST and PUT chunked data.

Parameters
[in]client

HTTP client handle of type sl_http_client_t

[in]data

Buffer pointer of data to be written.

[in]data_length

Length of data/chunk to be sent.

[in]flush_now

Returns

Note

  • : flush_now feature is not supported in Si91x specific chipsets.


Definition at line 334 of file components/service/http_client/inc/sl_http_client.h