MCPcopy Create free account
hub / github.com/SmingHub/Sming / sendFile

Method sendFile

samples/Basic_WebSkeletonApp/app/DelayStream.cpp:3–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "DelayStream.h"
2
3void DelayStream::sendFile()
4{
5 auto response = connection.getResponse();
6
7 String fn = filename + _F(".gz");
8 if(::fileExist(fn)) {
9 response->headers[HTTP_HEADER_CONTENT_ENCODING] = F("gzip");
10 } else {
11 fn = filename;
12 }
13
14 if(FileStream::open(fn, File::ReadOnly)) {
15 debug_i("opened '%s', %u bytes", fn.c_str(), FileStream::available());
16 response->setContentType(getMimeType());
17 } else {
18 debug_e("open '%s' failed!", fn.c_str());
19 response->code = HTTP_STATUS_NOT_FOUND;
20 }
21
22 ready = true;
23 connection.send();
24}

Callers 15

onFileFunction · 0.45
onFileFunction · 0.45
onUploadFunction · 0.45
onFileFunction · 0.45
onIndexFunction · 0.45
onFileFunction · 0.45
onIndexFunction · 0.45
onConfigurationFunction · 0.45
onFileFunction · 0.45
onFileFunction · 0.45
onIndexFunction · 0.45
onFileFunction · 0.45

Calls 6

fileExistFunction · 0.85
getResponseMethod · 0.80
setContentTypeMethod · 0.80
FFunction · 0.50
c_strMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected