On 2022/09/23 21:37:13 +0000, Klemens Nanni <[email protected]> wrote:
> In the few places I run httpd(8) patches usually float around and I do
> look at them with Firefox.
> 
> But unless httpd.conf(5) contains `types { text/plain diff patch }' the
> browser will download the file instead of displaying it as text.
> 
> Would it be sensible to add them to the default list so this line is not
> needed?
> 
> Not sure what implications this could have and/or what other web
> browers do by default, that should probably be evaluated first.
> 
> At least GitHub delivers .diff and .patch links with this content type,
> but it is also a slightly different scenario since GitHub, cgit, etc.
> generate and know the actual content type whereas httpd like type merely
> matches based on the filename suffix.
> 
>       $ curl -sI https://github.com/openbsd/src/commit/HEAD.patch |
>               grep -i content-type
>       content-type: text/plain; charset=utf-8
>       x-content-type-options: nosniff
> 
> Feedback?

not opposed to the idea, fwiw i like it, but shoudln't we add
something to /usr/shar/misc/mime.types too then?

> Index: http.h
> ===================================================================
> RCS file: /cvs/src/usr.sbin/httpd/http.h,v
> retrieving revision 1.16
> diff -u -p -r1.16 http.h
> --- http.h    12 Sep 2020 07:34:17 -0000      1.16
> +++ http.h    23 Sep 2022 21:26:23 -0000
> @@ -217,6 +217,8 @@ struct http_mediatype {
>       { "css",        "text",         "css" },        \
>       { "html",       "text",         "html" },       \
>       { "txt",        "text",         "plain" },      \
> +     { "diff",       "text",         "plain" },      \
> +     { "patch",      "text",         "plain" },      \
>       { "gif",        "image",        "gif" },        \
>       { "jpeg",       "image",        "jpeg" },       \
>       { "jpg",        "image",        "jpeg" },       \


Reply via email to