[multiple] application/javascript text/javascript
translate MIME type "application/javascript" to "text/javascript" (if required, type may still be overwritten by mod_setenv or mod_magnet) x-ref: "Updates to ECMAScript Media Types" https://www.rfc-editor.org/rfc/rfc9239
This commit is contained in:
parent
a6d4a98c07
commit
33f73b4d82
|
@ -113,7 +113,6 @@ mimetype.assign = (
|
|||
".inkml" => "application/inkml+xml",
|
||||
".ipfix" => "application/ipfix",
|
||||
".its" => "application/its+xml",
|
||||
".js" => "application/javascript",
|
||||
".jrd" => "application/jrd+json",
|
||||
".json" => "application/json",
|
||||
".json-patch" => "application/json-patch+json",
|
||||
|
@ -1223,6 +1222,8 @@ mimetype.assign = (
|
|||
".htm" => "text/html",
|
||||
".html" => "text/html",
|
||||
".sandboxed" => "text/html-sandboxed",
|
||||
".js" => "text/javascript",
|
||||
".mjs" => "text/javascript",
|
||||
".cnd" => "text/jcr-cnd",
|
||||
".markdown" => "text/markdown;charset=utf-8",
|
||||
".md" => "text/markdown;charset=utf-8",
|
||||
|
|
|
@ -171,6 +171,10 @@ while (<MIMETYPES>) {
|
|||
# from http://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
add(".dtd", "application/xml-dtd");
|
||||
|
||||
# RFC 9239
|
||||
add(".js", "text/javascript");
|
||||
add(".mjs", "text/javascript");
|
||||
|
||||
# other useful mappings
|
||||
my %useful = (
|
||||
".tar.gz" => "application/x-gtar-compressed",
|
||||
|
|
|
@ -1129,7 +1129,18 @@ static int config_insert(server *srv) {
|
|||
break;
|
||||
}
|
||||
case 19:/* connection.kbytes-per-second */
|
||||
case 20:/* mimetype.assign */
|
||||
break;
|
||||
case 20:{/* mimetype.assign */
|
||||
/* translate "application/javascript" to "text/javascript" */
|
||||
data_string * const ds = (data_string *)
|
||||
array_get_data_unset(cpv->v.a, CONST_STR_LEN(".js"));
|
||||
if (NULL != ds /*(note: this does not catch w/ ";charset=...")*/
|
||||
&& buffer_eq_slen(&ds->value,
|
||||
CONST_STR_LEN("application/javascript")))
|
||||
buffer_copy_string_len(&ds->value,
|
||||
CONST_STR_LEN("text/javascript"));
|
||||
break;
|
||||
}
|
||||
case 21:/* mimetype.use-xattr */
|
||||
case 22:/* etag.use-inode */
|
||||
case 23:/* etag.use-mtime */
|
||||
|
|
|
@ -962,6 +962,16 @@ static int http_response_process_headers(request_st * const restrict r, http_res
|
|||
r->keep_alive = 0;
|
||||
if (r->http_version >= HTTP_VERSION_2) continue;
|
||||
break;
|
||||
case HTTP_HEADER_CONTENT_TYPE:
|
||||
if (end - value >= 22 /*(prefix match probably good enough)*/
|
||||
&& 0 == memcmp(value, "application/javascript", 22)) {
|
||||
/* value = "text/javascript"; *//*(loses ";charset=...")*/
|
||||
/* *(const char **)&end = value+sizeof("text/javascript")-1; */
|
||||
/*(convert "application/javascript" to "text/javascript")*/
|
||||
value += 7; /*(step over "applica", leaving "tion")*/
|
||||
memcpy(s+(value-s)+1, "ext", 3);
|
||||
}
|
||||
break;
|
||||
case HTTP_HEADER_CONTENT_LENGTH:
|
||||
if (*value == '+') ++value;
|
||||
if (!r->resp_decode_chunked
|
||||
|
|
|
@ -751,6 +751,9 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) {
|
|||
size_t len = buffer_clen(mimetype);
|
||||
if (len > 2 && mimetype->ptr[len-1] == '*')
|
||||
buffer_truncate(mimetype, len-1);
|
||||
if (buffer_eq_slen(mimetype,
|
||||
CONST_STR_LEN("application/javascript")))
|
||||
buffer_copy_string_len(mimetype, "text/javascript", 15);
|
||||
}
|
||||
if (0 == cpv->v.a->used) cpv->v.a = NULL;
|
||||
break;
|
||||
|
|
|
@ -208,9 +208,21 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) {
|
|||
buffer_truncate(&ds->key, klen-1);
|
||||
}
|
||||
a = cpv->v.a;
|
||||
if (!array_get_element_klen(a, CONST_STR_LEN("text/javascript"))
|
||||
&& !array_get_element_klen(a, CONST_STR_LEN("text/"))) {
|
||||
array *m;
|
||||
*(const array **)&m = a;
|
||||
data_unset * const du =
|
||||
array_extract_element_klen(m,
|
||||
CONST_STR_LEN("application/javascript"));
|
||||
if (du) {
|
||||
buffer_copy_string_len(&du->key, "text/javascript", 15);
|
||||
array_replace(m, du);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:/* should not happen */
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* parse array values into structured data */
|
||||
|
|
Loading…
Reference in New Issue