Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
HTTP client service

This module provides implementation of HTTP client 1.1 for WINC1500 board.

Detailed description of HTTP, please refer to the following documents.
http://tools.ietf.org/html/rfc2616

Revision history 2014/10/07 : Initial draft. (v1.0)

Detailed description of HTTP, please refer to the following documents.
http://tools.ietf.org/html/rfc2616

Revision history 2014/10/07 : Initial draft. (v1.0.0) 2014/12/17 : Add extension header and fix some issues. (v1.0.1) 2015/01/07 : Optimize the WINC driver 18.0 (v1.0.2)

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...
 
struct  http_entity
 A structure that the implementation of HTTP entity. More...
 

Macros

#define HTTP_HEADER_ACCEPT   ("Accept: ")
 
#define HTTP_HEADER_ACCEPT   ("Accept: ")
 
#define HTTP_HEADER_ACCEPT_CHARSET   ("Accept-Charset: ")
 
#define HTTP_HEADER_ACCEPT_CHARSET   ("Accept-Charset: ")
 
#define HTTP_HEADER_ACCEPT_ENCODING   ("Accept-Encoding: ")
 
#define HTTP_HEADER_ACCEPT_ENCODING   ("Accept-Encoding: ")
 
#define HTTP_HEADER_ACCEPT_LANGUAGE   ("Accept-Language: ")
 
#define HTTP_HEADER_ACCEPT_LANGUAGE   ("Accept-Language: ")
 
#define HTTP_HEADER_ACCEPT_RANGES   ("Accept-Ranges: ")
 
#define HTTP_HEADER_ACCEPT_RANGES   ("Accept-Ranges: ")
 
#define HTTP_HEADER_AGE   ("Age: ")
 
#define HTTP_HEADER_AGE   ("Age: ")
 
#define HTTP_HEADER_ALLOW   ("Allow: ")
 
#define HTTP_HEADER_ALLOW   ("Allow: ")
 
#define HTTP_HEADER_AUTHORIZATION   ("Authorization: ")
 
#define HTTP_HEADER_AUTHORIZATION   ("Authorization: ")
 
#define HTTP_HEADER_CACHE_CONTROL   ("Cache-Control: ")
 
#define HTTP_HEADER_CACHE_CONTROL   ("Cache-Control: ")
 
#define HTTP_HEADER_CONNECTION   ("Connection: ")
 
#define HTTP_HEADER_CONNECTION   ("Connection: ")
 
#define HTTP_HEADER_CONTENT_ENCODING   ("Content-Encoding: ")
 
#define HTTP_HEADER_CONTENT_ENCODING   ("Content-Encoding: ")
 
#define HTTP_HEADER_CONTENT_LANGUAGE   ("Content-Language: ")
 
#define HTTP_HEADER_CONTENT_LANGUAGE   ("Content-Language: ")
 
#define HTTP_HEADER_CONTENT_LENGTH   ("Content-Length: ")
 
#define HTTP_HEADER_CONTENT_LENGTH   ("Content-Length: ")
 
#define HTTP_HEADER_CONTENT_LOCATION   ("Content-Location: ")
 
#define HTTP_HEADER_CONTENT_LOCATION   ("Content-Location: ")
 
#define HTTP_HEADER_CONTENT_MD5   ("Content-MD5: ")
 
#define HTTP_HEADER_CONTENT_MD5   ("Content-MD5: ")
 
#define HTTP_HEADER_CONTENT_RANGE   ("Content-Range: ")
 
#define HTTP_HEADER_CONTENT_RANGE   ("Content-Range: ")
 
#define HTTP_HEADER_CONTENT_TYPE   ("Content-Type: ")
 
#define HTTP_HEADER_CONTENT_TYPE   ("Content-Type: ")
 
#define HTTP_HEADER_DATE   ("Date: ")
 
#define HTTP_HEADER_DATE   ("Date: ")
 
#define HTTP_HEADER_ETAG   ("ETag: ")
 
#define HTTP_HEADER_ETAG   ("ETag: ")
 
#define HTTP_HEADER_EXPECT   ("Expect: ")
 
#define HTTP_HEADER_EXPECT   ("Expect: ")
 
#define HTTP_HEADER_EXPIRES   ("Expires: ")
 
#define HTTP_HEADER_EXPIRES   ("Expires: ")
 
#define HTTP_HEADER_FROM   ("From: ")
 
#define HTTP_HEADER_FROM   ("From: ")
 
#define HTTP_HEADER_HOST   ("Host: ")
 
#define HTTP_HEADER_HOST   ("Host: ")
 
#define HTTP_HEADER_IF_MATCH   ("If-Match: ")
 
#define HTTP_HEADER_IF_MATCH   ("If-Match: ")
 
#define HTTP_HEADER_IF_MODIFIED_SINCE   ("If-Modified-Since: ")
 
#define HTTP_HEADER_IF_MODIFIED_SINCE   ("If-Modified-Since: ")
 
#define HTTP_HEADER_IF_NONE_MATCH   ("If-None-Match: ")
 
#define HTTP_HEADER_IF_NONE_MATCH   ("If-None-Match: ")
 
#define HTTP_HEADER_IF_RANGE   ("If-Range: ")
 
#define HTTP_HEADER_IF_RANGE   ("If-Range: ")
 
#define HTTP_HEADER_IF_UNMODIFIED_SINCE   ("If-Unmodified-Since: ")
 
#define HTTP_HEADER_IF_UNMODIFIED_SINCE   ("If-Unmodified-Since: ")
 
#define HTTP_HEADER_LAST_MODIFIED   ("Last-Modified: ")
 
#define HTTP_HEADER_LAST_MODIFIED   ("Last-Modified: ")
 
#define HTTP_HEADER_LOCATION   ("Location: ")
 
#define HTTP_HEADER_LOCATION   ("Location: ")
 
#define HTTP_HEADER_MAX_FORWARDS   ("Max-Forwards: ")
 
#define HTTP_HEADER_MAX_FORWARDS   ("Max-Forwards: ")
 
#define HTTP_HEADER_PRAGMA   ("Pragma: ")
 
#define HTTP_HEADER_PRAGMA   ("Pragma: ")
 
#define HTTP_HEADER_PROXY_AUTHENTICATE   ("Proxy-Authenticate: ")
 
#define HTTP_HEADER_PROXY_AUTHENTICATE   ("Proxy-Authenticate: ")
 
#define HTTP_HEADER_PROXY_AUTHORIZATION   ("Proxy-Authorization: ")
 
#define HTTP_HEADER_PROXY_AUTHORIZATION   ("Proxy-Authorization: ")
 
#define HTTP_HEADER_RANGE   ("Range: ")
 
#define HTTP_HEADER_RANGE   ("Range: ")
 
#define HTTP_HEADER_REFERER   ("Referer: ")
 
#define HTTP_HEADER_REFERER   ("Referer: ")
 
#define HTTP_HEADER_RETRY_AFTER   ("Retry-After: ")
 
#define HTTP_HEADER_RETRY_AFTER   ("Retry-After: ")
 
#define HTTP_HEADER_SERVER   ("Server: ")
 
#define HTTP_HEADER_SERVER   ("Server: ")
 
#define HTTP_HEADER_TE   ("TE: ")
 
#define HTTP_HEADER_TE   ("TE: ")
 
#define HTTP_HEADER_TRAILER   ("Trailer: ")
 
#define HTTP_HEADER_TRAILER   ("Trailer: ")
 
#define HTTP_HEADER_TRANSFER_ENCODING   ("Transfer-Encoding: ")
 
#define HTTP_HEADER_TRANSFER_ENCODING   ("Transfer-Encoding: ")
 
#define HTTP_HEADER_UPGRADE   ("Upgrade: ")
 
#define HTTP_HEADER_UPGRADE   ("Upgrade: ")
 
#define HTTP_HEADER_USER_AGENT   ("User-Agent: ")
 
#define HTTP_HEADER_USER_AGENT   ("User-Agent: ")
 
#define HTTP_HEADER_VARY   ("Vary: ")
 
#define HTTP_HEADER_VARY   ("Vary: ")
 
#define HTTP_HEADER_VIA   ("Via: ")
 
#define HTTP_HEADER_VIA   ("Via: ")
 
#define HTTP_HEADER_WARNING   ("Warning: ")
 
#define HTTP_HEADER_WARNING   ("Warning: ")
 
#define HTTP_HEADER_WWW_AUTHENTICATE   ("WWW-Authenticate: ")
 
#define HTTP_HEADER_WWW_AUTHENTICATE   ("WWW-Authenticate: ")
 
#define HTTP_MAX_URI_LENGTH   64
 Max size of URI. More...
 
#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...
 
#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...
 
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_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...
 
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_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)
 Event handler of gethostbyname. 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...
 

#define HTTP_HEADER_ACCEPT   ("Accept: ")
#define HTTP_HEADER_ACCEPT   ("Accept: ")
#define HTTP_HEADER_ACCEPT_CHARSET   ("Accept-Charset: ")
#define HTTP_HEADER_ACCEPT_CHARSET   ("Accept-Charset: ")
#define HTTP_HEADER_ACCEPT_ENCODING   ("Accept-Encoding: ")
#define HTTP_HEADER_ACCEPT_ENCODING   ("Accept-Encoding: ")
#define HTTP_HEADER_ACCEPT_LANGUAGE   ("Accept-Language: ")
#define HTTP_HEADER_ACCEPT_LANGUAGE   ("Accept-Language: ")
#define HTTP_HEADER_ACCEPT_RANGES   ("Accept-Ranges: ")
#define HTTP_HEADER_ACCEPT_RANGES   ("Accept-Ranges: ")
#define HTTP_HEADER_AGE   ("Age: ")
#define HTTP_HEADER_AGE   ("Age: ")
#define HTTP_HEADER_ALLOW   ("Allow: ")
#define HTTP_HEADER_ALLOW   ("Allow: ")
#define HTTP_HEADER_AUTHORIZATION   ("Authorization: ")
#define HTTP_HEADER_AUTHORIZATION   ("Authorization: ")
#define HTTP_HEADER_CACHE_CONTROL   ("Cache-Control: ")
#define HTTP_HEADER_CACHE_CONTROL   ("Cache-Control: ")
#define HTTP_HEADER_CONNECTION   ("Connection: ")
#define HTTP_HEADER_CONNECTION   ("Connection: ")
#define HTTP_HEADER_CONTENT_ENCODING   ("Content-Encoding: ")
#define HTTP_HEADER_CONTENT_ENCODING   ("Content-Encoding: ")
#define HTTP_HEADER_CONTENT_LANGUAGE   ("Content-Language: ")
#define HTTP_HEADER_CONTENT_LANGUAGE   ("Content-Language: ")
#define HTTP_HEADER_CONTENT_LENGTH   ("Content-Length: ")
#define HTTP_HEADER_CONTENT_LENGTH   ("Content-Length: ")
#define HTTP_HEADER_CONTENT_LOCATION   ("Content-Location: ")
#define HTTP_HEADER_CONTENT_LOCATION   ("Content-Location: ")
#define HTTP_HEADER_CONTENT_MD5   ("Content-MD5: ")
#define HTTP_HEADER_CONTENT_MD5   ("Content-MD5: ")
#define HTTP_HEADER_CONTENT_RANGE   ("Content-Range: ")
#define HTTP_HEADER_CONTENT_RANGE   ("Content-Range: ")
#define HTTP_HEADER_CONTENT_TYPE   ("Content-Type: ")
#define HTTP_HEADER_CONTENT_TYPE   ("Content-Type: ")
#define HTTP_HEADER_DATE   ("Date: ")
#define HTTP_HEADER_DATE   ("Date: ")
#define HTTP_HEADER_ETAG   ("ETag: ")
#define HTTP_HEADER_ETAG   ("ETag: ")
#define HTTP_HEADER_EXPECT   ("Expect: ")
#define HTTP_HEADER_EXPECT   ("Expect: ")
#define HTTP_HEADER_EXPIRES   ("Expires: ")
#define HTTP_HEADER_EXPIRES   ("Expires: ")
#define HTTP_HEADER_FROM   ("From: ")
#define HTTP_HEADER_FROM   ("From: ")
#define HTTP_HEADER_HOST   ("Host: ")
#define HTTP_HEADER_HOST   ("Host: ")
#define HTTP_HEADER_IF_MATCH   ("If-Match: ")
#define HTTP_HEADER_IF_MATCH   ("If-Match: ")
#define HTTP_HEADER_IF_MODIFIED_SINCE   ("If-Modified-Since: ")
#define HTTP_HEADER_IF_MODIFIED_SINCE   ("If-Modified-Since: ")
#define HTTP_HEADER_IF_NONE_MATCH   ("If-None-Match: ")
#define HTTP_HEADER_IF_NONE_MATCH   ("If-None-Match: ")
#define HTTP_HEADER_IF_RANGE   ("If-Range: ")
#define HTTP_HEADER_IF_RANGE   ("If-Range: ")
#define HTTP_HEADER_IF_UNMODIFIED_SINCE   ("If-Unmodified-Since: ")
#define HTTP_HEADER_IF_UNMODIFIED_SINCE   ("If-Unmodified-Since: ")
#define HTTP_HEADER_LAST_MODIFIED   ("Last-Modified: ")
#define HTTP_HEADER_LAST_MODIFIED   ("Last-Modified: ")
#define HTTP_HEADER_LOCATION   ("Location: ")
#define HTTP_HEADER_LOCATION   ("Location: ")
#define HTTP_HEADER_MAX_FORWARDS   ("Max-Forwards: ")
#define HTTP_HEADER_MAX_FORWARDS   ("Max-Forwards: ")
#define HTTP_HEADER_PRAGMA   ("Pragma: ")
#define HTTP_HEADER_PRAGMA   ("Pragma: ")
#define HTTP_HEADER_PROXY_AUTHENTICATE   ("Proxy-Authenticate: ")
#define HTTP_HEADER_PROXY_AUTHENTICATE   ("Proxy-Authenticate: ")
#define HTTP_HEADER_PROXY_AUTHORIZATION   ("Proxy-Authorization: ")
#define HTTP_HEADER_PROXY_AUTHORIZATION   ("Proxy-Authorization: ")
#define HTTP_HEADER_RANGE   ("Range: ")
#define HTTP_HEADER_RANGE   ("Range: ")
#define HTTP_HEADER_REFERER   ("Referer: ")
#define HTTP_HEADER_REFERER   ("Referer: ")
#define HTTP_HEADER_RETRY_AFTER   ("Retry-After: ")
#define HTTP_HEADER_RETRY_AFTER   ("Retry-After: ")
#define HTTP_HEADER_SERVER   ("Server: ")
#define HTTP_HEADER_SERVER   ("Server: ")
#define HTTP_HEADER_TE   ("TE: ")
#define HTTP_HEADER_TE   ("TE: ")
#define HTTP_HEADER_TRAILER   ("Trailer: ")
#define HTTP_HEADER_TRAILER   ("Trailer: ")
#define HTTP_HEADER_TRANSFER_ENCODING   ("Transfer-Encoding: ")
#define HTTP_HEADER_TRANSFER_ENCODING   ("Transfer-Encoding: ")
#define HTTP_HEADER_UPGRADE   ("Upgrade: ")
#define HTTP_HEADER_UPGRADE   ("Upgrade: ")
#define HTTP_HEADER_USER_AGENT   ("User-Agent: ")
#define HTTP_HEADER_USER_AGENT   ("User-Agent: ")
#define HTTP_HEADER_VARY   ("Vary: ")
#define HTTP_HEADER_VARY   ("Vary: ")
#define HTTP_HEADER_VIA   ("Via: ")
#define HTTP_HEADER_VIA   ("Via: ")
#define HTTP_HEADER_WARNING   ("Warning: ")
#define HTTP_HEADER_WARNING   ("Warning: ")
#define HTTP_HEADER_WWW_AUTHENTICATE   ("WWW-Authenticate: ")
#define HTTP_HEADER_WWW_AUTHENTICATE   ("WWW-Authenticate: ")
#define HTTP_MAX_URI_LENGTH   64

Max size of URI.

Referenced by http_client_send_request().

#define HTTP_MAX_URI_LENGTH   64

Max size of URI.

#define HTTP_PROTO_NAME   "HTTP/1.1"

Protocol version string of HTTP client.

Referenced by _http_client_request().

#define HTTP_PROTO_NAME   "HTTP/1.1"

Protocol version string of HTTP client.

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.

Parameters
[in]module_instModule instance of HTTP client module.
[in]typeType of event.
[in]dataData structure of the event. http_client_data
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.

Parameters
[in]module_instModule instance of HTTP client module.
[in]typeType of event.
[in]dataData structure of the event. http_client_data

A type of HTTP client callback.

Enumerator
HTTP_CLIENT_CALLBACK_SOCK_CONNECTED 

Socket was connected.

After received this event, try send request message to the server.

HTTP_CLIENT_CALLBACK_REQUESTED 

The request operation is completed.

HTTP_CLIENT_CALLBACK_RECV_RESPONSE 

Received HTTP response message.

HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA 

Received Chunked data.

HTTP_CLIENT_CALLBACK_DISCONNECTED 

The session was closed.

HTTP_CLIENT_CALLBACK_SOCK_CONNECTED 

Socket was connected.

After received this event, try send request message to the server.

HTTP_CLIENT_CALLBACK_REQUESTED 

The request operation is completed.

HTTP_CLIENT_CALLBACK_RECV_RESPONSE 

Received HTTP response message.

HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA 

Received Chunked data.

HTTP_CLIENT_CALLBACK_RECV_NO_CONTENT_LENGTH_DATA 

Received data without content length header.

HTTP_CLIENT_CALLBACK_DISCONNECTED 

The session was closed.

A type of HTTP client callback.

Enumerator
HTTP_CLIENT_CALLBACK_SOCK_CONNECTED 

Socket was connected.

After received this event, try send request message to the server.

HTTP_CLIENT_CALLBACK_REQUESTED 

The request operation is completed.

HTTP_CLIENT_CALLBACK_RECV_RESPONSE 

Received HTTP response message.

HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA 

Received Chunked data.

HTTP_CLIENT_CALLBACK_DISCONNECTED 

The session was closed.

HTTP_CLIENT_CALLBACK_SOCK_CONNECTED 

Socket was connected.

After received this event, try send request message to the server.

HTTP_CLIENT_CALLBACK_REQUESTED 

The request operation is completed.

HTTP_CLIENT_CALLBACK_RECV_RESPONSE 

Received HTTP response message.

HTTP_CLIENT_CALLBACK_RECV_CHUNKED_DATA 

Received Chunked data.

HTTP_CLIENT_CALLBACK_RECV_NO_CONTENT_LENGTH_DATA 

Received data without content length header.

HTTP_CLIENT_CALLBACK_DISCONNECTED 

The session was closed.

A type of HTTP method.

Enumerator
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_DELETE 
HTTP_METHOD_PUT 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_HEAD 
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_DELETE 
HTTP_METHOD_PUT 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_HEAD 

A type of HTTP method.

Enumerator
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_DELETE 
HTTP_METHOD_PUT 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_HEAD 
HTTP_METHOD_GET 
HTTP_METHOD_POST 
HTTP_METHOD_DELETE 
HTTP_METHOD_PUT 
HTTP_METHOD_OPTIONS 
HTTP_METHOD_HEAD 

int http_client_close ( struct http_client_module *const  module)

Force close HTTP connection.

Parameters
[in]module_instInstance of HTTP client module.
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.
-ENOTSUP Unsupported operation.

References _http_client_clear_conn(), NULL, http_client_module::req, http_client_req::state, and STATE_SOCK_CONNECTED.

int http_client_deinit ( struct http_client_module *const  module)

Terminate HTTP client service.

Parameters
[in]moduleModule instance of HTTP client.
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.
-ENOTSUP Unsupported operation.

References http_client_module::alloc_buffer, http_client_module::config, http_client_req::ext_header, NULL, http_client_config::recv_buffer, and http_client_module::req.

void http_client_get_config_defaults ( struct http_client_config *const  config)
int http_client_init ( struct http_client_module *const  module,
struct http_client_config config 
)

Initialize HTTP client service.

Parameters
[in]moduleModule instance of HTTP client module.
[in]configPointer of configuration structure which will be used in the module.
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.

References http_client_module::alloc_buffer, http_client_module::config, http_client_timer_callback(), MIN_SEND_BUFFER_SIZE, NULL, http_client_config::recv_buffer, http_client_config::recv_buffer_size, http_client_module::req, http_client_module::resp, http_client_config::send_buffer_size, http_client_req::state, http_client_resp::state, STATE_INIT, STATE_PARSE_HEADER, sw_timer_register_callback(), http_client_config::timeout, http_client_module::timer_id, and http_client_config::timer_inst.

Referenced by configure_http_client().

int http_client_register_callback ( struct http_client_module *const  module,
http_client_callback_t  callback 
)

Register and enable the callback.

Parameters
[in]module_instInstance of HTTP client module.
[in]callbackCallback entry for the HTTP client module.
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.
-ENOTSUP Unsupported operation.

References callback, http_client_module::cb, and NULL.

Referenced by configure_http_client().

int http_client_send_request ( struct http_client_module *const  module,
const char *  url,
enum http_method  method,
struct http_entity *const  entity 
)

Event handler of gethostbyname.

Parameters
[in]module_instInstance of HTTP client module.
[in]urlURL of request.
[in]methodMethod of request.
[in]entityEntity of request. Entity is consist of Entity header and Entity body Please refer to http_entity.
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.
-ENOTSUP Unsupported operation.

Referenced by http_client_callback(), start_download(), and wifi_callback().

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.

Parameters
[in]module_instInstance of HTTP client module.
[in]urlURL of request.
[in]methodMethod of request.
[in]entityEntity of request. Entity is consist of Entity header and Entity body Please refer to http_entity.
[in]ext_headerExtension header of the request.It must ends with new line character(
).
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.
-ENOTSUP Unsupported operation.

References _htons, _http_client_clear_conn(), _http_client_request(), _is_ip(), AF_INET, http_client_module::config, connect(), http_client_req::entity, http_client_req::ext_header, flag, gethostbyname(), http_client_module::host, HTTP_MAX_URI_LENGTH, i, j, http_client_req::method, nmi_inet_addr(), NULL, http_client_config::port, http_client_module::recved_size, http_client_module::req, in_addr::s_addr, http_client_module::sending, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, http_client_module::sock, SOCK_STREAM, socket(), SOCKET_FLAGS_SSL, http_client_req::state, STATE_INIT, STATE_REQ_SEND_HEADER, STATE_SOCK_CONNECTED, STATE_TRY_SOCK_CONNECT, http_client_config::tls, and http_client_req::uri.

void http_client_socket_resolve_handler ( uint8_t *  doamin_name,
uint32_t  server_ip 
)
int http_client_unregister_callback ( struct http_client_module *const  module)

Unregister callback.

Parameters
[in]module_instInstance of HTTP client module.
Returns
0 Function succeeded
-ENOENT No such address.
-EINVAL Invalid argument.
-ENOSPC No space left on device.
-EIO Device was occurred error due to unknown exception.
-EDESTADDRREQ Destination address required.
-ECONNRESET Connection reset by peer.
-EAGAIN Try again.
-EBUSY Device or resource busy.
-EADDRINUSE Address already in use.
-EALREADY Socket already connected.
-ENOTCONN Service in bad state.
-ECONNREFUSED Connection refused.
-EOVERFLOW Value too large for defined data type.
-EBADMSG Not a data message.
-ENOMEM Out of memory.
-ENOTSUP Unsupported operation.

References http_client_module::cb, and NULL.