Skip to main content

src/plume@content_type_options.erl

-module(plume@content_type_options).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plume/content_type_options.gleam").
-export([to_string/1]).
-export_type([content_type_options/0]).

-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.

?MODULEDOC(
    " X-Content-Type-Options\n"
    "\n"
    " This response header indicates that the [MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types)\n"
    " advertised in the `Content-Type` headers should be respected and not changed.\n"
    " It is a way to opt out of [MIME type sniffing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types#mime_sniffing),\n"
    " reducing exposure to drive-by download attacks and the serving of user-uploaded content\n"
    " with an unexpected MIME type.\n"
    "\n"
    " See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Content-Type-Options).\n"
).

-type content_type_options() :: no_sniff.

-file("src/plume/content_type_options.gleam", 22).
?DOC(" Encode as the `X-Content-Type-Options` header value.\n").
-spec to_string(content_type_options()) -> binary().
to_string(Value) ->
    case Value of
        no_sniff ->
            <<"nosniff"/utf8>>
    end.