Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
sol_http_request_interface Struct Reference

The HTTP request interface to use when creating a new request. More...

#include <sol-http-client.h>

Data Fields

uint16_t api_version
 api_version must match SOL_HTTP_REQUEST_INTERFACE_API_VERSION at runtime. More...
 
size_t data_buffer_size
 The size in bytes of the receiving data buffer. More...
 
ssize_t(* on_data )(void *user_data, struct sol_http_client_connection *connection, const struct sol_buffer *buffer)
 This callback is called whenever data comes. More...
 
void(* on_response )(void *user_data, struct sol_http_client_connection *connection, struct sol_http_response *response)
 This callback is called when the request finishes, the result of request is available on response. More...
 
ssize_t(* on_send )(void *user_data, struct sol_http_client_connection *connection, struct sol_buffer *buffer)
 This callback is called data should be written, it's commonly used for POST. More...
 

Detailed Description

The HTTP request interface to use when creating a new request.

It allows one to have more control over the request, notifying when data comes or when data should be sent.

See Also
sol_http_client_request_with_interface()
Note
HTTP client follows the Soletta stream design pattern, which can be found here: IO Streams
Examples:
/src/samples/http/download.c.

Field Documentation

uint16_t sol_http_request_interface::api_version

api_version must match SOL_HTTP_REQUEST_INTERFACE_API_VERSION at runtime.

Examples:
/src/samples/http/download.c.
size_t sol_http_request_interface::data_buffer_size

The size in bytes of the receiving data buffer.

0 means unlimited buffer size (It will always grow).

See Also
sol_http_request_interface::on_data
ssize_t(* sol_http_request_interface::on_data)(void *user_data, struct sol_http_client_connection *connection, const struct sol_buffer *buffer)

This callback is called whenever data comes.

The number of bytes consumed (the value returned by this callback) will be removed from buffer.

It should return the number of bytes taken care of in case of success, any negative value will abort the trasnfer.

The parameters are:

  • user_data the context data given in sol_http_client_request_with_interface
  • connection the connection returned in sol_http_client_request_with_interface
  • buffer the data received
Note
it is allowed to cancel the connection handle from inside this callback.
void(* sol_http_request_interface::on_response)(void *user_data, struct sol_http_client_connection *connection, struct sol_http_response *response)

This callback is called when the request finishes, the result of request is available on response.

See Also
sol_http_response
  • user_data the context data given in sol_http_client_request_with_interface
  • connection the connection returned in sol_http_client_request_with_interface
  • response the result of the request
Note
it is allowed to cancel the connection handle from inside this callback.
ssize_t(* sol_http_request_interface::on_send)(void *user_data, struct sol_http_client_connection *connection, struct sol_buffer *buffer)

This callback is called data should be written, it's commonly used for POST.

When it's used, it's MANDATORY either the header Content-Length with the correct size or the header Transfer-Encoding with the value chunked on sol_http_client_request_with_interface.

It should return the number of bytes written into buffer on success, any negative value will abort the trasnfer.

The parameters are:

  • user_data the context data given in sol_http_client_request_with_interface
  • connection the connection returned in sol_http_client_request_with_interface
  • buffer the buffer where the data should be written, the buffer's capacity indicates the amount of data that should be set.
Note
it is allowed to cancel the connection handle from inside this callback.

The documentation for this struct was generated from the following file: