@maschinenlesbar.org/lebensmittelwarnung-cli
    Preparing search index...

    Class RequestEngine

    Index
    • The request URL as an error message names it: buildUrl with the userinfo redacted (https://***@host/…), cut at 500 characters. An error about an answer starts with GET <this>: , so it says which host gave the bad answer (a wrong --base-url).

      Parameters

      Returns string

    • GET a feed path and parse the RSS reply.

      The response Content-Type does not decide whether the body is a feed (the portal serves it as text/xml, but we sniff the body rather than trust the type); only its charset is used, to decode the body (see decodeXml). Two failure modes are surfaced as a typed LebensmittelwarnungParseError with a plain-language message rather than a cryptic parse failure:

      • an HTML shell (the feed moved, or a proxy returned the website); and
      • an EMPTY body — which is exactly what the DEFUNCT legacy JSON API returns (HTTP 200 + Content-Length: 0 since the portal relaunch), so the hint names it explicitly.

      Parameters

      Returns Promise<RssFeed>

    • buildUrl without the base URL's userinfo: the base that relative links in the feed (image srcs of an item without a <link>) are resolved against, so a password in the base URL can never end up in a warning's imageUrls.

      Parameters

      • path: string

      Returns string

    • getFeed without the warning: the feed, and how many characters of it were not valid text and became U+FFFD (invalid bytes, references to a lone surrogate in the item leaves). The text is never changed silently: the caller reports the count with reportReplaced, once it has decoded the rest of the answer.

      Parameters

      Returns Promise<{ feed: RssFeed; replaced: number }>

    • Tell onWarning that replaced characters of the answer to path/query were not valid text and became U+FFFD; nothing when there were none. A throwing callback never breaks the request. getFeed calls it; a caller of readFeed that decodes more of the answer (the client's descriptions) calls it once with the whole count.

      Parameters

      • path: string
      • query: QueryParams | undefined
      • replaced: number

      Returns void

    • Perform a GET with Accept negotiation and transient-error retries. Redirects are NOT followed — a 3xx surfaces as an error (the canonical host answers the feed directly).

      Parameters

      • path: string
      • Optionalquery: QueryParams
      • accept: string = "application/rss+xml, application/xml"

      Returns Promise<RawResponse>