When I run
check50 2015.fall.pset6.server1 server.c
I get
:) server.c exists
:) server compiles
:) HTTP/1.0 returns error code 505
:) Method of 'abcGET' returns error code 405
:) Method of 'GETabc' returns error code 405
:) request-target without starting '/' returns error code 501
:) request-target of abc/hello.php returns error code 501
:( Requesting cat.exe returns error code 501 \ expected output, not an exit code of 0
:) Requesting non-existant file returns error code 404
:) Requesting request-target with " returns error code 400
:) Two spaces after GET returns error code
:) A space within the request target returns error code
:) Two spaces before HTTP/1.1 returns error code
I tried many times but still not able to figure out why I keep getting this
:( Requesting cat.exe returns error code 501 \ expected output, not an exit code of 0
Here is my lookup function
/**
* Returns MIME type for supported extensions, else NULL.
*/
const char* lookup(const char* path)
{
// initialize a pointer
char* extension = NULL;
// storing extension of path at extension
strcpy(extension, strrchr(path, '.'));
// checking for every extension then returning value based on that
if (extension != NULL)
{
if (strcasecmp(extension, ".css") == 0)
{
return "text/css";
}
if(strcasecmp(extension, ".html") == 0)
{
return "text/html";
}
if (strcasecmp(extension, ".gif") == 0)
{
return "image/gif";
}
if (strcasecmp(extension, ".ico") == 0)
{
return "image/x-icon";
}
if (strcasecmp(extension, ".jpg") == 0)
{
return "image/jpeg";
}
if (strcasecmp(extension, ".js") == 0)
{
return "text/javascript";
}
if (strcasecmp(extension, ".php") == 0)
{
return "text/x-php";
}
if (strcasecmp(extension, ".png") == 0)
{
return "image/png";
}
}
return NULL;
}