Skip to content

Commit

Permalink
Replaced all occurencies of HTTP/1.0 with HTTP/1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanpc committed Nov 27, 2012
1 parent 03bf870 commit d0b2a3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
The TODO list for the awesome bonsai server:

- Colorize the console output.
- Prevent the use of .. in the URL for security.
- Implement the Lua scripting for the config files (yes, all config files are going to be written in Lua).
- Write the standards for the config files.
- Implement the Virtual Host stuff in Lua.
- Implement logging.

x Improve the folder checking algorithm.
x Colorize the console output.
9 changes: 6 additions & 3 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void send_file(int connection, char file_name[501]) {
char mime[60];
DIR *dir;
bool redir = false;
bool invalid_url = false;

strcpy(file_location, "htdocs");
strcat(file_location, file_name);
Expand Down Expand Up @@ -121,10 +122,12 @@ void send_file(int connection, char file_name[501]) {
if (redir) {
read_buffer = NULL;

strcpy(response_headers[0], "HTTP/1.0 301 Moved Permanently");
strcpy(response_headers[0], "HTTP/1.1 301 Moved Permanently");
strcpy(response_headers[2], "Location: ");
strcat(response_headers[2], file_name);
strcat(response_headers[2], "/");
} else if (invalid_url) {
read_buffer = NULL;
} else if (file != NULL) {
fseek(file, 0, SEEK_END);
file_size = ftell(file);
Expand All @@ -133,15 +136,15 @@ void send_file(int connection, char file_name[501]) {
read_buffer = calloc((sizeof * read_buffer * file_size) + 1, sizeof(char));
fread(read_buffer, 1, file_size, file);

strcpy(response_headers[0], "HTTP/1.0 200 OK");
strcpy(response_headers[0], "HTTP/1.1 200 OK");
strcpy(response_headers[2], "Content-Type: ");
strcat(response_headers[2], mime);

fclose(file);
} else {
read_buffer = NULL;
// TODO: Get the 404 page from the template dir.
strcpy(response_headers[0], "HTTP/1.0 404 Not Found");
strcpy(response_headers[0], "HTTP/1.1 404 Not Found");
strcpy(response_headers[2], "Content-Type: text/html");
}

Expand Down

0 comments on commit d0b2a3c

Please sign in to comment.