Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

HTTP client

Typedefs

typedef enum ehttpc_result httpc_result_t
 HTTP client result codes.
typedef void(* httpc_result_fn )(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err)
 Prototype of a http client callback function.
typedef err_t(* httpc_headers_done_fn )(httpc_state_t *connection, void *arg, struct pbuf *hdr, u16_t hdr_len, u32_t content_len)
 Prototype of http client callback: called when the headers are received.

Enumerations

enum  ehttpc_result {
  HTTPC_RESULT_OK = 0, HTTPC_RESULT_ERR_UNKNOWN = 1, HTTPC_RESULT_ERR_CONNECT = 2, HTTPC_RESULT_ERR_HOSTNAME = 3,
  HTTPC_RESULT_ERR_CLOSED = 4, HTTPC_RESULT_ERR_TIMEOUT = 5, HTTPC_RESULT_ERR_SVR_RESP = 6, HTTPC_RESULT_ERR_MEM = 7,
  HTTPC_RESULT_LOCAL_ABORT = 8, HTTPC_RESULT_ERR_CONTENT_LEN = 9
}
 

HTTP client result codes.

More...

Functions

err_t httpc_get_file (const ip_addr_t *server_addr, u16_t port, const char *uri, const httpc_connection_t *settings, altcp_recv_fn recv_fn, void *callback_arg, httpc_state_t **connection)
 HTTP client API: get a file by passing server IP address.
err_t httpc_get_file_dns (const char *server_name, u16_t port, const char *uri, const httpc_connection_t *settings, altcp_recv_fn recv_fn, void *callback_arg, httpc_state_t **connection)
 HTTP client API: get a file by passing server name as string (DNS name or IP address string)
err_t httpc_get_file_to_disk (const ip_addr_t *server_addr, u16_t port, const char *uri, const httpc_connection_t *settings, void *callback_arg, const char *local_file_name, httpc_state_t **connection)
 HTTP client API: get a file to disk by passing server IP address.
err_t httpc_get_file_dns_to_disk (const char *server_name, u16_t port, const char *uri, const httpc_connection_t *settings, void *callback_arg, const char *local_file_name, httpc_state_t **connection)
 HTTP client API: get a file to disk by passing server name as string (DNS name or IP address string)

Detailed Description

encode spaces)

  • IPv6 support

Typedef Documentation

typedef err_t(* httpc_headers_done_fn)(httpc_state_t *connection, void *arg, struct pbuf *hdr, u16_t hdr_len, u32_t content_len)

Prototype of http client callback: called when the headers are received.

Parameters:
connectionhttp client connection
argargument specified when initiating the request
hdrheader pbuf(s) (may contain data also)
hdr_lenlength of the heders in 'hdr'
content_lencontent length as received in the headers (-1 if not received)
Returns:
if != ERR_OK is returned, the connection is aborted

Definition at line 123 of file http_client.h.

typedef void(* httpc_result_fn)(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err)

Prototype of a http client callback function.

Parameters:
argargument specified when initiating the request
httpc_resultresult of the http transfer (see enum httpc_result_t)
rx_content_lennumber of bytes received (without headers)
srv_resthis contains the http status code received (if any)
erran error returned by internal lwip functions, can help to specify the source of the error but must not necessarily be != ERR_OK

Definition at line 110 of file http_client.h.

HTTP client result codes.


Enumeration Type Documentation

HTTP client result codes.

Enumerator:
HTTPC_RESULT_OK 

File successfully received.

HTTPC_RESULT_ERR_UNKNOWN 

Unknown error.

HTTPC_RESULT_ERR_CONNECT 

Connection to server failed.

HTTPC_RESULT_ERR_HOSTNAME 

Failed to resolve server hostname.

HTTPC_RESULT_ERR_CLOSED 

Connection unexpectedly closed by remote server.

HTTPC_RESULT_ERR_TIMEOUT 

Connection timed out (server didn't respond in time)

HTTPC_RESULT_ERR_SVR_RESP 

Server responded with an error code.

HTTPC_RESULT_ERR_MEM 

Local memory error.

HTTPC_RESULT_LOCAL_ABORT 

Local abort.

HTTPC_RESULT_ERR_CONTENT_LEN 

Content length mismatch.

Definition at line 74 of file http_client.h.


Function Documentation

err_t httpc_get_file ( const ip_addr_t server_addr,
u16_t  port,
const char *  uri,
const httpc_connection_t *  settings,
altcp_recv_fn  recv_fn,
void *  callback_arg,
httpc_state_t **  connection 
)

HTTP client API: get a file by passing server IP address.

Parameters:
server_addrIP address of the server to connect
porttcp port of the server
uriuri to get from the server, remember leading "/"!
settingsconnection settings (callbacks, proxy, etc.)
recv_fnthe http body (not the headers) are passed to this callback
callback_argargument passed to all the callbacks
connectionretreives the connection handle (to match in callbacks)
Returns:
ERR_OK if starting the request succeeds (callback_fn will be called later) or an error code

Definition at line 632 of file lwip_http_client.c.

err_t httpc_get_file_dns ( const char *  server_name,
u16_t  port,
const char *  uri,
const httpc_connection_t *  settings,
altcp_recv_fn  recv_fn,
void *  callback_arg,
httpc_state_t **  connection 
)

HTTP client API: get a file by passing server name as string (DNS name or IP address string)

Parameters:
server_nameserver name as string (DNS name or IP address string)
porttcp port of the server
uriuri to get from the server, remember leading "/"!
settingsconnection settings (callbacks, proxy, etc.)
recv_fnthe http body (not the headers) are passed to this callback
callback_argargument passed to all the callbacks
connectionretreives the connection handle (to match in callbacks)
Returns:
ERR_OK if starting the request succeeds (callback_fn will be called later) or an error code

Definition at line 677 of file lwip_http_client.c.

err_t httpc_get_file_dns_to_disk ( const char *  server_name,
u16_t  port,
const char *  uri,
const httpc_connection_t *  settings,
void *  callback_arg,
const char *  local_file_name,
httpc_state_t **  connection 
)

HTTP client API: get a file to disk by passing server name as string (DNS name or IP address string)

Parameters:
server_nameserver name as string (DNS name or IP address string)
porttcp port of the server
uriuri to get from the server, remember leading "/"!
settingsconnection settings (callbacks, proxy, etc.)
callback_argargument passed to all the callbacks
connectionretreives the connection handle (to match in callbacks)
Returns:
ERR_OK if starting the request succeeds (callback_fn will be called later) or an error code

Definition at line 870 of file lwip_http_client.c.

err_t httpc_get_file_to_disk ( const ip_addr_t server_addr,
u16_t  port,
const char *  uri,
const httpc_connection_t *  settings,
void *  callback_arg,
const char *  local_file_name,
httpc_state_t **  connection 
)

HTTP client API: get a file to disk by passing server IP address.

Parameters:
server_addrIP address of the server to connect
porttcp port of the server
uriuri to get from the server, remember leading "/"!
settingsconnection settings (callbacks, proxy, etc.)
callback_argargument passed to all the callbacks
connectionretreives the connection handle (to match in callbacks)
Returns:
ERR_OK if starting the request succeeds (callback_fn will be called later) or an error code

Definition at line 818 of file lwip_http_client.c.