Hi,
I've created this simple HTTP web-server. For now, it's simply sending files on response, so I'm obviously able to send HTML files and such.
I'm willing to implement image-sending, so I that I could send images as-well, but I've encountered a problem.
When the server receives a request for an image file, it reads up the file.
This function reads the requested file and returns a byte array of the file.
We process the returned array, and store it in the
String "temp", after casting each byte to char:
Then we append it to our HTTP message and flush it to the client:
Using the browser, I get a
"The image “http://localhost/error_0x0.PNG” cannot be displayed, because it contains errors." error with Firefox. The file's obviously corrupt.
I decided to compare the image I receive from the server I made, and the original one, and they're different:
I must be reading the file wrong, or converting it wrong somehow..
What am I doing wrong?
Thanks