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 Structures | Macros | Typedefs | Enumerations | Functions
sol-http.h File Reference
#include <sol-arena.h>
#include <sol-buffer.h>
#include <sol-macros.h>
#include <sol-str-slice.h>
#include <sol-vector.h>
#include <inttypes.h>

Go to the source code of this file.

Data Structures

struct  sol_http_content_type_priority
 Used to rank content type priorities. More...
 
struct  sol_http_param_value
 Used to define an HTTP parameter. More...
 
struct  sol_http_params
 Keep vector of HTTP parameters to be sent in a request. More...
 
struct  sol_http_response
 Handle for an HTTP response. More...
 
struct  sol_http_url
 Handle for an HTTP URL. More...
 

Macros

#define SOL_HTTP_PARAM_API_VERSION   (1)
 
#define SOL_HTTP_PARAMS_CHECK_API_VERSION(params_,...)
 Macro used to check if a struct sol_http_params has the expected API version. More...
 
#define SOL_HTTP_PARAMS_CHECK_API_VERSION_GOTO(params_, label_)
 Macro used to check if a struct sol_http_params has the expected API version. More...
 
#define SOL_HTTP_PARAMS_FOREACH_IDX(param, itrvar, idx)
 Macro used to iterate over a vector of HTTP parameters. More...
 
#define SOL_HTTP_REQUEST_PARAM_ALLOW_REDIR(setting_)   SOL_HTTP_REQUEST_PARAM_BOOL(SOL_HTTP_PARAM_ALLOW_REDIR, setting_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_ALLOW_REDIR and true or false as value. More...
 
#define SOL_HTTP_REQUEST_PARAM_AUTH_BASIC(username_, password_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_AUTH_BASIC, username and password. More...
 
#define SOL_HTTP_REQUEST_PARAM_BOOL(type_, setting_)
 Macro to set a struct sol_http_param_value with a boolean and type passed as argument. More...
 
#define SOL_HTTP_REQUEST_PARAM_COOKIE(key_, value_)   SOL_HTTP_REQUEST_PARAM_KEY_VALUE(SOL_HTTP_PARAM_COOKIE, key_, value_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_COOKIE and key-value. More...
 
#define SOL_HTTP_REQUEST_PARAM_HEADER(header_, content_)   SOL_HTTP_REQUEST_PARAM_KEY_VALUE(SOL_HTTP_PARAM_HEADER, header_, content_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_HEADER, a header and content. More...
 
#define SOL_HTTP_REQUEST_PARAM_KEY_VALUE(type_, key_, value_)
 Macro to set a struct sol_http_param_value with key-value and type passed as argument. More...
 
#define SOL_HTTP_REQUEST_PARAM_POST_DATA_CONTENTS(key_, value_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_POST_DATA and the given value. More...
 
#define SOL_HTTP_REQUEST_PARAM_POST_DATA_FILE(key_, filename_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_POST_DATA and the contents of filename_. More...
 
#define SOL_HTTP_REQUEST_PARAM_POST_FIELD(key_, value_)   SOL_HTTP_REQUEST_PARAM_KEY_VALUE(SOL_HTTP_PARAM_POST_FIELD, key_, value_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_POST_FIELD and key-value. More...
 
#define SOL_HTTP_REQUEST_PARAM_QUERY(key_, value_)   SOL_HTTP_REQUEST_PARAM_KEY_VALUE(SOL_HTTP_PARAM_QUERY_PARAM, key_, value_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_QUERY_PARAM and key-value. More...
 
#define SOL_HTTP_REQUEST_PARAM_TIMEOUT(setting_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_TIMEOUT and timeout value. More...
 
#define SOL_HTTP_REQUEST_PARAM_VERBOSE(setting_)   SOL_HTTP_REQUEST_PARAM_BOOL(SOL_HTTP_PARAM_VERBOSE, setting_)
 Macro to set a struct sol_http_param_value with type SOL_HTTP_PARAM_VERBOSE and true or false as value. More...
 
#define SOL_HTTP_REQUEST_PARAMS_INIT
 Macro used to initialize a struct sol_http_params with empty vector. More...
 
#define SOL_HTTP_RESPONSE_API_VERSION   (1)
 
#define SOL_HTTP_RESPONSE_CHECK_API(response_,...)
 Macro used to check if a struct sol_http_response is valid (different from NULL) and has the expected API version or return. More...
 
#define SOL_HTTP_RESPONSE_CHECK_API_GOTO(response_, label)
 Macro used to check if a struct sol_http_response is valid (different from NULL) and has the expected API version or goto a label. More...
 
#define SOL_HTTP_RESPONSE_CHECK_API_VERSION(response_,...)
 Macro used to check if a struct sol_http_response has the expected API version or return. More...
 
#define SOL_HTTP_RESPONSE_CHECK_API_VERSION_GOTO(response_, label)
 Macro used to check if a struct sol_http_response has the expected API version or goto a label. More...
 

Typedefs

typedef struct sol_http_param_value sol_http_param_value
 Used to define an HTTP parameter. More...
 
typedef struct sol_http_params sol_http_params
 Keep vector of HTTP parameters to be sent in a request. More...
 
typedef struct sol_http_response sol_http_response
 Handle for an HTTP response. More...
 
typedef struct sol_http_url sol_http_url
 Handle for an HTTP URL. More...
 

Enumerations

enum  sol_http_method {
  SOL_HTTP_METHOD_GET, SOL_HTTP_METHOD_POST, SOL_HTTP_METHOD_HEAD, SOL_HTTP_METHOD_DELETE,
  SOL_HTTP_METHOD_PUT, SOL_HTTP_METHOD_CONNECT, SOL_HTTP_METHOD_OPTIONS, SOL_HTTP_METHOD_TRACE,
  SOL_HTTP_METHOD_PATCH, SOL_HTTP_METHOD_INVALID
}
 Type of HTTP method. More...
 
enum  sol_http_param_type {
  SOL_HTTP_PARAM_QUERY_PARAM, SOL_HTTP_PARAM_COOKIE, SOL_HTTP_PARAM_POST_FIELD, SOL_HTTP_PARAM_POST_DATA,
  SOL_HTTP_PARAM_HEADER, SOL_HTTP_PARAM_AUTH_BASIC, SOL_HTTP_PARAM_ALLOW_REDIR, SOL_HTTP_PARAM_TIMEOUT,
  SOL_HTTP_PARAM_VERBOSE, SOL_HTTP_PARAM_FRAGMENT
}
 Type of HTTP parameter. More...
 
enum  sol_http_status_code {
  SOL_HTTP_STATUS_OK = 200, SOL_HTTP_STATUS_FOUND = 302, SOL_HTTP_STATUS_SEE_OTHER = 303, SOL_HTTP_STATUS_NOT_MODIFIED = 304,
  SOL_HTTP_STATUS_BAD_REQUEST = 400, SOL_HTTP_STATUS_FORBIDDEN = 403, SOL_HTTP_STATUS_NOT_FOUND = 404, SOL_HTTP_STATUS_METHOD_NOT_ALLOWED = 405,
  SOL_HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, SOL_HTTP_STATUS_NOT_IMPLEMENTED = 501
}
 Status codes as defined by HTTP protocol. More...
 

Functions

void sol_http_content_type_priorities_array_clear (struct sol_vector *priorities)
 Clears the priorities array. More...
 
int sol_http_create_full_uri (struct sol_buffer *buf, const struct sol_http_url url, const struct sol_http_params *params)
 Creates an URI based on struct sol_http_url and its parameters. More...
 
int sol_http_create_uri (struct sol_buffer *buf, const struct sol_str_slice base_uri, const struct sol_http_params *params)
 A simpler version of sol_http_create_full_uri(). More...
 
static int sol_http_create_uri_from_str (struct sol_buffer *buf, const char *base_url, const struct sol_http_params *params)
 A wrapper on top of sol_http_create_uri() More...
 
int sol_http_decode_params (const struct sol_str_slice params_slice, enum sol_http_param_type type, struct sol_http_params *params)
 Decodes HTTP parameters of a given type. More...
 
int sol_http_decode_slice (struct sol_buffer *buf, const struct sol_str_slice value)
 Decodes an URL string. More...
 
int sol_http_encode_params (struct sol_buffer *buf, enum sol_http_param_type type, const struct sol_http_params *params)
 Encodes HTTP parameters of a given type. More...
 
int sol_http_encode_slice (struct sol_buffer *buf, const struct sol_str_slice value)
 Encodes an URL string. More...
 
int sol_http_params_add (struct sol_http_params *params, struct sol_http_param_value value)
 Add a new parameter to HTTP parameters vector. More...
 
int sol_http_params_add_copy (struct sol_http_params *params, struct sol_http_param_value value)
 Add a new parameter to HTTP parameters vector copying strings. More...
 
void sol_http_params_clear (struct sol_http_params *params)
 Clear vector of HTTP parameters. More...
 
static void sol_http_params_init (struct sol_http_params *params)
 Initialize HTTP parameters struct with an empty vector. More...
 
int sol_http_parse_content_type_priorities (const struct sol_str_slice content_type, struct sol_vector *priorities)
 Sort the content type slice based on its priorities. More...
 
int sol_http_split_post_field (const char *query, struct sol_http_params *params)
 Split post/field string into parameters. More...
 
int sol_http_split_query (const char *query, struct sol_http_params *params)
 Split query into parameters. More...
 
int sol_http_split_uri (const struct sol_str_slice full_uri, struct sol_http_url *url)
 Split an URI. More...
 

Macro Definition Documentation

#define SOL_HTTP_PARAM_API_VERSION   (1)

Referenced by sol_http_params_init().

#define SOL_HTTP_RESPONSE_API_VERSION   (1)