I am repeatedly getting ERR_CONTENT_LENGTH_MISMATCH in Chrome's Network Status tab when trying to load any file in the appliance's browser. This is despite the content loading correctly when I run it through telnet.
This is my code to respond to the 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;
}
I have used write(cfd, body, length) to spit out the file's content but there is obviously an issue with the length. Should I be looking for file headers and subtracting these from the length? Any help would be mega!