mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
Some fixes:
* using ContentTypes to resolve static files too * added some default content types, in the case of mime.types file not present * resolve extensions with upper case letters in them
This commit is contained in:
parent
b847eea57e
commit
0ef9b22a7e
3 changed files with 37 additions and 27 deletions
|
@ -308,7 +308,7 @@ public:
|
|||
unsigned int i = info.fname.rfind('.');
|
||||
if(i != std::string::npos)
|
||||
ext = info.fname.substr(i+1);
|
||||
MHD_add_response_header(resp, "Content-Type", ContentTypes::ContentTypes::cTypeFromExt(ext).c_str());
|
||||
MHD_add_response_header(resp, "Content-Type", ContentTypes::cTypeFromExt(ext).c_str());
|
||||
|
||||
secure_queue_response(connection, MHD_HTTP_OK, resp);
|
||||
MHD_destroy_response(resp);
|
||||
|
@ -650,27 +650,10 @@ int ApiServerMHD::accessHandlerCallback(MHD_Connection *connection,
|
|||
{
|
||||
extension = filename[i] + extension;
|
||||
i--;
|
||||
}
|
||||
const char* type = 0;
|
||||
if(extension == "html")
|
||||
type = "text/html";
|
||||
else if(extension == "css")
|
||||
type = "text/css";
|
||||
else if(extension == "js")
|
||||
type = "text/javascript";
|
||||
else if(extension == "jsx") // react.js jsx files
|
||||
type = "text/jsx";
|
||||
else if(extension == "png")
|
||||
type = "image/png";
|
||||
else if(extension == "jpg" || extension == "jpeg")
|
||||
type = "image/jpeg";
|
||||
else if(extension == "gif")
|
||||
type = "image/gif";
|
||||
else
|
||||
type = "application/octet-stream";
|
||||
};
|
||||
|
||||
struct MHD_Response* resp = MHD_create_response_from_fd(s.st_size, fd);
|
||||
MHD_add_response_header(resp, "Content-Type", type);
|
||||
MHD_add_response_header(resp, "Content-Type", ContentTypes::cTypeFromExt(extension).c_str());
|
||||
secure_queue_response(connection, MHD_HTTP_OK, resp);
|
||||
MHD_destroy_response(resp);
|
||||
return MHD_YES;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue