File tree Expand file tree Collapse file tree 2 files changed +26
-20
lines changed
libraries/ESP8266WebServer/src/detail Expand file tree Collapse file tree 2 files changed +26
-20
lines changed Original file line number Diff line number Diff line change 99
1010namespace esp8266webserver {
1111
12- // calculate an ETag for a file in filesystem based on md5 checksum
13- // that can be used in the http headers - include quotes.
14- static String calcETag (FS &fs, const String &path) {
15- String result;
16-
17- // calculate eTag using md5 checksum
18- uint8_t md5_buf[16 ];
19- File f = fs.open (path, " r" );
20- MD5Builder calcMD5;
21- calcMD5.begin ();
22- calcMD5.addStream (f, f.size ());
23- calcMD5.calculate ();
24- calcMD5.getBytes (md5_buf);
25- f.close ();
26- // create a minimal-length eTag using base64 byte[]->text encoding.
27- result = " \" " + base64::encode (md5_buf, 16 , false ) + " \" " ;
28- return (result);
29- } // calcETag
30-
12+ String calcETag (FS &, const String &);
3113
3214template <typename ServerType>
3315class FunctionRequestHandler : public RequestHandler <ServerType> {
@@ -310,4 +292,4 @@ public StaticRequestHandler<ServerType> {
310292
311293} // namespace
312294
313- #endif // REQUESTHANDLERSIMPL_H
295+ #endif // REQUESTHANDLERSIMPL_H
Original file line number Diff line number Diff line change 1+ #include < ESP8266WebServer.h>
2+
3+ namespace esp8266webserver {
4+
5+ // calculate an ETag for a file in filesystem based on md5 checksum
6+ // that can be used in the http headers - include quotes.
7+ String calcETag (FS &fs, const String &path) {
8+ String result;
9+
10+ // calculate eTag using md5 checksum
11+ uint8_t md5_buf[16 ];
12+ File f = fs.open (path, " r" );
13+ MD5Builder calcMD5;
14+ calcMD5.begin ();
15+ calcMD5.addStream (f, f.size ());
16+ calcMD5.calculate ();
17+ calcMD5.getBytes (md5_buf);
18+ f.close ();
19+ // create a minimal-length eTag using base64 byte[]->text encoding.
20+ result = " \" " + base64::encode (md5_buf, 16 , false ) + " \" " ;
21+ return (result);
22+ }
23+
24+ } // namespace esp8266webserver
You can’t perform that action at this time.
0 commit comments