WiFi WebServer for ESP8266

Fork of ESP8266_WebServer by Sebastian Schocke

Revision:
1:1c4333ce7448
Parent:
0:56c72c87d2f5
Child:
2:6079554681d6
diff -r 56c72c87d2f5 -r 1c4333ce7448 ESP8266_WebServer.cpp
--- a/ESP8266_WebServer.cpp	Thu Jan 01 10:11:55 2015 +0000
+++ b/ESP8266_WebServer.cpp	Thu Jan 01 10:22:31 2015 +0000
@@ -209,6 +209,16 @@
     sendResponse(linkID, replySize);
 }
 
+void ESP8266_WebServer::SendFile(int linkID, FileHandle* file, const char* mimeType) {
+    sprintf(response, "HTTP/1.1 200 OK\r\nContent-Type:%s\r\nContent-Length: %d\r\n\r\n", mimeType, file->flen());
+    sendResponse(linkID, strlen(response));
+    int numBytes = file->read(response, sizeof(response));
+    while( numBytes > 0) {
+        sendResponse(linkID, numBytes);
+        numBytes = file->read(response, sizeof(response));
+    }
+}
+
 ESP8266_WebRequest::ESP8266_WebRequest(const char* packet, Serial* debug) {
     int sz = strlen(packet);
     data = (char *)malloc(sz+1);