Microchip® Advanced Software Framework

wilc/at_commands_wilc1000_wilc3000_example/iot/http/http_client.h File Reference

HTTP client service.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

#include "common/include/nm_common.h"
#include "iot/sw_timer.h"
#include "http_entity.h"
#include <stdint.h>

Data Structures

struct  http_client_config
 HTTP client configuration structure. More...
 
union  http_client_data
 Structure of the HTTP client callback. More...
 
struct  http_client_data_disconnected
 Structure of the HTTP_CLIENT_CALLBACK_DISCONNECTED callback. More...
 
struct  http_client_data_recv_chunked_data
 Structure of the HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA callback. More...
 
struct  http_client_data_recv_response
 Structure of the HTTP_CLIENT_CALLBACK_RECV_RESPONSE callback. More...
 
struct  http_client_data_requested
 Structure of the HTTP_CLIENT_CALLBACK_REQUESTED callback. More...
 
struct  http_client_data_sock_connected
 Structure of the HTTP_CLIENT_CALLBACK_SOCK_CONNECTED callback. More...
 
struct  http_client_module
 Structure of HTTP client connection instance. More...
 
struct  http_client_req
 HTTP client request instance. More...
 
struct  http_client_resp
 HTTP client response instance. More...
 

Macros

#define _htonl(x)
 
#define _htons(A)   (uint16)((((uint16) (A)) << 8) | (((uint16) (A)) >> 8))
 
#define DEFAULT_HTTP_PORT   80
 
#define DEFAULT_PORT   DEFAULT_HTTP_PORT
 
#define HOSTNAME_MAX_SIZE   64
 
#define HTTP_MAX_URI_LENGTH   128
 Max size of URI. More...
 
#define HTTP_PROTO_NAME   "HTTP/1.1"
 Protocol version string of HTTP client. More...
 
#define IPV4_BYTE(val, index)   ((val >> (index * 8)) & 0xFF)
 IP address parsing. More...
 
#define MAX_SOCKET   (TCP_SOCK_MAX + UDP_SOCK_MAX)
 
#define TCP_SOCK_MAX   (7)
 
#define UDP_SOCK_MAX   4
 

Typedefs

typedef void(* http_client_callback_t )(struct http_client_module *module_inst, int type, union http_client_data *data)
 Callback interface of HTTP client service. More...
 

Enumerations

enum  http_client_callback_type {
  HTTP_CLIENT_CALLBACK_SOCK_CONNECTED,
  HTTP_CLIENT_CALLBACK_REQUESTED,
  HTTP_CLIENT_CALLBACK_RECV_RESPONSE,
  HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA,
  HTTP_CLIENT_CALLBACK_DISCONNECTED,
  HTTP_CLIENT_CALLBACK_SOCK_CONNECTED,
  HTTP_CLIENT_CALLBACK_REQUESTED,
  HTTP_CLIENT_CALLBACK_RECV_RESPONSE,
  HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA,
  HTTP_CLIENT_CALLBACK_RECV_NO_CONTENT_LENGTH_DATA,
  HTTP_CLIENT_CALLBACK_DISCONNECTED
}
 A type of HTTP client callback. More...
 
enum  http_method {
  HTTP_METHOD_GET = 1,
  HTTP_METHOD_POST,
  HTTP_METHOD_DELETE,
  HTTP_METHOD_PUT,
  HTTP_METHOD_OPTIONS,
  HTTP_METHOD_HEAD,
  HTTP_METHOD_GET = 1,
  HTTP_METHOD_POST,
  HTTP_METHOD_DELETE,
  HTTP_METHOD_PUT,
  HTTP_METHOD_OPTIONS,
  HTTP_METHOD_HEAD
}
 A type of HTTP method. More...
 

Functions

int http_client_close (struct http_client_module *const module)
 Force close HTTP connection. More...
 
int http_client_deinit (struct http_client_module *const module)
 Terminate HTTP client service. More...
 
void http_client_get_config_defaults (struct http_client_config *const config)
 Get default configuration of HTTP client module. More...
 
int http_client_init (struct http_client_module *const module, struct http_client_config *config)
 Initialize HTTP client service. More...
 
int http_client_recv_response (struct http_client_module *const module)
 Force close HTTP connection. More...
 
int http_client_register_callback (struct http_client_module *const module, http_client_callback_t callback)
 Register and enable the callback. More...
 
int http_client_send_request (struct http_client_module *const module, const char *url, enum http_method method, struct http_entity *const entity, const char *ext_header)
 send HTTP request. More...
 
int http_client_unregister_callback (struct http_client_module *const module)
 Unregister callback. More...