From aacb973e83942c7e5852e1d4329140e2ee26ca0a Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 1 Oct 2007 19:09:28 +0000 Subject: [PATCH] Converted tabs to spaces; fixed indentation --- apps/httpserver/httpserver-netconn.c | 102 +++++++++++++-------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/apps/httpserver/httpserver-netconn.c b/apps/httpserver/httpserver-netconn.c index 88b0faf..7e9b357 100644 --- a/apps/httpserver/httpserver-netconn.c +++ b/apps/httpserver/httpserver-netconn.c @@ -2,61 +2,61 @@ const static char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\ const static char http_index_html[] = "Congrats!

Welcome to our lwIP HTTP server!

This is a small test page."; void http_server_serve(struct netconn *conn) { - struct netbuf *inbuf; - char *buf; - u16_t buflen; - - /* Read the data from the port, blocking if nothing yet there. - We assume the request (the part we care about) is in one netbuf */ - inbuf = netconn_recv(conn); - - if (conn->err == ERR_OK) { - netbuf_data(inbuf, &buf, &buflen); - - /* Is this an HTTP GET command? (only check the first 5 chars, since - there are other formats for GET, and we're keeping it very simple )*/ - if (buflen>=5 && - buf[0]=='G' && - buf[1]=='E' && - buf[2]=='T' && - buf[3]==' ' && - buf[4]=='/' ) { - - /* Send the HTML header + struct netbuf *inbuf; + char *buf; + u16_t buflen; + + /* Read the data from the port, blocking if nothing yet there. + We assume the request (the part we care about) is in one netbuf */ + inbuf = netconn_recv(conn); + + if (conn->err == ERR_OK) { + netbuf_data(inbuf, &buf, &buflen); + + /* Is this an HTTP GET command? (only check the first 5 chars, since + there are other formats for GET, and we're keeping it very simple )*/ + if (buflen>=5 && + buf[0]=='G' && + buf[1]=='E' && + buf[2]=='T' && + buf[3]==' ' && + buf[4]=='/' ) { + + /* Send the HTML header * subtract 1 from the size, since we dont send the \0 in the string * NETCONN_NOCOPY: our data is const static, so no need to copy it - */ - netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY); - - /* Send our HTML page */ - netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY); - } + */ + netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY); + + /* Send our HTML page */ + netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY); } - /* Close the connection (server closes in HTTP) */ - netconn_close(conn); - - /* Delete the buffer (netconn_recv gives us ownership, - so we have to make sure to deallocate the buffer) */ - netbuf_delete(inbuf); + } + /* Close the connection (server closes in HTTP) */ + netconn_close(conn); + + /* Delete the buffer (netconn_recv gives us ownership, + so we have to make sure to deallocate the buffer) */ + netbuf_delete(inbuf); } int http_server() { - struct netconn *conn, *newconn; - - /* Create a new TCP connection handle */ - conn = netconn_new(NETCONN_TCP); - LWIP_ERROR("http_server: invalid conn", (conn != NULL), return -1;); - - /* Bind to port 80 (HTTP) with default IP address */ - netconn_bind(conn, NULL, 80); - - /* Put the connection into LISTEN state */ - netconn_listen(conn); - - while(1) { - newconn = netconn_accept(conn); - http_server_serve(newconn); - netconn_delete(newconn); - } - return 0; + struct netconn *conn, *newconn; + + /* Create a new TCP connection handle */ + conn = netconn_new(NETCONN_TCP); + LWIP_ERROR("http_server: invalid conn", (conn != NULL), return -1;); + + /* Bind to port 80 (HTTP) with default IP address */ + netconn_bind(conn, NULL, 80); + + /* Put the connection into LISTEN state */ + netconn_listen(conn); + + while(1) { + newconn = netconn_accept(conn); + http_server_serve(newconn); + netconn_delete(newconn); + } + return 0; }