Hi, This patch removes the unused media_encoding field, it was probably intended to be used to add text-encoding information.
However: forcing a text-encoding can be useful in some cases. Currently in httpd.conf the text-encoding can be set with a hack for example: types { "text"/"plain; charset=utf-8" txt c h } This works because in parse.y the mediaoptsl grammar is defined as: STRING '/' STRING. However this might be incompatible with the mime.types format. Anyway, patch below: diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c index 6d1d1ff34fe..ef3f95a649d 100644 --- a/usr.sbin/httpd/httpd.c +++ b/usr.sbin/httpd/httpd.c @@ -1199,11 +1199,6 @@ media_add(struct mediatypes *types, struct media_type *media) return (NULL); memcpy(entry, media, sizeof(*entry)); - if (media->media_encoding != NULL && - (entry->media_encoding = strdup(media->media_encoding)) == NULL) { - free(entry); - return (NULL); - } RB_INSERT(mediatypes, types, entry); return (entry); @@ -1214,7 +1209,6 @@ media_delete(struct mediatypes *types, struct media_type *media) { RB_REMOVE(mediatypes, types, media); - free(media->media_encoding); free(media); } diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 05cbb8e3550..9a6530715c7 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -53,7 +53,7 @@ #define HTTPD_LOGROOT "/logs" #define HTTPD_ACCESS_LOG "access.log" #define HTTPD_ERROR_LOG "error.log" -#define HTTPD_DEFAULT_TYPE { "bin", "application", "octet-stream", NULL } +#define HTTPD_DEFAULT_TYPE { "bin", "application", "octet-stream" } #define HTTPD_LOGVIS VIS_NL|VIS_TAB|VIS_CSTYLE #define HTTPD_TLS_CERT "/etc/ssl/server.crt" #define HTTPD_TLS_KEY "/etc/ssl/private/server.key" @@ -438,7 +438,6 @@ struct media_type { char media_name[MEDIATYPE_NAMEMAX]; char media_type[MEDIATYPE_TYPEMAX]; char media_subtype[MEDIATYPE_TYPEMAX]; - char *media_encoding; RB_ENTRY(media_type) media_entry; }; RB_HEAD(mediatypes, media_type); diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index 203ddd1b0bb..2fc50b1a1da 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1695,7 +1695,6 @@ load_config(const char *filename, struct httpd *x_conf) (void)strlcpy(m.media_subtype, mediatypes[i].media_subtype, sizeof(m.media_subtype)); - m.media_encoding = NULL; if (media_add(conf->sc_mediatypes, &m) == NULL) { log_warnx("failed to add default media \"%s\"", -- Kind regards, Hiltjo