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().
Files | |
file | webclient.h |
Header file for the HTTP client. | |
file | webclient.c |
Implementation of the HTTP client. | |
Data Structures | |
struct | webclient_state |
Defines | |
#define | WEBCLIENT_CONF_MAX_URLLEN 100 |
#define | UIP_APPCALL webclient_appcall |
#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 |
Typedefs | |
typedef webclient_state | uip_tcp_appstate_t |
Functions | |
void | webclient_datahandler (char *data, u16_t len) |
Callback function that is called from the webclient code when HTTP data has been received. | |
void | webclient_connected (void) |
Callback function that is called from the webclient code when the HTTP connection has been connected to the web server. | |
void | webclient_timedout (void) |
Callback function that is called from the webclient code if the HTTP connection to the web server has timed out. | |
void | webclient_aborted (void) |
Callback function that is called from the webclient code if the HTTP connection to the web server has been aborted by the web server. | |
void | webclient_closed (void) |
Callback function that is called from the webclient code when the HTTP connection to the web server has been closed. | |
void | webclient_init (void) |
Initialize the webclient module. | |
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. | |
void | webclient_close (void) |
Close the currently open HTTP connection. | |
void | webclient_appcall (void) |
char * | webclient_mimetype (void) |
Obtain the MIME type of the current HTTP data stream. | |
char * | webclient_filename (void) |
Obtain the filename of the current HTTP data stream. | |
char * | webclient_hostname (void) |
Obtain the hostname of the current HTTP data stream. | |
unsigned short | webclient_port (void) |
Obtain the port number of the current HTTP data stream. |
|
Callback function that is called from the webclient code if the HTTP connection to the web server has been aborted by the web server. This function must be implemented by the module that uses the webclient code.
Referenced by webclient_appcall(). |
|
Callback function that is called from the webclient code when the HTTP connection to the web server has been closed. This function must be implemented by the module that uses the webclient code.
Referenced by webclient_appcall(). |
|
Callback function that is called from the webclient code when the HTTP connection has been connected to the web server. This function must be implemented by the module that uses the webclient code.
Referenced by webclient_appcall(). |
|
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.
Referenced by webclient_appcall(). |
|
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.
Definition at line 93 of file webclient.c. References webclient_state::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.
Definition at line 140 of file webclient.c. References webclient_state::file, webclient_state::host, htons(), NULL, webclient_state::port, resolv_lookup(), and uip_connect(). Referenced by webclient_appcall(). |
|
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.
Definition at line 99 of file webclient.c. References webclient_state::host. |
|
Obtain the MIME type of the current HTTP data stream.
Definition at line 87 of file webclient.c. References webclient_state::mimetype. |
|
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.
Definition at line 105 of file webclient.c. References webclient_state::port. |
|
Callback function that is called from the webclient code if the HTTP connection to the web server has timed out. This function must be implemented by the module that uses the webclient code.
Referenced by webclient_appcall(). |