Make sure our own web servers report wasm files as the correct mime type. Firefox can be a bit quirky otherwise.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6052 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-09-01 03:54:40 +00:00
parent 13d8d0fbdf
commit 4d7836b5ff
2 changed files with 33 additions and 19 deletions

View file

@ -4539,28 +4539,32 @@ qboolean FTENET_TCP_HTTPResponse(ftenet_tcp_stream_t *st, httparg_t arg[WCATTR_C
char etag[64];
if (!filetype)
{
char ext[64];
const char *ext;
int i;
static const char *mimes[] =
{
"html", "text/html",
"htm", "text/html",
"png", "image/png",
"jpeg", "image/jpeg",
"jpg", "image/jpeg",
"ico", "image/vnd.microsoft.icon",
"pk3", "application/zip",
"fmf", "application/x-ftemanifest",
"qtv", "application/x-qtv",
".html", "text/html",
".htm", "text/html",
".png", "image/png",
".jpeg", "image/jpeg",
".jpg", "image/jpeg",
".ico", "image/vnd.microsoft.icon",
".pk3", "application/zip",
".fmf", "application/x-ftemanifest",
".qtv", "application/x-qtv",
".wasm", "application/wasm",
".js", "text/javascript",
"mvd", "application/x-multiviewdemo",
"mvd.gz", "application/x-multiviewdemo",
"qwd", "application/x-multiviewdemo",
"qwd.gz", "application/x-multiviewdemo",
"dem", "application/x-multiviewdemo",
"dem.gz", "application/x-multiviewdemo",
".mvd", "application/x-multiviewdemo",
".mvd.gz", "application/x-multiviewdemo",
".qwd", "application/x-multiviewdemo",
".qwd.gz", "application/x-multiviewdemo",
".dem", "application/x-multiviewdemo",
".dem.gz", "application/x-multiviewdemo",
};
COM_FileExtension (name, ext, sizeof(ext));
ext = COM_GetFileExtension(name, NULL);
if (!strcmp(ext, ".gz")||!strcmp(ext, ".xz"))
ext = COM_GetFileExtension(name, ext);
for (i = 0; i < countof(mimes); i+=2)
{
if (!Q_strcasecmp(ext, mimes[i]))

View file

@ -587,11 +587,21 @@ const char *HTTP_RunClient (HTTP_active_connections_t *cl)
}
else
{
const char *mimeline;
if (strstr(resource, ".htm"))
mimeline = "Content-Type: text/html\r\n";
else if (strstr(resource, ".wasm"))
mimeline = "Content-Type: application/wasm\r\n";
else if (strstr(resource, ".js"))
mimeline = "Content-Type: text/javascript\r\n";
else
mimeline = NULL;
//fixme: add connection: keep-alive or whatever so that ie3 is happy...
if (HTTPmarkup>=3)
sprintf(resource, "HTTP/1.1 200 OK\r\n" "%s%s" "Connection: %s\r\n" "Content-Length: %i\r\n" "Server: "FULLENGINENAME"/0\r\n" "\r\n", strstr(resource, ".htm")?"Content-Type: text/html\r\n":"", gzipped?"Content-Encoding: gzip\r\nCache-Control: public, max-age=86400\r\n":"", cl->closeaftertransaction?"close":"keep-alive", (int)VFS_GETLEN(cl->file));
sprintf(resource, "HTTP/1.1 200 OK\r\n" "%s%s" "Connection: %s\r\n" "Content-Length: %i\r\n" "Server: "FULLENGINENAME"/0\r\n" "\r\n", mimeline, gzipped?"Content-Encoding: gzip\r\nCache-Control: public, max-age=86400\r\n":"", cl->closeaftertransaction?"close":"keep-alive", (int)VFS_GETLEN(cl->file));
else if (HTTPmarkup==2)
sprintf(resource, "HTTP/1.0 200 OK\r\n" "%s%s" "Connection: %s\r\n" "Content-Length: %i\r\n" "Server: "FULLENGINENAME"/0\r\n" "\r\n", strstr(resource, ".htm")?"Content-Type: text/html\r\n":"", gzipped?"Content-Encoding: gzip\r\nCache-Control: public, max-age=86400\r\n":"", cl->closeaftertransaction?"close":"keep-alive", (int)VFS_GETLEN(cl->file));
sprintf(resource, "HTTP/1.0 200 OK\r\n" "%s%s" "Connection: %s\r\n" "Content-Length: %i\r\n" "Server: "FULLENGINENAME"/0\r\n" "\r\n", mimeline, gzipped?"Content-Encoding: gzip\r\nCache-Control: public, max-age=86400\r\n":"", cl->closeaftertransaction?"close":"keep-alive", (int)VFS_GETLEN(cl->file));
else if (HTTPmarkup)
sprintf(resource, "HTTP/0.9 200 OK\r\n\r\n");
else