+ /* Ensure filename is null-terminated */\r
+ AppState->FileName[(sizeof(AppState->FileName) - 1)] = 0x00;\r
+ \r
+ /* Try to open the file from the Dataflash disk */\r
+ AppState->FileOpen = (f_open(&AppState->FileHandle, AppState->FileName, FA_OPEN_EXISTING | FA_READ) == FR_OK);\r
+\r
+ /* Lock to the SendResponseHeader state until connection terminated */\r
+ AppState->CurrentState = WEBSERVER_STATE_SendResponseHeader;\r
+ AppState->NextState = WEBSERVER_STATE_SendResponseHeader;\r
+}\r
+\r
+/** HTTP Server State handler for the HTTP Response Header Send state. This state manages the transmission of\r
+ * the HTTP response header to the receiving HTTP client.\r
+ */\r
+static void Webserver_SendResponseHeader(void)\r
+{\r
+ uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
+ char* const AppData = (char*)uip_appdata;\r
+\r
+ char* HeaderToSend;\r
+ uint16_t HeaderLength;\r
+\r
+ /* Determine which HTTP header should be sent to the client */\r
+ if (AppState->FileOpen)\r
+ {\r
+ HeaderToSend = HTTP200Header;\r
+ AppState->NextState = WEBSERVER_STATE_SendMIMETypeHeader;\r
+ }\r
+ else\r
+ {\r
+ HeaderToSend = HTTP404Header;\r
+ AppState->NextState = WEBSERVER_STATE_Closing;\r
+ }\r
+\r
+ /* Copy over the HTTP response header and send it to the receiving client */\r
+ HeaderLength = strlen_P(HeaderToSend);\r
+ strncpy_P(AppData, HeaderToSend, HeaderLength);\r
+ uip_send(AppData, HeaderLength);\r
+}\r
+\r
+/** HTTP Server State handler for the MIME Header Send state. This state manages the transmission of the file\r
+ * MIME type header for the requested file to the receiving HTTP client.\r
+ */\r
+static void Webserver_SendMIMETypeHeader(void)\r
+{\r
+ uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
+ char* const AppData = (char*)uip_appdata;\r