def client.follow

emerging-ezhttp@0.21.0.0 · src/client.bend:123

import emerging-ezhttp@0.21.0.0/src/client.bend as Client
import Base
import emerging-ezhttp@0.21.0.0/src/http.bend as Http
import emerging-ezhttp@0.21.0.0/src/body.bend as Body

123# GET, following redirects while `left` hops remain; `body` goes with this
124# hop only. The answer is the last response, which is a redirect only when
125# the hops ran out or its Location is not one redirect.bend follows
126def client.follow(+left: Nat, +url: String, +headers: List<&2, Http.Header>,
127  body: Body.Body, +ms: U32) -> IO(Response):
128  match left:
129    case 0n:
130      client.timed("GET", url, headers, body, ms)
131    case 1n+p:
132      do IO<Response>:
133        r : Response <- client.timed("GET", url, headers, body, ms)
134        client.after(client.hop(left, url, r),
135          next => client.follow(p, next, headers, Body.Empty{}, ms))

Uses (12)

Used by (1)