mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-30 12:47:48 +02:00
Move MIME type detection to util/HTTP.cpp
This commit is contained in:
parent
17cd149e7f
commit
221e350228
3 changed files with 19 additions and 7 deletions
|
@ -227,6 +227,19 @@ std::string preprocessContent(const std::string& content, const std::string& pat
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string getMimeType(const std::string& filename)
|
||||
{
|
||||
const std::string ext = filename.substr(filename.find_last_of("."));
|
||||
if(ext == ".css")
|
||||
return "text/css";
|
||||
else if(ext == ".css")
|
||||
return "text/javascript";
|
||||
else if(ext == ".html" || ext == ".htm")
|
||||
return "text/html";
|
||||
else
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,11 @@ private:
|
|||
*/
|
||||
std::string preprocessContent(const std::string& content, const std::string& path);
|
||||
|
||||
/**
|
||||
* @return the MIME type based on the extension of the given filename
|
||||
*/
|
||||
std::string getMimeType(const std::string& filename);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue