![]() |
Data Structures | |
struct | uip_tcp_appstate_t |
Files | |
file | webclient.c |
file | webclient.h |
Defines | |
#define | WEBCLIENT_TIMEOUT 100 |
#define | WEBCLIENT_STATE_STATUSLINE 0 |
#define | WEBCLIENT_STATE_HEADERS 1 |
#define | WEBCLIENT_STATE_DATA 2 |
#define | WEBCLIENT_STATE_CLOSE 3 |
#define | HTTPFLAG_NONE 0 |
#define | HTTPFLAG_OK 1 |
#define | HTTPFLAG_MOVED 2 |
#define | HTTPFLAG_ERROR 3 |
#define | ISO_nl 0x0a |
#define | ISO_cr 0x0d |
#define | ISO_space 0x20 |
#define | WEBCLIENT_CONF_MAX_URLLEN 100 |
#define | UIP_APPCALL webclient_appcall |
Functions | |
char * | webclient_mimetype (void) |
char * | webclient_filename (void) |
char * | webclient_hostname (void) |
unsigned short | webclient_port (void) |
void | webclient_init (void) |
void | webclient_close (void) |
unsigned char | webclient_get (char *host, u16_t port, char *file) |
void | webclient_appcall (void) |
void | webclient_datahandler (char *data, u16_t len) |
void | webclient_connected (void) |
void | webclient_timedout (void) |
void | webclient_aborted (void) |
void | webclient_closed (void) |
This example shows a HTTP client that is able to download web pages and files from web servers. It requires a number of callback functions to be implemented by the module that utilizes the code: webclient_datahandler(), webclient_connected(), webclient_timedout(), webclient_aborted(), webclient_closed().
void webclient_aborted | ( | void | ) |
void webclient_close | ( | void | ) |
Close the currently open HTTP connection.
void webclient_closed | ( | void | ) |
void webclient_connected | ( | void | ) |
void webclient_datahandler | ( | char * | data, | |
u16_t | len | |||
) |
Callback function that is called from the webclient code when HTTP data has been received.
This function must be implemented by the module that uses the webclient code. The function is called from the webclient module when HTTP data has been received. The function is not called when HTTP headers are received, only for the actual data.
data | A pointer to the data that has been received. | |
len | The length of the data that has been received. |
char * webclient_filename | ( | void | ) |
Obtain the filename of the current HTTP data stream.
The filename of an HTTP request may be changed by the web server, and may therefore not be the same as when the original GET request was made with webclient_get(). This function is used for obtaining the current filename.
unsigned char webclient_get | ( | char * | host, | |
u16_t | port, | |||
char * | file | |||
) |
Open an HTTP connection to a web server and ask for a file using the GET method.
This function opens an HTTP connection to the specified web server and requests the specified file using the GET method. When the HTTP connection has been connected, the webclient_connected() callback function is called and when the HTTP data arrives the webclient_datahandler() callback function is called.
The callback function webclient_timedout() is called if the web server could not be contacted, and the webclient_aborted() callback function is called if the HTTP connection is aborted by the web server.
When the HTTP request has been completed and the HTTP connection is closed, the webclient_closed() callback function will be called.
host | A pointer to a string containing either a host name or a numerical IP address in dotted decimal notation (e.g., 192.168.23.1). | |
port | The port number to which to connect, in host byte order. | |
file | A pointer to the name of the file to get. |
0 | if the host name could not be found in the cache, or if a TCP connection could not be created. | |
1 | if the connection was initiated. |
char * webclient_hostname | ( | void | ) |
Obtain the hostname of the current HTTP data stream.
The hostname of the web server of an HTTP request may be changed by the web server, and may therefore not be the same as when the original GET request was made with webclient_get(). This function is used for obtaining the current hostname.
void webclient_init | ( | void | ) |
Initialize the webclient module.
char * webclient_mimetype | ( | void | ) |
Obtain the MIME type of the current HTTP data stream.
unsigned short webclient_port | ( | void | ) |
Obtain the port number of the current HTTP data stream.
The port number of an HTTP request may be changed by the web server, and may therefore not be the same as when the original GET request was made with webclient_get(). This function is used for obtaining the current port number.