mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Changed set_file_content to accept only a regular file path.
This commit is contained in:
parent
3f2922b3fa
commit
7ab9c119ef
3 changed files with 90 additions and 91 deletions
15
httplib.h
15
httplib.h
|
@ -5752,12 +5752,21 @@ inline void Response::set_chunked_content_provider(
|
|||
|
||||
inline void Response::set_file_content(const std::string &path,
|
||||
const std::string &content_type) {
|
||||
file_content_path_ = path;
|
||||
file_content_content_type_ = content_type;
|
||||
detail::FileStat stat(dir);
|
||||
if (stat.is_file(path)) {
|
||||
file_content_path_ = path;
|
||||
file_content_content_type_ = content_type;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CPPHTTPLIB_NO_EXCEPTIONS
|
||||
std::string msg = "'" + path + "' is not a regular file.";
|
||||
throw std::invalid_argument(msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void Response::set_file_content(const std::string &path) {
|
||||
file_content_path_ = path;
|
||||
return set_file_content(path, std::string());
|
||||
}
|
||||
|
||||
// Result implementation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue