Function: verb--headers-content-type

verb--headers-content-type is a natively compiled function defined in verb.el.

Signature

(verb--headers-content-type HEADERS)

Documentation

Return the value of the "Content-Type" header in HEADERS.

The value returned has the form (TYPE . CHARSET). If the charset is not present, return (TYPE). If the header itself is not present, return (nil).

Source Code

;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb.el
(defun verb--headers-content-type (headers)
  "Return the value of the \"Content-Type\" header in HEADERS.
The value returned has the form (TYPE . CHARSET).  If the charset is
not present, return (TYPE).  If the header itself is not present,
return (nil)."
  (let* ((value (cdr (assoc-string "Content-Type" headers t)))
         (type-subtype (and value (string-trim (car (split-string
                                                     value ";"))))))
    (if (and value type-subtype)
        (cons type-subtype
              (when (string-match "charset=\\([[:alnum:]-]+\\)" value)
                (match-string 1 value)))
      (cons nil nil))))