/** 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 HTTPHeader[] = "HTTP/1.1 200 OK\r\n"\r
- "Server: LUFA RNDIS\r\n"\r
- "Content-type: text/html\r\n"\r
- "Connection: close\r\n\r\n";\r
+char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
+ "Server: LUFA RNDIS\r\n"\r
+ "Content-type: text/html\r\n"\r
+ "Connection: close\r\n\r\n";\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\n";\r
\r
/** HTTP page to serve to the host when a HTTP request is made. This page is too long for a single response, thus it is automatically\r
* broken up into smaller blocks and sent as a series of packets each time the webserver application callback is run.\r
{\r
if (IsHTTPCommand(Buffer->Data, "GET"))\r
{\r
- PageBlock = 0;\r
-\r
- /* Copy the HTTP response header into the packet buffer */\r
- strcpy_P(BufferDataStr, HTTPHeader);\r
- \r
- /* Send the buffer contents to the host */\r
- TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
-\r
- /* Lock the buffer to Device->Host transmissions only while we send the page contents */\r
- TCP_APP_CAPTURE_BUFFER(Buffer);\r
+ if (IsHTTPCommand(Buffer->Data, "GET / "))\r
+ {\r
+ PageBlock = 0;\r
+\r
+ /* Copy the HTTP 200 response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP200Header);\r
+ \r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+\r
+ /* Lock the buffer to Device->Host transmissions only while we send the page contents */\r
+ TCP_APP_CAPTURE_BUFFER(Buffer);\r
+ }\r
+ else\r
+ {\r
+ /* Copy the HTTP 404 response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP404Header);\r
+ \r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+ \r
+ /* All data sent, close the connection */\r
+ TCP_APP_CLOSECONNECTION(ConnectionState);\r
+ }\r
}\r
else if (IsHTTPCommand(Buffer->Data, "HEAD"))\r
{\r
- /* Copy the HTTP response header into the packet buffer */\r
- strcpy_P(BufferDataStr, HTTPHeader);\r
-\r
- /* Send the buffer contents to the host */\r
- TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+ if (IsHTTPCommand(Buffer->Data, "HEAD / "))\r
+ {\r
+ /* Copy the HTTP response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP200Header);\r
+\r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+ }\r
+ else\r
+ {\r
+ /* Copy the HTTP response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP404Header);\r
+\r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr)); \r
+ }\r
+ \r
+ /* All data sent, close the connection */\r
+ TCP_APP_CLOSECONNECTION(ConnectionState);\r
}\r
else if (IsHTTPCommand(Buffer->Data, "TRACE"))\r
{\r
/* Echo the host's query back to the host */\r
TCP_APP_SEND_BUFFER(Buffer, Buffer->Length);\r
+ \r
+ /* All data sent, close the connection */\r
+ TCP_APP_CLOSECONNECTION(ConnectionState);\r
}\r
else\r
{\r
/** 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 HTTPHeader[] = "HTTP/1.1 200 OK\r\n"\r
- "Server: LUFA RNDIS\r\n"\r
- "Content-type: text/html\r\n"\r
- "Connection: close\r\n\r\n";\r
+char PROGMEM HTTP200Header[] = "HTTP/1.1 200 OK\r\n"\r
+ "Server: LUFA RNDIS\r\n"\r
+ "Content-type: text/html\r\n"\r
+ "Connection: close\r\n\r\n";\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\n";\r
\r
/** HTTP page to serve to the host when a HTTP request is made. This page is too long for a single response, thus it is automatically\r
* broken up into smaller blocks and sent as a series of packets each time the webserver application callback is run.\r
{\r
if (IsHTTPCommand(Buffer->Data, "GET"))\r
{\r
- PageBlock = 0;\r
-\r
- /* Copy the HTTP response header into the packet buffer */\r
- strcpy_P(BufferDataStr, HTTPHeader);\r
- \r
- /* Send the buffer contents to the host */\r
- TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
-\r
- /* Lock the buffer to Device->Host transmissions only while we send the page contents */\r
- TCP_APP_CAPTURE_BUFFER(Buffer);\r
+ if (IsHTTPCommand(Buffer->Data, "GET / "))\r
+ {\r
+ PageBlock = 0;\r
+\r
+ /* Copy the HTTP 200 response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP200Header);\r
+ \r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+\r
+ /* Lock the buffer to Device->Host transmissions only while we send the page contents */\r
+ TCP_APP_CAPTURE_BUFFER(Buffer);\r
+ }\r
+ else\r
+ {\r
+ /* Copy the HTTP 404 response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP404Header);\r
+ \r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+ \r
+ /* All data sent, close the connection */\r
+ TCP_APP_CLOSECONNECTION(ConnectionState);\r
+ }\r
}\r
else if (IsHTTPCommand(Buffer->Data, "HEAD"))\r
{\r
- /* Copy the HTTP response header into the packet buffer */\r
- strcpy_P(BufferDataStr, HTTPHeader);\r
-\r
- /* Send the buffer contents to the host */\r
- TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+ if (IsHTTPCommand(Buffer->Data, "HEAD / "))\r
+ {\r
+ /* Copy the HTTP response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP200Header);\r
+\r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr));\r
+ }\r
+ else\r
+ {\r
+ /* Copy the HTTP response header into the packet buffer */\r
+ strcpy_P(BufferDataStr, HTTP404Header);\r
+\r
+ /* Send the buffer contents to the host */\r
+ TCP_APP_SEND_BUFFER(Buffer, strlen(BufferDataStr)); \r
+ }\r
+ \r
+ /* All data sent, close the connection */\r
+ TCP_APP_CLOSECONNECTION(ConnectionState);\r
}\r
else if (IsHTTPCommand(Buffer->Data, "TRACE"))\r
{\r
/* Echo the host's query back to the host */\r
TCP_APP_SEND_BUFFER(Buffer, Buffer->Length);\r
+ \r
+ /* All data sent, close the connection */\r
+ TCP_APP_CLOSECONNECTION(ConnectionState);\r
}\r
else\r
{\r
* - Added new LEDs_ToggleLEDs() function to the LEDs driver\r
* - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions\r
* - Added new DEVICE_STATE_AS_GPIOR and HOST_STATE_AS_GPIOR compile time options\r
+ * - Added 404 errors to the Webserver in the RNDIS demos to indicate invalid URLs\r
* \r
* <b>Changed:</b>\r
* - Deprecated psuedo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)\r