| 38 | #undef XX |
| 39 | |
| 40 | void sendFile(const String& fileName, HttpServerConnection& connection) |
| 41 | { |
| 42 | auto response = connection.getResponse(); |
| 43 | |
| 44 | String compressed = fileName + ".gz"; |
| 45 | auto content = fileMap[compressed]; |
| 46 | if(content) { |
| 47 | response->headers[HTTP_HEADER_CONTENT_ENCODING] = _F("gzip"); |
| 48 | } else { |
| 49 | content = fileMap[fileName]; |
| 50 | if(!content) { |
| 51 | debug_w("File '%s' not found", fileName.c_str()); |
| 52 | response->code = HTTP_STATUS_NOT_FOUND; |
| 53 | return; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | debug_i("found %s in fileMap", String(content.key()).c_str()); |
| 58 | auto stream = new FSTR::Stream(content.content()); |
| 59 | response->sendDataStream(stream, ContentType::fromFullFileName(fileName)); |
| 60 | |
| 61 | // Use client caching for better performance. |
| 62 | // response->setCache(86400, true); |
| 63 | } |
| 64 | |
| 65 | #else |
| 66 |
no test coverage detected