def redirect.to

bend-kit-http@0.38.2.0 · http.bend:1787

import bend-kit-http@0.38.2.0/http.bend as Http
import Base
import bend-kit-url@0.4.1.0/url.bend as Url
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

1787def redirect.to(+status: U32, +method: String, +from: Url.Abs, headers: Map<&2, List<&2, String>>, body: Bytes.Bytes, next: Maybe<&2, Url.Abs>) -> Maybe<&1, Hop>:
1788  match next:
1789    case None{}:
1790      None{}
1791    case Some{+to}:
1792      +drop = Bool.or(Bool.and(U32.is_eq(status, 303), Bool.not(String.eq(method, "HEAD"))), Bool.and(Bool.or(U32.is_eq(status, 301), U32.is_eq(status, 302)), String.eq(method, "POST")))
1793      Some{Hop{Bool.pick(String, drop, "GET", method), to, redirect.hdrs(headers, drop, Bool.not(String.eq(redirect.origin(from), redirect.origin(to)))), redirect.body(drop, body)}}

Uses (17)

Used by (1)