A simple web server that can be bound to either the EthernetInterface or the WiflyInterface.
Dependents: Smart-WiFly-WebServer WattEye X10Svr SSDP_Server
Diff: SW_HTTPServer.cpp
- Revision:
- 12:109bf1558300
- Parent:
- 11:17d84c41a7b3
- Child:
- 13:8975d7928678
diff -r 17d84c41a7b3 -r 109bf1558300 SW_HTTPServer.cpp --- a/SW_HTTPServer.cpp Sun Aug 04 21:34:44 2013 +0000 +++ b/SW_HTTPServer.cpp Sun Aug 11 15:49:51 2013 +0000 @@ -14,7 +14,7 @@ #include "SW_HTTPServer.h" #include "Utility.h" -//#define DEBUG +#define DEBUG const char * DEFAULT_FILENAME = "index.htm"; @@ -46,7 +46,7 @@ }; #ifdef DEBUG -// This uses standard library dynamic memory management, but for an +// This uses standard library dynamic memory management, but for an // embedded system there are alternates that may make better sense - // search the web for embedded system malloc alternates. static void * MyMalloc(int x, int y) @@ -98,6 +98,7 @@ hostString = NULL; contentLength = NULL; contentType = NULL; + authorization = NULL; postQueryString = NULL; paramcount = 0; handlercount = 0; @@ -555,6 +556,10 @@ myfree(contentType); contentType = NULL; } + if (authorization) { + myfree(authorization); + authorization = NULL; + } if (postQueryString) { myfree(postQueryString); postQueryString = NULL; @@ -586,9 +591,9 @@ *eoRec = '\0'; if (*(eoRec-1) == '\r') *(eoRec-1) = '\0'; - #ifdef DEBUG +#ifdef DEBUG pc->printf("rec {%s}\r\n", soRec); - #endif +#endif // Inspect the supported query types (GET, POST) and ignore (HEAD, PUT, OPTION, DELETE, TRACE, CONNECT] // This is very clumsy if (strstr(soRec, "GET ") == soRec) { @@ -609,14 +614,15 @@ Extract(soRec, "Host: ", &hostString); Extract(soRec, "Content-Length: ", &contentLength); Extract(soRec, "Content-Type: ", &contentType); + Extract(soRec, "Authorization: ", &authorization); soRec = eoRec + 1; eoRec = strchr(soRec, '\n'); } if (queryString) { // We have enough to try to reply - #ifdef DEBUG +#ifdef DEBUG pc->printf("create reply queryType{%s}, queryString{%s}\r\n", "GET", queryString); - #endif +#endif // parse params - if any // /file.htm?name1=value1&name2=value2... // /file.htm?name1&name2=value2... @@ -703,6 +709,7 @@ return advanceState; } + void HTTPServer::GetPerformanceData(SW_PerformanceData * p) { memcpy(p, &perfData, sizeof(perfData));