/** Default MIME type sent if no other MIME type can be determined */\r
char PROGMEM DefaultMIMEType[] = "text/plain";\r
\r
/** Default MIME type sent if no other MIME type can be determined */\r
char PROGMEM DefaultMIMEType[] = "text/plain";\r
\r
MIME_Type_t PROGMEM MIMETypes[] =\r
{\r
{.Extension = "htm", .MIMEType = "text/html"},\r
MIME_Type_t PROGMEM MIMETypes[] =\r
{\r
{.Extension = "htm", .MIMEType = "text/html"},\r
{.Extension = "gif", .MIMEType = "image/gif"},\r
{.Extension = "bmp", .MIMEType = "image/bmp"},\r
{.Extension = "png", .MIMEType = "image/png"},\r
{.Extension = "gif", .MIMEType = "image/gif"},\r
{.Extension = "bmp", .MIMEType = "image/bmp"},\r
{.Extension = "png", .MIMEType = "image/png"},\r
{.Extension = "exe", .MIMEType = "application/octet-stream"},\r
{.Extension = "gz", .MIMEType = "application/x-gzip"},\r
{.Extension = "exe", .MIMEType = "application/octet-stream"},\r
{.Extension = "gz", .MIMEType = "application/x-gzip"},\r
{.Extension = "zip", .MIMEType = "application/zip"},\r
{.Extension = "pdf", .MIMEType = "application/pdf"},\r
};\r
{.Extension = "zip", .MIMEType = "application/zip"},\r
{.Extension = "pdf", .MIMEType = "application/pdf"},\r
};\r
/** uIP stack application callback for the simple HTTP webserver. This function must be called each time the\r
* TCP/IP stack needs a TCP packet to be processed.\r
*/\r
/** uIP stack application callback for the simple HTTP webserver. This function must be called each time the\r
* TCP/IP stack needs a TCP packet to be processed.\r
*/\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
\r
if (uip_aborted() || uip_timedout() || uip_closed())\r
{\r
/* Connection is being terminated for some reason - close file handle */\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
\r
if (uip_aborted() || uip_timedout() || uip_closed())\r
{\r
/* Connection is being terminated for some reason - close file handle */\r
- AppState->CurrentState = WEBSERVER_STATE_Closed;\r
- AppState->NextState = WEBSERVER_STATE_Closed;\r
+ AppState->HTTPServer.CurrentState = WEBSERVER_STATE_Closed;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_Closed;\r
- AppState->CurrentState = WEBSERVER_STATE_OpenRequestedFile;\r
- AppState->NextState = WEBSERVER_STATE_OpenRequestedFile;\r
- AppState->FileOpen = false;\r
- AppState->ACKedFilePos = 0;\r
- AppState->SentChunkSize = 0;\r
+ AppState->HTTPServer.CurrentState = WEBSERVER_STATE_OpenRequestedFile;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_OpenRequestedFile;\r
+ AppState->HTTPServer.FileOpen = false;\r
+ AppState->HTTPServer.ACKedFilePos = 0;\r
+ AppState->HTTPServer.SentChunkSize = 0;\r
/** HTTP Server State handler for the Request Process state. This state manages the processing of incomming HTTP\r
* GET requests to the server from the receiving HTTP client.\r
*/\r
/** HTTP Server State handler for the Request Process state. This state manages the processing of incomming HTTP\r
* GET requests to the server from the receiving HTTP client.\r
*/\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
/* If the requested filename has more that just the leading '/' path in it, copy it over */\r
if (strlen(RequestedFileName) > 1)\r
\r
/* If the requested filename has more that just the leading '/' path in it, copy it over */\r
if (strlen(RequestedFileName) > 1)\r
- strncpy(AppState->FileName, &RequestedFileName[1], (sizeof(AppState->FileName) - 1));\r
+ strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], (sizeof(AppState->HTTPServer.FileName) - 1));\r
- AppState->FileOpen = (f_open(&AppState->FileHandle, AppState->FileName, FA_OPEN_EXISTING | FA_READ) == FR_OK);\r
+ AppState->HTTPServer.FileOpen = (f_open(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.FileName, FA_OPEN_EXISTING | FA_READ) == FR_OK);\r
- AppState->CurrentState = WEBSERVER_STATE_SendResponseHeader;\r
- AppState->NextState = WEBSERVER_STATE_SendResponseHeader;\r
+ AppState->HTTPServer.CurrentState = WEBSERVER_STATE_SendResponseHeader;\r
+ AppState->HTTPServer.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
}\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
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
- HeaderLength = strlen_P(HeaderToSend);\r
- strncpy_P(AppData, HeaderToSend, HeaderLength);\r
- uip_send(AppData, HeaderLength);\r
+ strcpy_P(AppData, HeaderToSend);\r
+ uip_send(AppData, strlen(AppData));\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
}\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
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
uint16_t MIMEHeaderLength = 0;\r
\r
/* Check to see if a file extension was found for the requested filename */\r
uint16_t MIMEHeaderLength = 0;\r
\r
/* Check to see if a file extension was found for the requested filename */\r
uip_send(AppData, MIMEHeaderLength);\r
\r
/* When the MIME header is ACKed, progress to the data send stage */\r
uip_send(AppData, MIMEHeaderLength);\r
\r
/* When the MIME header is ACKed, progress to the data send stage */\r
}\r
\r
/** HTTP Server State handler for the Data Send state. This state manages the transmission of file chunks\r
* to the receiving HTTP client.\r
*/\r
}\r
\r
/** HTTP Server State handler for the Data Send state. This state manages the transmission of file chunks\r
* to the receiving HTTP client.\r
*/\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
{\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
- f_read(&AppState->FileHandle, AppData, MaxSegmentSize, &AppState->SentChunkSize);\r
+ f_read(&AppState->HTTPServer.FileHandle, AppData, MaxSegmentSize, &AppState->HTTPServer.SentChunkSize);\r