diff --git a/apps/httpserver_raw/httpd.c b/apps/httpserver_raw/httpd.c
index afab3a2..cac3c46 100644
--- a/apps/httpserver_raw/httpd.c
+++ b/apps/httpserver_raw/httpd.c
@@ -672,6 +672,10 @@ get_http_headers(struct http_state *pState, char *pszURI)
the 200 OK header. */
if (strstr(pszURI, "404")) {
pState->hdrs[0] = g_psHTTPHeaderStrings[HTTP_HDR_NOT_FOUND];
+ } else if (strstr(pszURI, "400")) {
+ pState->hdrs[0] = g_psHTTPHeaderStrings[HTTP_HDR_BAD_REQUEST];
+ } else if (strstr(pszURI, "501")) {
+ pState->hdrs[0] = g_psHTTPHeaderStrings[HTTP_HDR_NOT_IMPL];
} else {
pState->hdrs[0] = g_psHTTPHeaderStrings[HTTP_HDR_OK];
}
diff --git a/apps/httpserver_raw/httpd_structs.h b/apps/httpserver_raw/httpd_structs.h
index 60f3cb7..b211ef7 100644
--- a/apps/httpserver_raw/httpd_structs.h
+++ b/apps/httpserver_raw/httpd_structs.h
@@ -31,8 +31,7 @@ typedef struct
static const char *g_psHTTPHeaderStrings[] =
{
"Content-type: text/html\r\n\r\n",
- "Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\n" \
- "Pragma: no-cache\r\n\r\n",
+ "Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\nPragma: no-cache\r\n\r\n",
"Content-type: image/gif\r\n\r\n",
"Content-type: image/png\r\n\r\n",
"Content-type: image/jpeg\r\n\r\n",
@@ -47,13 +46,16 @@ static const char *g_psHTTPHeaderStrings[] =
"Content-type: text/plain\r\n\r\n",
"HTTP/1.0 200 OK\r\n",
"HTTP/1.0 404 File not found\r\n",
+ "HTTP/1.0 400 Bad Request\r\n",
+ "HTTP/1.0 501 Not Implemented\r\n",
"HTTP/1.1 200 OK\r\n",
"HTTP/1.1 404 File not found\r\n",
+ "HTTP/1.1 400 Bad Request\r\n",
+ "HTTP/1.1 501 Not Implemented\r\n",
"Content-Length: ",
"Connection: Close\r\n",
"Server: "HTTPD_SERVER_AGENT"\r\n",
- "\r\n
404: The requested file cannot be found." \
- "
\r\n"
+ "\r\n404: The requested file cannot be found.
\r\n"
};
/* Indexes into the g_psHTTPHeaderStrings array */
@@ -73,12 +75,16 @@ static const char *g_psHTTPHeaderStrings[] =
#define HTTP_HDR_DEFAULT_TYPE 13 /* text/plain */
#define HTTP_HDR_OK 14 /* 200 OK */
#define HTTP_HDR_NOT_FOUND 15 /* 404 File not found */
-#define HTTP_HDR_OK_11 16 /* 200 OK */
-#define HTTP_HDR_NOT_FOUND_11 17 /* 404 File not found */
-#define HTTP_HDR_CONTENT_LENGTH 18 /* 200 OK (HTTP 1.1) */
-#define HTTP_HDR_CONN_CLOSE 19 /* 404 File not found (HTTP 1.1) */
-#define HTTP_HDR_SERVER 20 /* Server: HTTPD_SERVER_AGENT */
-#define DEFAULT_404_HTML 21 /* default 404 body */
+#define HTTP_HDR_BAD_REQUEST 16 /* 400 Bad request */
+#define HTTP_HDR_NOT_IMPL 17 /* 501 Not Implemented */
+#define HTTP_HDR_OK_11 18 /* 200 OK */
+#define HTTP_HDR_NOT_FOUND_11 19 /* 404 File not found */
+#define HTTP_HDR_BAD_REQUEST_11 20 /* 400 Bad request */
+#define HTTP_HDR_NOT_IMPL_11 21 /* 501 Not Implemented */
+#define HTTP_HDR_CONTENT_LENGTH 22 /* Content-Length: (HTTP 1.1)*/
+#define HTTP_HDR_CONN_CLOSE 23 /* Connection: Close (HTTP 1.1) */
+#define HTTP_HDR_SERVER 24 /* Server: HTTPD_SERVER_AGENT */
+#define DEFAULT_404_HTML 25 /* default 404 body */
/** A list of extension-to-HTTP header strings */
static tHTTPHeader g_psHTTPHeaders[] =
diff --git a/apps/httpserver_raw/makefsdata/makefsdata.c b/apps/httpserver_raw/makefsdata/makefsdata.c
index 48ea83a..cd76acb 100644
--- a/apps/httpserver_raw/makefsdata/makefsdata.c
+++ b/apps/httpserver_raw/makefsdata/makefsdata.c
@@ -471,11 +471,21 @@ int file_write_http_header(FILE *data_file, const char *filename, int file_size,
}
fprintf(data_file, NEWLINE "/* HTTP header */");
- if (strstr(filename, "404")) {
+ if (strstr(filename, "404") == filename) {
response_type = HTTP_HDR_NOT_FOUND;
if (useHttp11) {
response_type = HTTP_HDR_NOT_FOUND_11;
}
+ } else if (strstr(filename, "400") == filename) {
+ response_type = HTTP_HDR_BAD_REQUEST;
+ if (useHttp11) {
+ response_type = HTTP_HDR_BAD_REQUEST_11;
+ }
+ } else if (strstr(filename, "501") == filename) {
+ response_type = HTTP_HDR_NOT_IMPL;
+ if (useHttp11) {
+ response_type = HTTP_HDR_NOT_IMPL_11;
+ }
}
cur_string = g_psHTTPHeaderStrings[response_type];
cur_len = strlen(cur_string);