htmlForText function

void htmlForText(
  1. HttpResponse res
)

With CoreFlags.htmlStrings, a string is sent as text/html. Only when the type is still the preset one: a type set by a middleware or the controller stays. The preset can not be told from ContentType.text set by hand, so use response(text).contentType(...) to keep plain text.

Implementation

void htmlForText(HttpResponse res) {
  if (!Dox().flags.htmlStrings) return;
  if (res.headers.value(HttpHeaders.contentTypeHeader) != _presetType) return;
  res.headers.contentType = ContentType.html;
}