0

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!

1
  • Please update your question with the code for responding to client! – Kareem Jan 30 '15 at 9:55
6

After your content type line, try adding another \r\n to finish up.

1
  • Fantastic - thanks so much. My lesson here is to make sure I don't miss any small details in the problem sheet. – AlastairHoward Jan 31 '15 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .