web-markdown is intentionally strict about HTTP behavior.
- Transform only when
Acceptexplicitly containstext/markdownwithq > 0. - Do not transform on wildcard-only headers like
*/*ortext/*. - If markdown is not explicitly acceptable, return the original representation.
- Skip transformation for redirects (
3xx). - Skip non-HTML responses.
- Treat
text/htmlandapplication/xhtml+xmlas HTML. - If
Content-Typeis missing, sniff body for likely HTML markers before converting.
- Always merge
Vary: Accepton transformed and passthrough responses. - Preserve status code and non-representation headers (for example
Cache-Control). - On transformed markdown responses:
- set
Content-Type: text/markdown; charset=utf-8 - remove
Content-Length - remove
Content-Encoding - remove
ETag(representation changed)
- set
- Default
maxHtmlBytes:3MB. - Overflow behavior:
passthrough(default): return original HTML.not-acceptable: return406.
transformFetchResponse supports onObservation with:
transformed- fallback
reason(if not transformed) durationMshtmlBytesmarkdownBytesstatus
Fallback reasons include:
not-acceptablenot-htmltoo-largestatusstreamed-unsupportedno-bodyconverter-error