Move DHCP negotiation timer into the DHCP connection application state structure...
[pub/USBasp.git] / Projects / Webserver / Lib / HTTPServerApp.c
index 9a70dad..e781beb 100644 (file)
 /** HTTP server response header, for transmission before the page contents. This indicates to the host that a page exists at the\r
  *  given location, and gives extra connection information.\r
  */\r
-char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
-                               "Server: LUFA RNDIS\r\n"\r
-                               "Connection: close\r\n"\r
-                               "MIME-version: 1.0\r\n"\r
-                               "Content-Type: ";\r
+const char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
+                                     "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
+                                     "Connection: close\r\n"\r
+                                     "MIME-version: 1.0\r\n"\r
+                                     "Content-Type: ";\r
 \r
 /** HTTP server response header, for transmission before a resource not found error. This indicates to the host that the given\r
  *  given URL is invalid, and gives extra error information.\r
  */\r
-char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"\r
-                               "Server: LUFA RNDIS\r\n"\r
-                               "Connection: close\r\n"\r
-                               "MIME-version: 1.0\r\n"\r
-                               "Content-Type: text/plain\r\n\r\n"\r
-                               "Error 404: File Not Found";\r
+const char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"\r
+                                     "Server: LUFA " LUFA_VERSION_STRING "\r\n"\r
+                                     "Connection: close\r\n"\r
+                                     "MIME-version: 1.0\r\n"\r
+                                     "Content-Type: text/plain\r\n\r\n"\r
+                                     "Error 404: File Not Found";\r
 \r
-/** Default MIME type sent if no other MIME type can be determined */\r
-char PROGMEM DefaultMIMEType[] = "text/plain";\r
+/** Default MIME type sent if no other MIME type can be determined. */\r
+const char PROGMEM DefaultMIMEType[] = "text/plain";\r
 \r
 /** List of MIME types for each supported file extension. */\r
-MIME_Type_t PROGMEM MIMETypes[] =\r
+const MIME_Type_t MIMETypes[] =\r
        {\r
                {.Extension = "htm", .MIMEType = "text/html"},\r
                {.Extension = "jpg", .MIMEType = "image/jpeg"},\r
@@ -150,7 +150,7 @@ void HTTPServerApp_Callback(void)
        }               \r
 }\r
 \r
-/** HTTP Server State handler for the Request Process state. This state manages the processing of incomming HTTP\r
+/** HTTP Server State handler for the Request Process state. This state manages the processing of incoming HTTP\r
  *  GET requests to the server from the receiving HTTP client.\r
  */\r
 static void HTTPServerApp_OpenRequestedFile(void)\r
@@ -198,8 +198,7 @@ static void HTTPServerApp_SendResponseHeader(void)
        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
+       const char* HeaderToSend;\r
 \r
        /* Determine which HTTP header should be sent to the client */\r
        if (AppState->HTTPServer.FileOpen)\r
@@ -214,9 +213,8 @@ static void HTTPServerApp_SendResponseHeader(void)
        }\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
+       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
@@ -236,10 +234,10 @@ static void HTTPServerApp_SendMIMETypeHeader(void)
                /* 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
+                       if (strcmp(&Extension[1], MIMETypes[i].Extension) == 0)\r
                        {\r
-                               MIMEHeaderLength = strlen_P(MIMETypes[i].MIMEType);\r
-                               strncpy_P(AppData, MIMETypes[i].MIMEType, MIMEHeaderLength);                                            \r
+                               MIMEHeaderLength = strlen(MIMETypes[i].MIMEType);\r
+                               strncpy(AppData, MIMETypes[i].MIMEType, MIMEHeaderLength);                                              \r
                                break;\r
                        }\r
                } \r