diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index d06fa6def..9a73e0e84 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -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])) diff --git a/engine/http/httpserver.c b/engine/http/httpserver.c index ca2844cdb..10fc8c7ab 100644 --- a/engine/http/httpserver.c +++ b/engine/http/httpserver.c @@ -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