From ed5ab8253db569e0ed85a35cc9beff02a2d204bc Mon Sep 17 00:00:00 2001 From: asterix Date: Fri, 30 Sep 2011 16:26:09 +0000 Subject: [PATCH] Add comments. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5128 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/net/http.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/bertos/net/http.c b/bertos/net/http.c index 7967bb30..1121362d 100644 --- a/bertos/net/http.c +++ b/bertos/net/http.c @@ -63,17 +63,29 @@ static const char http_html_hdr_500[] = "HTTP/1.1 500 Internal Server Error\r\nC static HttpCGI *cgi_table; static http_handler_t http_callback; - +/** + * Send on \param client socket + * the 200 Ok http header + */ void http_sendOk(struct netconn *client) { netconn_write(client, http_html_hdr_200, sizeof(http_html_hdr_200) - 1, NETCONN_NOCOPY); } + +/** + * Send on \param client socket + * the 404 File not found http header + */ void http_sendFileNotFound(struct netconn *client) { netconn_write(client, http_html_hdr_404, sizeof(http_html_hdr_404) - 1, NETCONN_NOCOPY); } +/** + * Send on \param client socket + * the 500 internal server error http header + */ void http_sendInternalErr(struct netconn *client) { netconn_write(client, http_html_hdr_500, sizeof(http_html_hdr_500) - 1, NETCONN_NOCOPY); @@ -157,6 +169,12 @@ static http_handler_t cgi_search(const char *name, HttpCGI *table) static char req_string[80]; +/** + * Http polling function. + * + * Call this functions to process each client connections. + * + */ void http_poll(struct netconn *server) { struct netconn *client; @@ -202,6 +220,18 @@ void http_poll(struct netconn *server) netconn_delete(client); } +/** + * Init the http server. + * + * The simply http server call for each client request the default_callback function. The + * user should define this callback to manage the client request, i.e. reading site's page + * from SD card. The user can define the cgi_table, where associate one callback to the user string. + * In this way the user could filter some client request and redirect they to custom callback, i.e. + * the client could request status of the device only loading the particular page name. + * + * \param default_callback fuction that server call for all request, that does'nt match cgi table. + * \param table of callcack to call when client request a particular page. + */ void http_init(http_handler_t default_callback, struct HttpCGI *table) { ASSERT(default_callback); -- 2.25.1