summaryrefslogtreecommitdiff
path: root/bsp/stm32f103vb_lwip/httpserver-netconn.c
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2009-10-02 09:28:38 +0000
committerbernard.xiong <[email protected]>2009-10-02 09:28:38 +0000
commite3248a5045bd59b32c0b97a05c771928316f3aff (patch)
tree1e8b4eee32ac47912e201b3c40e6fa8515b4827f /bsp/stm32f103vb_lwip/httpserver-netconn.c
parent942ca4da6388e1ceab6ebdd225dbb3013ec6dffa (diff)
remove stm32f103vb branch
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@68 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp/stm32f103vb_lwip/httpserver-netconn.c')
-rw-r--r--bsp/stm32f103vb_lwip/httpserver-netconn.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/bsp/stm32f103vb_lwip/httpserver-netconn.c b/bsp/stm32f103vb_lwip/httpserver-netconn.c
deleted file mode 100644
index 3583268c45..0000000000
--- a/bsp/stm32f103vb_lwip/httpserver-netconn.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "lwip/opt.h"
-#include "lwip/arch.h"
-#include "lwip/api.h"
-
-const static char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n";
-const static char http_index_html[] = "<html><head><title>Congrats!</title></head><body><h1>Welcome to our lwIP HTTP server!</h1><p>This is a small test page.</body></html>";
-
-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 (netconn_err(conn) == 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);
- }
- }
- /* 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);
-}
-
-void http_server(void* parameter) {
- struct netconn *conn, *newconn;
-
- /* Create a new TCP connection handle */
- conn = netconn_new(NETCONN_TCP);
- LWIP_ERROR("http_server: invalid conn", (conn != NULL), );
-
- /* 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);
- }
-}
-
-void httpd_init()
-{
- rt_thread_t httpd = rt_thread_create("web",
- http_server, RT_NULL,
- 1024, 20, 8);
-
- if (httpd != RT_NULL)
- rt_thread_startup(httpd);
-}