def request.fields.n

emerging-ezhttp@0.21.0.0 · src/http.bend:625

import emerging-ezhttp@0.21.0.0/src/http.bend as Http
import Base

625# a request's header fields for a body of n octets: Host, User-Agent and
626# Accept (the caller's, or the default), Connection: close, the caller's other
627# fields, Content-Length.
628# A caller's Connection or Content-Length is not sent: Connection: close lets
629# the connection end frame the body when no Content-Length / chunked framing
630# applies (RFC 9112 §9.6 / §6.3), and the body's length is computed.
631def request.fields.n(host: String, +hs: List<&2, Header>, +n: Nat)
632  -> List<&2, Header>:
633  List.append(&2, Header, fields.or(fields.of(FHost{}, hs), [H{"Host", host}]),
634    List.append(&2, Header,
635      fields.or(fields.of(FAgent{}, hs), [H{"User-Agent", "ezhttp"}]),
636      List.append(&2, Header,
637        fields.or(fields.of(FAccept{}, hs), [H{"Accept", "*/*"}]),
638        H{"Connection", "close"}
639          <> List.append(&2, Header, fields.of(FOther{}, hs),
640            clen.field(n, Nat.is_eq(n, 0n))))))

Uses (10)

Used by (2)