I'd like to have one method for sending file contents from an SDCard via an Ethernet card to a browser.
Particularly, I'd like to use TinyFat's binary read method for both text (.htm) and binary (e.g. .png) files.
When I do a binary read on a HTML file, what gets echo'd to the browser is something like :
60 33 68 79 67 84 89 80 69 32 104 116 109 108 62 10 60 104 ..... which correctly corresponds to the character codes for the html I am trying to send ( and so on....).
What I don't understand is how to inform the browser to correctly interpret the data I'm sending, or how to send it in the correct format... I'm googling myself to death but it's not helping.
The relevant headers that I'm sending (for the .htm) are :
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html; charset=ISO-8859-1");
and the relevant file reading part is :
res=file.openFile(filename, FILEMODE_BINARY);
if (res==NO_ERROR)
{
result=512;
i=0;
while (result==512)
{
Serial.println("RESULT 512");
result=file.readBinary();
for(int i=0;i<result;i++) {
client.println(file.buffer[i]);
}
}
...
Does anybody know what blindingly obvious step I'm missing?!? Many thanks in advance!