Skip to content

Commit 590293e

Browse files
committed
If content type cannot be determined from path, then try uri.
This is useful for minified files (eg. path file.min.js, file file.js).
1 parent 9bc1ae5 commit 590293e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ class StaticRequestHandler : public RequestHandler {
9696

9797
String contentType = getContentType(path);
9898

99+
// If content type not matched on path, then try for uri
100+
// Useful for minified javascript et al.
101+
if (contentType.equals("application/octet-stream"))
102+
{
103+
contentType = getContentType(requestUri);
104+
}
105+
99106
// look for gz file, only if the original specified path is not a gz. So part only works to send gzip via content encoding when a non compressed is asked for
100107
// if you point the the path to gzip you will serve the gzip as content type "application/x-gzip", not text or javascript etc...
101108
if (!path.endsWith(".gz") && !_fs.exists(path)) {

0 commit comments

Comments
 (0)