Skip to content

Commit

Permalink
Added error 501
Browse files Browse the repository at this point in the history
  • Loading branch information
padenot committed Feb 14, 2011
1 parent 4145567 commit ee2b670
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/threaded_server/.gitignore
@@ -0,0 +1,2 @@
*.swp
tags
Empty file modified code/threaded_server/src/main.cpp 100755 → 100644
Empty file.
33 changes: 30 additions & 3 deletions code/threaded_server/src/server.cpp 100755 → 100644
Expand Up @@ -47,6 +47,32 @@ const char ERROR_404[] = "HTTP/1.1 404 NOT FOUND\r\n\r\n"
"<body>"
"</html>\r\n";

/**
* String returned when a 501 error shall occur (method not implemented).
*/
const char ERROR_501[] = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"
"<html><head>"
"<title>501 Method Not Implemented</title>"
"</head><body>"
"<h1>Method Not Implemented</h1>"
"<p>akenrlanre to /index.html not supported.<br />"
"</p>"
"<hr>"
"</body></html>";
/**
* String returned when a 400 error occur (malformed request).
* TODO
*/
const char ERROR_400[] = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">"
"<html><head>"
"<title>400 Bad Request</title>"
"</head><body>"
"<h1>Bad Request</h1>"
"<p>Your browser sent a request that this server could not understand.<br />"
"</p>"
"<hr>"
"</body></html>";

/**
* Header for a normal response.
*/
Expand Down Expand Up @@ -118,17 +144,18 @@ void* thread_function(void *client_infos)

if(get_URL(request, path, requested))
{
LOG << "Bad request" << std::endl;
send_socket(infos->fd_client, ERROR_501, strlen(ERROR_501));
goto clean;
}


send_content(path, requested, infos->fd_client);
}

close_socket(infos->fd_client);
clean:

close_socket(infos->fd_client);
delete infos;

pthread_exit(0);
}

Expand Down
Empty file modified code/threaded_server/src/server.hpp 100755 → 100644
Empty file.
Empty file modified code/threaded_server/src/socket.cpp 100755 → 100644
Empty file.
Empty file modified code/threaded_server/src/socket.hpp 100755 → 100644
Empty file.

0 comments on commit ee2b670

Please sign in to comment.