I can't figure out how to even get the / list to show up in the browser. I believe the reason based on printf statements comes from the fact that lookup is returning null. However, when the path is /home/ubuntu/workspace/pset6/public/ to start off with it, shouldn't it be returning null? However, the fact that the first request returns null gives the 501 error. I can't figure out how to not get the first path to show null?
const char* lookup(const char* path)
{
// TODO
int path_length = strlen(path);
printf("%s", path);
char ending[6];
for(int i = 0; i < path_length; i++)
{
if(path[i]=='.')
{
for(int j = 0; j < 6; j++)
{
if(i < path_length)
{
ending[j] = path[i];
i++;
}
else
{
ending[j] = '\0';
break;
}
}
}
}
if(strcasecmp(ending, ".css") == 0)
{
const char* mime = "text/css";
return mime;
}
if(strcasecmp(ending, ".html") == 0)
{
const char* mime = "text/html";
return mime;
}
if(strcasecmp(ending, ".gif") == 0)
{
const char* mime = "image/gif";
return mime;
}
if(strcasecmp(ending, ".ico") == 0)
{
const char* mime = "image/x-icon";
return mime;
}
if(strcasecmp(ending, ".jpg") == 0)
{
const char* mime = "image/jpeg";
return mime;
}
if(strcasecmp(ending, ".js") == 0)
{
const char* mime = "text/javascript";
return mime;
}
if(strcasecmp(ending, ".phm") == 0)
{
const char* mime = "text/x-php";
return mime;
}
if(strcasecmp(ending, ".png") == 0)
{
const char* mime = "image/png";
return mime;
}
return NULL;
}