Function: verb-request-spec-override

verb-request-spec-override is a byte-compiled function defined in verb.el.

Signature

(verb-request-spec-override &rest ARGS)

Implementations

(verb-request-spec-override (ORIGINAL verb-request-spec) OTHER) in `verb.el'.

Override request spec ORIGINAL with OTHER, return the result. Override each member of request ORIGINAL with one from OTHER in the following way, to form a new request specification:

method

Use OTHER's HTTP method if it is non-nil, otherwise use ORIGINAL's.

url

Construct a new URL using a combination of both URLs. The new URL's path is a concatenation of ORIGINAL's and OTHER's paths. The new URL's query string is a union of both ORIGINAL's and OTHER's query strings, preferring OTHER's values when both contain the same key. Use all other components (host, port, user, etc.) from OTHER if they are non-nil, or from ORIGINAL otherwise. If either OTHER's or ORIGINAL's URL is nil, use the other one's without modifications.

headers

Create a union of ORIGINAL's and OTHER's headers, using OTHER's values when both contain the same header.

body

Use OTHER's body if it is non-nil, otherwise use ORIGINAL's.

metadata

Always use OTHER's metadata.

Modify neither request specification, return a new one.

Source Code

;; Defined in /nix/store/8jnfn8w2mxcxbr2crbklcnija9m0zlkq-emacs-packages-deps/share/emacs/site-lisp/elpa/verb-20260818.1921/verb.el
(cl-defmethod verb-request-spec-override ((original verb-request-spec) other)
  "Override request spec ORIGINAL with OTHER, return the result.
Override each member of request ORIGINAL with one from OTHER in the
following way, to form a new request specification:

method

  Use OTHER's HTTP method if it is non-nil, otherwise use ORIGINAL's.

url

  Construct a new URL using a combination of both URLs.  The new URL's
  path is a concatenation of ORIGINAL's and OTHER's paths.  The new
  URL's query string is a union of both ORIGINAL's and OTHER's query
  strings, preferring OTHER's values when both contain the same key.
  Use all other components (host, port, user, etc.) from OTHER if they
  are non-nil, or from ORIGINAL otherwise.  If either OTHER's or
  ORIGINAL's URL is nil, use the other one's without modifications.

headers

  Create a union of ORIGINAL's and OTHER's headers, using OTHER's
  values when both contain the same header.

body

  Use OTHER's body if it is non-nil, otherwise use ORIGINAL's.

metadata

  Always use OTHER's metadata.

Modify neither request specification, return a new one."
  (unless (object-of-class-p other 'verb-request-spec)
    (user-error "%s" "Argument OTHER must be a `verb-request-spec'"))
  (if (let ((original-origin (verb--request-spec-url-origin original))
            (other-origin (verb--request-spec-url-origin other)))
        (and other-origin
             (not (equal original-origin other-origin))))
      other
    (verb-request-spec :method (or (oref other method)
                                   (oref original method))
                       :url (verb--override-url (oref original url)
                                                (oref other url))
                       :headers (verb--override-headers (oref original headers)
                                                        (oref other headers))
                       :body (or (oref other body) (oref original body))
                       :metadata (oref other metadata))))