Microchip® Advanced Software Framework

http_client.h File Reference

HTTP client service.

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

#include "socket/include/socket.h"
#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 HTTP_MAX_URI_LENGTH   64
 Max size of URI. More...
 
#define HTTP_PROTO_NAME   "HTTP/1.1"
 Protocol version string of HTTP client. More...
 

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_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
}
 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_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)
 Event handler of gethostbyname. More...
 
void http_client_socket_event_handler (SOCKET sock, uint8_t msg_type, void *msg_data)
 Event handler of socket event. More...
 
void http_client_socket_resolve_handler (uint8_t *doamin_name, uint32_t server_ip)
 Event handler of gethostbyname. More...
 
int http_client_unregister_callback (struct http_client_module *const module)
 Unregister callback. More...