#include <MimeTypes.hpp>
◆ MimeTypes() [1/2]
Constructs the MimeTypes object and loads MIME types from the specified file.
This constructor initializes the MIME types map by reading from the provided file path. It sets the last reload time to the last modification time of the file. If the file cannot be loaded, throws a runtime_error exception.
- Parameters
-
path | Optional parameter path to the MIME types configuration file. Defaults to "MIME_TYPES_PATH". |
◆ MimeTypes() [2/2]
http::MimeTypes::MimeTypes |
( |
const MimeTypes & | other | ) |
|
Copy constructor.
This constructor creates a new MimeTypes object as a copy of an existing one.
- Parameters
-
◆ ~MimeTypes()
http::MimeTypes::~MimeTypes |
( |
| ) |
|
◆ findFirstNonSpace()
size_t http::MimeTypes::findFirstNonSpace |
( |
const std::string | str, |
|
|
size_t | startPos ) |
|
private |
◆ findFirstSpace()
size_t http::MimeTypes::findFirstSpace |
( |
const std::string | str | ) |
|
|
private |
◆ getMimeType()
const std::string http::MimeTypes::getMimeType |
( |
const std::string & | extension | ) |
const |
Retrieves the MIME type associated with a given file extension.
This method looks up the MIME type corresponding to the provided file extension in the loaded MIME types map..
- Parameters
-
extension | The file extension (without the leading dot) for which to retrieve the MIME type. |
- Returns
- The corresponding MIME type as a string, or "text/plain" if the extension is not recognized.
◆ operator=()
Assignment operator.
This operator assigns the contents of one MimeTypes object to another.
- Parameters
-
- Returns
- A reference to this MimeTypes object.
◆ reload()
void http::MimeTypes::reload |
( |
| ) |
|
Reloads the MIME types from the configuration file.
This method reads the MIME types file specified by filePath_ and populates the mimeTypes_ map with the latest MIME type definitions. It updates the rtime_ to reflect the time of the last successful reload.
◆ wasChanged()
bool http::MimeTypes::wasChanged |
( |
| ) |
|
|
private |
checks if the MIME types file has been modified since the last load.
◆ filePath_
std::string http::MimeTypes::filePath_ |
|
private |
◆ mimeTypes_
std::map<std::string, std::string> http::MimeTypes::mimeTypes_ |
|
private |
◆ rtime_
struct timespec http::MimeTypes::rtime_ |
|
private |
The documentation for this class was generated from the following files: