Hwaro::Services::CharsetHandler
Inherits HTTP::Handler / Reference / Object
HTTP::StaticFileHandler derives Content-Type from the file
extension via MIME.from_extension and writes it without a
charset parameter — so robots.txt / llms.txt / sitemap and
search index responses all advertise no charset, leaving UTF-8
bytes (e.g. Korean LLM-instructions) at the mercy of client-side
heuristics. This handler runs after the static handler and
appends ; charset=utf-8 to text-shaped responses.
We only touch types we know are text. Binary types (image/png,
font/woff2, etc.) are left alone — adding a charset there would
be wrong, not just useless. image/svg+xml is treated as text
because it's XML.
Constants
TEXT_PREFIXES = ["text/"]
TEXT_SUFFIXES = ["+xml", "+json"]
TEXT_TYPES = Set {"application/xml", "application/json", "application/javascript", "application/rss+xml", "application/atom+xml", "image/svg+xml"}
Instance methods
call(context)
Source