I respond to the client with the following function call:
dprintf(cfd, "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: %i\r\nContent-Type: %s\r\n\r\n%s", length, type, body);
This works, mostly, but the jpg file is giving me an ERR_CONTENT_LENGTH_MISMATCH in the status on the developer Network panel.
Upon further inspection, I found that the jpg was labeled as having a content-length of 26860, which is the total Bytes in the cat.jpg
file, BUT the "Size Content" column on the network panel says
Size
Content
100 B
13 B
For cat.html
, it says:
Size
Content
240 B
156 B
and 156 B is the size of my actual .html
, so for some reason that one works just fine but the .jpg
does not.
The biggest problem I am having is FINDING the particular bug here. I did not touch the code in load
, and I have no code handling body differently dependent on what's inside it.
In an attempt to debug, I used printf
to spit out the file contents of each file being passed in, and what I found was my HTML file has random characters (sometimes letters, sometimes weird boxes that my terminal makes difficult to discern) added after the </html>
which doesn't seem to affect the output, but I'm wondering if these extra bits have anything to do with my issues with the .jpg
file.