Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions include/crow/http_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
#include <ios>
#include <fstream>
#include <sstream>
// S_ISREG is not defined for windows
// This defines it like suggested in https://stackoverflow.com/a/62371749
#if defined(_MSC_VER)
#define _CRT_INTERNAL_NONSTDC_NAMES 1
#endif
#include <sys/stat.h>
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
#endif

#include "crow/http_request.h"
#include "crow/ci_map.h"
Expand Down Expand Up @@ -233,7 +241,7 @@ namespace crow
#ifdef CROW_ENABLE_COMPRESSION
compressed = false;
#endif
if (file_info.statResult == 0)
if (file_info.statResult == 0 && S_ISREG(file_info.statbuf.st_mode))
{
std::size_t last_dot = path.find_last_of(".");
std::string extension = path.substr(last_dot + 1);
Expand All @@ -257,7 +265,6 @@ namespace crow
{
code = 404;
file_info.path.clear();
this->end();
}
}

Expand Down