Do not test for avr family.
[bertos.git] / bertos / net / http.c
index 7967bb30f34a323f41303126d79174bbaf5d2f24..f994079b0faf324cb4ccedb2e2cb429f6dcedbd7 100644 (file)
@@ -38,6 +38,8 @@
  * the cases where SD is not present or page not found, using embedded pages.
  * Quering from browser the /status page, the server return a json dictionary where are store
  * some board status info, like board temperature, up-time, etc.
+ *
+ * notest: avr
  */
 
 #include "http.h"
@@ -63,17 +65,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);
@@ -85,7 +99,7 @@ static void get_fileName(const char *revc_buf, size_t recv_len, char *name, size
        char *p = strstr(revc_buf, "GET");
        if (p)
        {
-               //Find the end of the page request.
+               /* Find the end of the page request. */
                char *stop = strstr(revc_buf, "HTTP");
                if (!stop)
                {
@@ -94,7 +108,7 @@ static void get_fileName(const char *revc_buf, size_t recv_len, char *name, size
                        return;
                }
 
-               //skip the "/" in get string request
+               /* skip the "/" in get string request */
                p += sizeof("GET") + 1;
 
                while (p != stop)
@@ -109,7 +123,7 @@ static void get_fileName(const char *revc_buf, size_t recv_len, char *name, size
                }
        }
 
-       //Trail white space in the string.
+       /* Trail white space in the string. */
        while ( --i >= 0 )
                if (name[i] != ' ' && name[i] != '\t' && name[i] != '\n')
                        break;
@@ -157,6 +171,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 +222,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);