+ AppState->PrevState = WEBSERVER_STATE_SendResponseHeader;\r
+ AppState->CurrentState = WEBSERVER_STATE_SendMIMETypeHeader;\r
+ break;\r
+ case WEBSERVER_STATE_SendMIMETypeHeader:\r
+ /* File must have been found and opened for MIME header to be sent */\r
+ if (AppState->FileOpen)\r
+ {\r
+ char* Extension = strpbrk(AppState->FileName, ".");\r
+ \r
+ /* Check to see if a file extension was found for the requested filename */\r
+ if (Extension != NULL)\r
+ {\r
+ /* Look through the MIME type list, copy over the required MIME type if found */\r
+ for (int i = 0; i < (sizeof(MIMETypes) / sizeof(MIMETypes[0])); i++)\r
+ {\r
+ if (strcmp_P(&Extension[1], MIMETypes[i].Extension) == 0)\r
+ {\r
+ AppDataSize = strlen_P(MIMETypes[i].MIMEType);\r
+ strncpy_P(AppData, MIMETypes[i].MIMEType, AppDataSize); \r
+ break;\r
+ }\r
+ } \r
+ }\r
+\r
+ /* Check if a MIME type was found and copied to the output buffer */\r
+ if (!(AppDataSize))\r
+ {\r
+ /* MIME type not found - copy over the default MIME type */\r
+ AppDataSize = strlen_P(DefaultMIMEType);\r
+ strncpy_P(AppData, DefaultMIMEType, AppDataSize); \r
+ }\r
+ \r
+ /* Add the end-of line terminator and end-of-headers terminator after the MIME type */\r
+ strncpy(&AppData[AppDataSize], "\r\n\r\n", sizeof("\r\n\r\n"));\r
+ AppDataSize += (sizeof("\r\n\r\n") - 1);\r
+ }\r
+ \r
+ AppState->PrevState = WEBSERVER_STATE_SendMIMETypeHeader;\r
+ AppState->CurrentState = WEBSERVER_STATE_SendData; \r