As shown, I've set all files (hello.html, cat.html, cat.jpg) to be readable. But when I try to go onto those locations on my local web-browsers what came up was a blank page for hello.html and this (as shown in picture) for cat.html. I think the problem with the code is problably the [response to client] part for static content: here is the code...
// load file
ssize_t length = load();
// printf("Length is: %i\n", length);
if (length == -1)
{
error(500);
continue;
}
// TODO: respond to client
if (dprintf(cfd, "HTTP/1.1 200 OK\r\n") < 0)
{
continue;
}
if (dprintf(cfd, "Connection: close\r\n") < 0)
{
continue;
}
if (dprintf(cfd, "Content-Length: %i\r\n", length) < 0)
{
continue;
}
if (dprintf(cfd, "Content-Type: %s\r\n", type) < 0)
{
continue;
}
if (write(cfd, body, length) == -1)
{
continue;
}
}