Strange, this is not "straight."
Besides adding a MIME header, the web server seems to highlight all jpeg tokens (0xFF, 0xNN), but leaves the rest intact. This seems strange since I don’t know how the web browser recognizes the beginning of the image frame.
I found this by writing my simple web server on the embedded system - I thought I would need to add the MIME header and send the rest of the jfif-jpeg file intact, but the browser says: “Image cannot be displayed because it contains errors”!
here is the beginning of the original jpeg / jfif in hex
ff d8 ff e0 00 10 4a 46 49 46 00
[SOI] [APP0] [length] JF i F NULL
According to specification.
The resulting file contains this, after the header:
0d 0a 0d 0a 00 10 4a 46 49 46 00
The first 4 bytes are cr / lf / cr / lf at the end of the header, then NO markers, but it contains a data field. The same thing is repeated for other markers, for example. start of frame.
Strange, huh? I don't think this is a mime coding problem, as the rest of the data looks intact - including FF in the data, etc.
Does anyone know what is going on here? PS, to get a closer look, just ask .jpg from any site, using putty or the like, and save what you get and compare it with the original or even with the saved version.